[whatwg] When to stop <video> elements from playing

On Fri, 26 Oct 2007, Jonas Sicking wrote:
>
> A couple of comments:
> 
> The spec currently doesn't say to set the autoplaying flag to false when 
> an element is removed from the Document. I take it that will mean that 
> the element will start playing if it's currently waiting for data? This 
> seems undesirable to me for two reasons:
> 
> A) I think nodes not in the document should only start playing when more 
> explicitly asked to.
>
> B) It creates a race condition where the element _will_not_ play when if 
> enough data had been downloaded at the point when the element was 
> removed, but _will_ play if it was still waiting for data.
> 
> Is there any reason we couldn't state the removing the element from the 
> Document calls pause() on the element?

Good point. Fixed.


> I think that it is still currently possible that a currently playing 
> element can get garbage collected. Alternatively, that it is possible to 
> create elements that will never stop playing, even if the user navigates 
> away. Consider the following scenario:
> 
> 1) Page A opens a new window containing Page B
> 2) Page A creates a reference to Page B
> 3) Page B creates an <audio> element that doesn't live in its Document
>    and sticks it in a global variable of its context.
> 4) Window containing Page B is closed. Page B does not go away since
>    Page A is holding a reference to it.
> 5) Page B calls .play() on the <audio>

At this point nothing happens, because B isn't an active document, and 
playback only occurs (according to the spec) if the ownerDocument is an 
active document.


> The only step here that is slightly suspicious is step 5 since a 
> closed-but-alive page is running script.

Right, but the point would still hold if page A called .play().


> I believe this can happen in a number of ways, the simplest being that 
> Page A calls a function on Page B. But I suspect there are also events 
> that can fire in Page B even after it has closed.

Actually per spec, if I recall, you can't run script if you're not an 
active document. (To start with, your Window object won't have your 
properties any more, which makes things difficult if we allow script.)


> I believe the best solution here is to say that step 5 should throw an 
> exception. I.e. you can't start playing a media element whose 
> .ownerDocument is not a displayed document.

What do you think of what the spec says at the moment?

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

Received on Friday, 26 October 2007 17:49:10 UTC