[whatwg] Media load algorithm feedback

Ian Hickson ian at hixie.ch
Thu Feb 26 01:15:38 PST 2009

On Wed, 25 Feb 2009, Chris Pearce wrote:
> We now have three things called load. The "load() method", the "load 
> algorithm", and the "resource-load algorithm". It might be clearer if 
> they were called the "load() method", the "resource selection 
> algorithm", and the "resource fetch algorithm".

Done and done.

> From the "using source elements" load algorithm sub-step:
> > 
> > /Search loop:/ Run these substeps atomically (so that the DOM cannot change
> > while they are running):
> > 
> >   1.
> > 
> >       If the node after pointer is the end of the list, then jump to
> >       the step below labeled /waiting/.
> > 
> [...]
> > 7. Waiting: Set the error attribute to a new MediaError object whose code
> > attribute is set to MEDIA_ERR_NONE_SUPPORTED.
> > 8. Set the element's networkState attribute to the NETWORK_NO_SOURCE value
> > 9. Queue a task to fire a progress event called error at the media element.
> > 10. Set the element's delaying-the-load-event flag to false. This stops
> > delaying the load event.
> > 11. Wait until the node after pointer is a node other than the end of the
> > list. (This step might wait forever.)
> There's no step 12; I think the intention is that we return to the Search
> loop, but it's not documented.

Oops. Fixed.

> Step 1 of the load algorithm:
> > 1. While the media element has neither a src attribute nor any source
> > element children, wait. (This steps might wait forever.) 
> And further down it says:
> > If a media element
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#media-element>
> > whose |networkState
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-networkstate>|
> > has the value |NETWORK_EMPTY
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom-media-network_empty>|
> > is inserted into a document
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#insert-an-element-into-a-document>,
> > the user agent must asynchronously invoke the media element
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#media-element>'s
> > load algorithm
> > <http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#concept-media-load-algorithm>.
> I think that should be "invoke the load() method"? If it's "invoke the load()
> method", running load() will cancel any already running instance of the load
> algorithm - e.g. any load which is waiting at step 1 of the load algorithm. As
> it's written, the load /algorithm /will be invoked, which will not cancel any
> waiting loads, and it could in fact it create another instance of the load
> algorithm waiting at step 1 of the load algorithm. So we would create two
> concurrent instances of the load algorithm, both waiting at step 1 of the load
> algorithm by doing the following:
> var v = document.createVideo();
> v.load();
> document.body.appendElement(v);
> Setting v.src or adding a <source> child element to v will awaken two
> instances of the load /algorithm.

Oops. The resource selection algorithm (previously, load algorithm) was 
supposed to immediately set the readyState to something other than 
NETWORK_EMPTY so that this couldn't happen, but I added the spin loop step 
late in the process to handle the case where there was neither src="" nor 
<source> so as to not preclude either being added later, and forgot to 
keep that invariant. I've fixed it now -- if the spin loop is to run, it 
first sets the readyState to NETWORK_NO_SOURCE as if it had run through 
and failed to find a media resource.

> /Other than that, the media load spec seems sensible.



Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list