Skip to content

Commit

Permalink
[gow] (2) Fix race conditions in the <video> load mechanism.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@2907 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 25, 2009
1 parent 2e01910 commit 566c4f9
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 49 deletions.
66 changes: 43 additions & 23 deletions index
Expand Up @@ -19129,9 +19129,8 @@ interface <dfn id=htmlaudioelement>HTMLAudioElement</dfn> : <a href=#htmlmediael
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>

Expand Down Expand Up @@ -19774,7 +19773,7 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {

</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>
Expand All @@ -19786,8 +19785,10 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {

</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>

Expand All @@ -19796,17 +19797,36 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {

<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>

</ol><p>Otherwise, run these substeps:</p>

<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><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>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>
<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>
Expand Down Expand Up @@ -19976,10 +19996,12 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {
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>

Expand Down Expand Up @@ -20292,9 +20314,9 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {

</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>

Expand Down Expand Up @@ -20942,8 +20964,7 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {

<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>
Expand Down Expand Up @@ -20999,8 +21020,7 @@ interface <dfn id=cuerangecallback>CueRangeCallback</dfn> {

<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
Expand Down
84 changes: 58 additions & 26 deletions source
Expand Up @@ -20604,9 +20604,9 @@ interface <dfn>HTMLAudioElement</dfn> : <span>HTMLMediaElement</span> {
<code>audio</code> element). If the <var title="">src</var> argument
is present, the object created must have its <code
title="dom-media-src">src</code> content attribute set to the
provided value, and the user agent must asynchronously invoke the
object's <span title="concept-media-load-algorithm">resource
selection algorithm</span> before returning.</p>
provided value, and the user agent must invoke the object's <span
title="concept-media-load-algorithm">resource selection
algorithm</span> before returning.</p>

</div>

Expand Down Expand Up @@ -21342,7 +21342,7 @@ interface <dfn>CueRangeCallback</dfn> {

</li>

<li><p>Asynchronously invoke the <span>media element</span>'s <span
<li><p>Invoke the <span>media element</span>'s <span
title="concept-media-load-algorithm">resource selection
algorithm</span>.</li>

Expand All @@ -21357,8 +21357,10 @@ interface <dfn>CueRangeCallback</dfn> {

<p>The <dfn title="concept-media-load-algorithm">resource selection
algorithm</dfn> for a <span>media element</span> is as follows. This
algorithm is always invoked asynchronously, meaning that it runs in
the background with scripts and other <span
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 <span
title="concept-task">tasks</span> running in parallel.</p>

<ol>
Expand All @@ -21375,22 +21377,51 @@ interface <dfn>CueRangeCallback</dfn> {
title="dom-media-networkState">networkState</code> to <code
title="dom-media-NETWORK_NO_SOURCE">NETWORK_NO_SOURCE</code>.</p></li>

<li><p>Run the remainder of the <span
title="concept-media-load-algorithm">resource selection
algorithm</span> steps asynchronously, allowing the <span
title="concept-task">task</span> that invoked this algorithm to
continue.</p></li>

<li><p>While the <span>media element</span> has neither a <code
title="attr-media-src">src</code> attribute nor any
<code>source</code> element children, wait. (This steps might
wait forever.)</p></li>
<code>source</code> element children, wait. (This step might wait
forever.)</p></li>

<li><p>Before the <span title="concept-task">task</span> that set
the <code title="attr-media-src">src</code> attribute or inserted
the <code>source</code> element has a chance to complete, set the
<span>media element</span>'s <span>delaying-the-load-event
flag</span> to true (this <span title="delay the load
event">delays the load event</span>), and set its <code
title="dom-media-networkState">networkState</code> to <code
title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p></li>

</ol>

</li>
<p>Otherwise, run these substeps:</p>

<ol>

<li><p>Set the element's <span>delaying-the-load-event flag</span>
to true. This <span title="delay the load event">delays the load
event</span>.</p></li>
<li><p>Set the <span>media element</span>'s
<span>delaying-the-load-event flag</span> to true (this <span
title="delay the load event">delays the load event</span>), and
set its <code title="dom-media-networkState">networkState</code>
to <code
title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p></li>

<li><p>Set the <code
title="dom-media-networkState">networkState</code> to <code
title="dom-media-NETWORK_LOADING">NETWORK_LOADING</code>.</p></li>
<li><p>Run the remainder of the <span
title="concept-media-load-algorithm">resource selection
algorithm</span> steps asynchronously, allowing the <span
title="concept-task">task</span> that invoked this algorithm to
continue.</p></li>

</ol>

</li>

<li><p class="note">By this point, the algorithm is running
asynchronously.</p></li>

<li><p><span>Queue a task</span> to <span>fire a progress
event</span> called <code title="event-loadstart">loadstart</code>
Expand Down Expand Up @@ -21601,10 +21632,12 @@ interface <dfn>CueRangeCallback</dfn> {
node other than the end of the list. (This step might wait
forever.)</p></li>

<li><p>Set the element's <span>delaying-the-load-event
<li><p>Before the <span title="concept-task">task</span> that
inserted the <code>source</code> element has a chance to
complete, set the element's <span>delaying-the-load-event
flag</span> back to true. This <span title="delay the load
event">delays the load event</span> again, in case it hasn't gone
been fired yet.</p></li>
event">delays the load event</span> again, in case it hasn't been
fired yet.</p></li>

<li><p>Jump back to the step labeled <i>search loop</i>.</p></li>

Expand Down Expand Up @@ -21997,10 +22030,9 @@ interface <dfn>CueRangeCallback</dfn> {
title="dom-media-networkState">networkState</code> has the value
<code title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code> is <span
title="insert an element into a document">inserted into a
document</span>, the user agent must asynchronously invoke the
<span>media element</span>'s <span
title="concept-media-load-algorithm">resource selection
algorithm</span>.</p>
document</span>, the user agent must invoke the <span>media
element</span>'s <span title="concept-media-load-algorithm">resource
selection algorithm</span>.</p>

</div>

Expand Down Expand Up @@ -22766,8 +22798,8 @@ interface <dfn>CueRangeCallback</dfn> {
title="dom-media-networkState">networkState</code> attribute has
the value <code
title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, then the user
agent must asynchronously invoke the <span>media element</span>'s
<span title="concept-media-load-algorithm">resource selection
agent must invoke the <span>media element</span>'s <span
title="concept-media-load-algorithm">resource selection
algorithm</span>.</p></li>

<li>
Expand Down Expand Up @@ -22842,8 +22874,8 @@ interface <dfn>CueRangeCallback</dfn> {
title="dom-media-networkState">networkState</code> attribute has
the value <code
title="dom-media-NETWORK_EMPTY">NETWORK_EMPTY</code>, then the user
agent must asynchronously invoke the <span>media element</span>'s
<span title="concept-media-load-algorithm">resource selection
agent must invoke the <span>media element</span>'s <span
title="concept-media-load-algorithm">resource selection
algorithm</span>.</p></li>

<li><p>If the <span>media element</span>'s <code
Expand Down

0 comments on commit 566c4f9

Please sign in to comment.