spec/Overview.html 1.2075 2907 Fix race conditions in the <video> load

Fix race conditions in the <video> load mechanism. (whatwg r2907)

play()
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#dom-media-play
load()
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#dom-media-load
autobuffer
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#attr-media-autobuffer
pause()
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#dom-media-pause
resource selection algorithm
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#concept-media-load-algorithm
If the media data can be fetched but has non-fatal errors or uses, in part, codecs that are unsupported, preventing the user agent from rendering the content completely correctly but not preventing playback altogether
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#non-fatal-media-error
Audio()
http://people.w3.org/mike/diffs/html5/spec/Overview.1.2075.html#dom-audio

http://people.w3.org/mike/diffs/html5/spec/Overview.diff.html
http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.2074&r2=1.2075&f=h
http://html5.org/tools/web-apps-tracker?from=2906&to=2907

===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.2074
retrieving revision 1.2075
diff -u -d -r1.2074 -r1.2075
--- Overview.html 25 Mar 2009 07:11:48 -0000 1.2074
+++ Overview.html 25 Mar 2009 08:40:08 -0000 1.2075
@@ -16638,9 +16638,8 @@
   these must return a new <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> object (a new
   <code><a href=#audio>audio</a></code> element). If the <var title="">src</var> argument
   is present, the object created must have its <code title=dom-media-src><a href=#dom-media-src>src</a></code> content attribute set to the
-  provided value, and the user agent must asynchronously invoke the
-  object's <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource
-  selection algorithm</a> before returning.</p>
+  provided value, and the user agent must invoke the object's <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
+  algorithm</a> before returning.</p>
 
   </div><div class=impl>
 
@@ -17196,7 +17195,7 @@
 
     </ol></li>
 
-   <li><p>Asynchronously invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
+   <li><p>Invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
    algorithm</a>.</li>
 
    <li>
@@ -17208,8 +17207,10 @@
 
   </ol><p>The <dfn id=concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
   algorithm</dfn> for a <a href=#media-element>media element</a> is as follows. This
-  algorithm is always invoked asynchronously, meaning that it runs in
-  the background with scripts and other <a href=#concept-task title=concept-task>tasks</a> running in parallel.</p>
+  algorithm is always invoked synchronously, but one of the first
+  steps in the algorithm is to return and continue running the
+  remaining steps asynchronously, meaning that it runs in the
+  background with scripts and other <a href=#concept-task title=concept-task>tasks</a> running in parallel.</p>
 
   <ol><li>
 
@@ -17218,17 +17219,36 @@
 
     <ol><li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_NO_SOURCE><a href=#dom-media-network_no_source>NETWORK_NO_SOURCE</a></code>.</li>
 
+     <li><p>Run the remainder of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
+     algorithm</a> steps asynchronously, allowing the <a href=#concept-task title=concept-task>task</a> that invoked this algorithm to
+     continue.</li>
+
      <li><p>While the <a href=#media-element>media element</a> has neither a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute nor any
-     <code><a href=#the-source-element>source</a></code> element children, wait. (This steps might
-     wait forever.)</li>
+     <code><a href=#the-source-element>source</a></code> element children, wait. (This step might wait
+     forever.)</li>
 
-    </ol></li>
+     <li><p>Before the <a href=#concept-task title=concept-task>task</a> that set
+     the <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute or inserted
+     the <code><a href=#the-source-element>source</a></code> element has a chance to complete, set the
+     <a href=#media-element>media element</a>'s <a href=#delaying-the-load-event-flag>delaying-the-load-event
+     flag</a> to true (this <a href=#delay-the-load-event title="delay the load
+     event">delays the load event</a>), and set its <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li>
 
-   <li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a>
-   to true. This <a href=#delay-the-load-event title="delay the load event">delays the load
-   event</a>.</li>
+    </ol><p>Otherwise, run these substeps:</p>
 
-   <li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li>
+    <ol><li><p>Set the <a href=#media-element>media element</a>'s
+     <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a> to true (this <a href=#delay-the-load-event title="delay the load event">delays the load event</a>), and
+     set its <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code>
+     to <code title=dom-media-NETWORK_LOADING><a href=#dom-media-network_loading>NETWORK_LOADING</a></code>.</li>
+
+     <li><p>Run the remainder of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
+     algorithm</a> steps asynchronously, allowing the <a href=#concept-task title=concept-task>task</a> that invoked this algorithm to
+     continue.</li>
+
+    </ol></li>
+
+   <li><p class=note>By this point, the algorithm is running
+   asynchronously.</li>
 
    <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-progress-event>fire a progress
    event</a> called <code title=event-loadstart><a href=#event-loadstart>loadstart</a></code>
@@ -17398,10 +17418,12 @@
      node other than the end of the list. (This step might wait
      forever.)</li>
 
-     <li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event
+     <li><p>Before the <a href=#concept-task title=concept-task>task</a> that
+     inserted the <code><a href=#the-source-element>source</a></code> element has a chance to
+     complete, set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event
      flag</a> back to true. This <a href=#delay-the-load-event title="delay the load
-     event">delays the load event</a> again, in case it hasn't gone
-     been fired yet.</li>
+     event">delays the load event</a> again, in case it hasn't been
+     fired yet.</li>
 
      <li><p>Jump back to the step labeled <i>search loop</i>.</li>
 
@@ -17714,9 +17736,9 @@
 
   </ol><p>If a <a href=#media-element>media element</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> has the value
   <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a
-  document</a>, the user agent must asynchronously invoke the
-  <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
-  algorithm</a>.</p>
+  document</a>, the user agent must invoke the <a href=#media-element>media
+  element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource
+  selection algorithm</a>.</p>
 
   </div><p>The <dfn id=attr-media-autobuffer title=attr-media-autobuffer><code>autobuffer</code></dfn>
   attribute is a <a href=#boolean-attribute>boolean attribute</a>. Its presence hints to
@@ -18318,8 +18340,7 @@
 
   <ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has
    the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, then the user
-   agent must asynchronously invoke the <a href=#media-element>media element</a>'s
-   <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
+   agent must invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
    algorithm</a>.</li>
 
    <li>
@@ -18375,8 +18396,7 @@
 
   <ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has
    the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, then the user
-   agent must asynchronously invoke the <a href=#media-element>media element</a>'s
-   <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
+   agent must invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
    algorithm</a>.</li>
 
    <li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, it must

Received on Wednesday, 25 March 2009 08:43:00 UTC