<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12227</bug_id>
          
          <creation_ts>2011-03-02 23:49:48 +0000</creation_ts>
          <short_desc>&lt;video&gt; The readyState check in the &quot;potentially playing&quot; definition should not be used to influence GC of media elements</short_desc>
          <delta_ts>2011-08-04 05:02:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adrian Bateman [MSFT]">adrianba</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ayg</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>46205</commentid>
    <comment_count>0</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-03-02 23:49:48 +0000</bug_when>
    <thetext>See the thread starting at [1] including [2] and [3].

We&apos;ve analysed this section of the spec.
http://dev.w3.org/html5/spec/video.html#media-playback

This uses the phrase &quot;potentially playing&quot;, which is defined as:

&quot;A media element is said to be potentially playing when its paused
 attribute is false, the readyState attribute is either HAVE_FUTURE_DATA
 or HAVE_ENOUGH_DATA, the element has not ended playback, playback has
 not stopped due to errors, and the element has not paused for user
 interaction.&quot;
http://dev.w3.org/html5/spec/video.html#potentially-playing

The problem with this is that there is still a race between the GC and the
network in this example:

function playAudio() {
  var a = new Audio(&quot;http://www.example.com/music&quot;);
  a.play();
}

This means that after the function exits, the behaviour will vary depending
upon whether the GC fires before or after readyState gets to HAVE_FUTURE_DATA.

We propose removing the readyState check from potentially playing this specific scenario so that the element will only be available to be collected on error, when paused, at the end of the media, or if somehow stopped by user interaction.


[1] http://lists.w3.org/Archives/Public/public-html/2011Jan/0438.html
[2] http://lists.w3.org/Archives/Public/public-html/2011Feb/0006.html
[3] http://lists.w3.org/Archives/Public/public-html/2011Feb/0007.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46212</commentid>
    <comment_count>1</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2011-03-03 06:34:35 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; The problem with this is that there is still a race between the GC and the
&gt; network in this example:
&gt; 
&gt; function playAudio() {
&gt;   var a = new Audio(&quot;http://www.example.com/music&quot;);
&gt;   a.play();
&gt; }
&gt; 
&gt; This means that after the function exits, the behaviour will vary depending
&gt; upon whether the GC fires before or after readyState gets to HAVE_FUTURE_DATA.

After the function exists, paused will be false, so it will be &quot;potentially playing&quot;. I think what you mean is that it could be GC&apos;d just before a.play().

Another example where I&apos;m unsure of the behavior is:

var a = new Audio(&quot;http://www.example.com/music&quot;);
a.canplaythrough = function() { a.play(); };</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46221</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-03-03 18:35:45 +0000</bug_when>
    <thetext>&quot;Paused is false&quot; is only one part of an AND clause. Before you get to HAVE_CURRENT_DATA then potentially playing is false with the current definition so the element could be collected before the play begins but after calling play().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46225</commentid>
    <comment_count>3</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2011-03-03 20:34:06 +0000</bug_when>
    <thetext>Oops, my bad. The example with the canplaythrough event listener is still racy though, and just removing the readyState check from potentially playing wouldn&apos;t fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49431</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-06-10 19:33:10 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: no spec change
Rationale: I changed the wording a few weeks ago in a way that I believe makes this a non-issue. It now says:

&quot;Media elements must not stop playing just because all references to them have been removed; only once a media element is in a state where no further audio could ever be played by that element may the element be garbage collected.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52548</commentid>
    <comment_count>5</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:02:29 +0000</bug_when>
    <thetext>mass-moved component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>