Re: [whatwg] preload="none" and HTMLMediaElement.load()

On Wed, Jun 17, 2015 at 2:55 AM, Brian Birtles <bbirtles@mozilla.com> wrote:
> The HTMLMediaElement.load()[1] method currently cancels playback of the
> current resource and runs the resource selection algorithm[2] (and in turn
> the resource fetch algorithm[3]). When preload="none", however, the resource
> fetch algorithm doesn't require the UA to load data or progress to
> HAVE_METADATA--instead it can suspend the load until, for example, the user
> goes to play the video.
>
> In Firefox we've hit compatibility issues where some sites are calling
> load() on preload="none" resources and expecting to get a "loadedmetadata"
> event.[4]
>
> Apparently, even with preload="none", Chrome and IE progress to
> HAVE_METADATA when load() is called. Presto, apparently, does not.
>
> I've just landed a patch in Firefox to make a call to load() treat
> preload="none" as preload="metadata" to match the behavior of Chrome/IE in
> this case.
>
> (Note that we need to do this not only when preload="none" is explicitly
> specified but also when the preload attribute is missing and the UA's
> missing value default for preload is 'none'--as is the case for us on
> mobile.)
>
> Is it possible to get this reflected in the spec?
>
> Best regards,
>
> Brian
>
> [1]
> https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-load
> [2]
> https://html.spec.whatwg.org/multipage/embedded-content.html#concept-media-load-algorithm
> [3]
> https://html.spec.whatwg.org/multipage/embedded-content.html#concept-media-load-resource
> [4] https://bugzilla.mozilla.org/show_bug.cgi?id=1165203

Thanks for raising this issue, Brian!

It turns out it is a very deliberate change in WebKit made in 2011:
https://bugs.webkit.org/show_bug.cgi?id=66414

I presume that was motivated by a similar problem in the wild,
although no reference was made to a real site in the bug report.

It's unfortunate that load() means anything more than to run the media
element load algorithm, but it's not crazy that load() actually load
something, so I agree that we should spec this behavior somehow. Can
you file a spec bug at https://whatwg.org/newbug to track this?

The most straightforward way to specify this is probably if load()
sets an internal flag on the media element, and if the the resource
fetch algorithm simply skips the preload="none" steps if it is set.
Another path could be to make more explicit that there's an internal
preload state that is influenced not only by the content attribute,
but also by setting the autoplay attribute, calling play(), setting
currentTime, and now, calling load().

Philip

Received on Monday, 6 July 2015 11:45:04 UTC