[whatwg] Race condition in media load algorithm

On Tue, 03 Aug 2010 17:40:33 +0200, Boris Zbarsky <bzbarsky at mit.edu> wrote:

> On 8/3/10 4:27 AM, Philip J?genstedt wrote:
>> For the record, here's how I interpreted "await a stable state":
>>
>> The only state that is not stable is a running script.
>
> I don't think that's true; for example you could be in an unstable state  
> if you're in the middle of the parser inserting some nodes into the DOM.

If the parser running in considered an unstable state, then we would have  
to wait until the whole document has finished parsing before running the  
resource selection algorithm. Thus, <video> would be unnecessarily delayed  
in a way that <img> isn't. The spec is certainly written in a way that  
makes good sense when triggering the resource selection algorithm when the  
parser first sets a src attribute or appends a child source element and  
then waiting in NETWORK_NO_SOURCE for more source elements. If this isn't  
the intention, I have really completely misunderstood what the spec is  
trying to do. Whatever the language used, I suggest letting the parser  
trigger the resource selection algorithm synchronously.

>> Therefore, when reaching that step, if the
>> resource selection algorithm was triggered by a script, wait until that
>> script has finished and then continue.
>
> Per spec as currently written, this will give the wrong behavior.  For  
> example, if the script in question calls showModalDialog, this is  
> supposed to interrupt the script task and spin the event loop, and so  
> your synchronous section would need to run while the modal dialog is up.  
>   It doesn't sound like your implementation does that.

That could be, but is this behavior actually useful for anything? It's  
certainly simpler to implement and more predictable for authors to always  
wait until the current script has finished executing.

-- 
Philip J?genstedt
Core Developer
Opera Software

Received on Wednesday, 4 August 2010 01:29:26 UTC