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 10421 - Setting media element's src and autoplay attribute may expose a race
Summary: Setting media element's src and autoplay attribute may expose a race
Status: CLOSED WORKSFORME
Alias: None
Product: HTML WG
Classification: Unclassified
Component: pre-LC1 HTML5 spec (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://dev.w3.org/html5/spec/video.ht...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-24 22:54 UTC by Adrian Bateman [MSFT]
Modified: 2010-10-04 14:49 UTC (History)
3 users (show)

See Also:


Attachments

Description Adrian Bateman [MSFT] 2010-08-24 22:54:12 UTC
In the following code, a video element is constructed and it's src attribute set. This initiates the resource retrieval. For a fast (e.g. local) resouce, the readystate could be set to HAVE_ENOUGH_DATA before the following line that sets the autoplay attribute. Because the user agent only considers the autoplay value on the readystate change then it would not play in this scenario. Setting the autoplay value first would succeed but web developers don't expect the order to matter.

var v = document.createElement(video);
v.src = ...;
v.autoplay = true;

Proposal:

Update the spec to say, "The autoplay IDL attribute must reflect the content attribute of the same name.  Upon setting, if the ready state is HAVE_ENOUGH_DATA or greater, the user agent must behave as if the play() method was invoked."
Comment 1 Simon Pieters 2010-09-07 09:52:58 UTC
I think you might not have implemented the spec correctly.

[[
If a src attribute of a media element is set or changed, the user agent must invoke the media element's media element load algorithm.
]]

The media element load algorithm invokes the resource selection algorithm, which changes networkState to NETWORK_NO_SOURCE and then awaits a stable state, which will let the script continue to run before the resource selection algorithm continues (and thus before the resource retrieval is initiated and readyState is changed).
Comment 2 Adrian Bateman [MSFT] 2010-09-13 18:16:12 UTC
Thanks Simon. We've reviewed this and agree.