This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27251 - Correct the “All or Nothing” Approach Currently Implemented For HTMLMediaElement / MSE
Summary: Correct the “All or Nothing” Approach Currently Implemented For HTMLMediaElem...
Status: RESOLVED WONTFIX
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-05 14:59 UTC by Karan Lyons
Modified: 2017-07-21 09:32 UTC (History)
3 users (show)

See Also:


Attachments

Description Karan Lyons 2014-11-05 14:59:25 UTC
(Duplicate of https://www.w3.org/Bugs/Public/show_bug.cgi?id=27249)

(Apologies for the length and possibly poor nomenclature of the below.)

Currently if you use an HTMLMediaElement:
    1) The browser automatically determines the file types / codecs of the sources and chooses the “best” source to play.
    2) The browser automatically parses the metadata of the chosen source in order to enable abilities like seeking, get the duration, etc.
    3) The browser implements some version of source buffering, but offers you know control over it. Not even at the very least starting and stopping buffering, and at most, even doing things like setting how much to buffer ahead, etc.
    4) The browser exposes *none* of this known metadata (file type, codec, file structure for seeking, bitrate, etc.) with the exception of the height, width, and duration.

If you use MSE:
    1) The browser expects you to know ahead of time if the data you’re putting into a SourceBuffer is decodable by the browser.
    2) The browser expects you to know the metadata associated with the source in order to set the duration and implement seeking *yourself*.
    3) The browser implements no buffering.

Those are your only two options. If you want to be able to do something as simple as starting or stopping buffering, you need to know all the associated metadata for your file (file type, codec, stco atom in the case of QT containers, height, width, duration, perhaps more). Your options are either to use a prepared manifest of all that required data, which is only possible if you know what content you’re to play ahead of time, or determine all that information dynamically, for which as a developer you’re now forced to use far less performant javascript, *despite the fact that the browser already implements fast compiled functions to do all this work*.


This “all or nothing” approach permeates both specs. As one example, HTMLMediaElement will tell you if it can play a source with canPlayType(), which requires a string of the format “filetype; codecs”. However it provides no way to *get* the format of a file, despite the fact that it can quite clearly determine this information (how else does it find the “best” source to play?).

Another example is that readyState change events, though fired based on buffer data, contain no snapshot of the TimeRanges buffered, despite the fact that those TimeRanges can and will change in time between the event being triggered and an event listener running and iterating through HTMLMediaElement.buffered.

MSE seems to have less of these problems, though an obvious one is the requirement for a type string with addSourceBuffer(), despite—again—no way to *get* the type of a buffer/file.


This honestly seems fairly difficult to fix since it’s a bug in the thinking behind the implementations and not just some aspect of the implementations themselves. Moreover, it requires more to be changed in the HTMLMediaElement spec than MSE’s. But I do think it’s very important that these shortcomings are addressed.

At the very least allowing greater control over the buffer (whereby “greater” I just mean the ability to start and stop the buffer, and *perhaps* control its length) would allow most developers to stick with HTMLMediaElement as opposed to being forced to use the more complex MSE.

At the most there needs to be a far greater degree of transparency in all the work the browser does regarding media. Metadata, file type, codec information, etc. should *all* be exposed to the developer, along with functions for determining them from an arbitrary SourceBuffer/ArrayBuffer/Blob/etc. The aim should be to ensure that the handling of media can continue to be dynamic (e.g. no manifests) and performant (e.g. no javascript based container parsing to get metadata) regardless of where along the continuum of HTMLMediaElement <-> MSE the developer chooses to reside.
Comment 1 Ian 'Hixie' Hickson 2014-11-06 00:47:28 UTC
This is the design intent of HTMLMediaElement. It's operating on the user's behalf; the whole point is that the user should be in control, not the author.
Comment 2 Karan Lyons 2014-11-06 00:57:45 UTC
I’m not sure that address control over the buffer within HTMLMediaElement, specifically starting and stopping the buffer. preload=“auto”, for example, is set by the developer, not the user, and in some browsers will buffer the entire video, regardless of its size. That doesn’t seem to place the user in control.

If that assessment is agreed to be true, then I’m not sure how adding (and again, just to use this one example) developer initiated start/stop functionality to the buffer doesn’t help *everyone* (hosts and clients, both in bandwidth consumption).

Even if we disagree on that assessment, that doesn’t speak to exposing metadata about the media as readonly values to the developer, which aids the developer in crafting a better experience for the user.

Honestly, I’ve no idea how my suggestions could *hurt* the user experience, and I believe they certainly *help* the user and the author.
Comment 3 Ian 'Hixie' Hickson 2014-11-06 18:36:24 UTC
"preload" is just a hint; the browser is explicitly allowed to ignore it at will.

Exposing the metadata is something we've considered, yes. It's pending browser vendor interest; see bug 5755.
Comment 4 Ian 'Hixie' Hickson 2014-12-03 21:52:09 UTC
Here's a way in which it could hurt the user experience: suppose that the user is paying for memory usage by the megabyte (that's not uncommon in virtual server scenarios for instance), and the user is loading Web pages with the browser configured not to buffer anything. If the page is allowed to override this, then the memory usage will be higher, and the user will pay more money.

Another way: suppose the user wants to prebuffer the entire video, so that they can view it offline. If the page says the buffer can only be 24KB, then the video can't be viewed offline.
Comment 5 Anne 2017-07-21 09:32:38 UTC
I'm closing this as WONTFIX since this is not specific enough to take action on. If you have a more concrete proposal as to what to change I suggest raising it at https://github.com/whatwg/html/issues/new. Thanks.