<?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>27790</bug_id>
          
          <creation_ts>2015-01-09 02:47:49 +0000</creation_ts>
          <short_desc>[MSE] Some of the attributes returning TimeRanges objects seem to return a new object each time the getter is invoked</short_desc>
          <delta_ts>2015-10-13 22:54:54 +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>Media Source Extensions</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>CR</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Boris Zbarsky">bzbarsky</reporter>
          <assigned_to name="Matt Wolenetz">wolenetz</assigned_to>
          <cc>acolwell</cc>
    
    <cc>b.gajda</cc>
    
    <cc>d</cc>
    
    <cc>jyavenard</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-html-media</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      <flag name="needinfo"
          id="14"
          type_id="3"
          status="?"
          setter="acolwell"
          requestee="jyavenard"
    />

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>116940</commentid>
    <comment_count>0</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-01-09 02:47:49 +0000</bug_when>
    <thetext>For example, the definition of SourceBuffer.buffered says: &quot;Let intersection ranges equal a TimeRange object containing a single range from 0 to highest end time.&quot;

This seems to create new object each time someone does .buffered.

This is a pretty bizarre behavior.  If we actually want a new object each time, this should be a method, not an attribute.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116955</commentid>
    <comment_count>1</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-01-09 09:41:20 +0000</bug_when>
    <thetext>This follows the behavior of HTMLMediaElement.buffered/played/seekable, so maybe file an HTML bug if you want some change there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116957</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-01-09 11:54:48 +0000</bug_when>
    <thetext>That HTML/WHATWG bug has existed for a while and been ignored.  Basically, Ian thinks it&apos;s not an issue in WHATWG because he tends not to care too much about consistency with JS author expectations, the HTML WG is not aiming to change things like this from the WHATWG spec (though this is a case where sanity via the HTML WG might have been nice), and as far as I can tell the TAG hasn&apos;t really been looking very closely at HTML, because it&apos;s too big, so here we are.

Changing this for HTMLMediaElement is also harder because those bits have been shipping in browsers for a good long while now...

But just because the HTML situation is broken due to the politics around HTML and possible legacy compat issues doesn&apos;t mean we should be spreading the brokenness further to new specs, imo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116958</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-01-09 12:51:44 +0000</bug_when>
    <thetext>In particular, see the discussion in bug 22471 where the suggestion that we stop doing the bad thing was just summarily ignored and all the conversation centered around how we prevent other specs from copying the bad thing....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116962</commentid>
    <comment_count>4</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-01-09 13:27:11 +0000</bug_when>
    <thetext>Thanks, bug 22471 was the discussion I wasn&apos;t sure had happened. I&apos;m not the spec editor here, but my take is that returning a new object every time isn&apos;t terrible enough to warrant trying to replace the attribute with a method, it&apos;s too late for HTMLMediaElement and consistency is worth something as well, even when consistently bad.

Ensuring that .buffered returns the same object as long as it hasn&apos;t changed since last access would be a less radical change that&apos;s probably Web compatible, if both specs made the same change.

I&apos;m also OK with the current state of things.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116964</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-01-09 14:13:09 +0000</bug_when>
    <thetext>&gt; my take is that returning a new object every time isn&apos;t terrible enough 

It&apos;s pretty terrible.  It&apos;s a behavior that only C++ implementors seem to think is OK for a JS property get....  Not least because it&apos;s simple for them to do.

&gt; Ensuring that .buffered returns the same object as long as it hasn&apos;t changed
&gt; since last access

Can it change without the event loop spinning or script in some way invoking browser APIs?  Because if not, then this is clearly the correct solution, imo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116972</commentid>
    <comment_count>6</comment_count>
    <who name="Aaron Colwell">acolwell</who>
    <bug_when>2015-01-09 19:52:33 +0000</bug_when>
    <thetext>I&apos;m fine with changing SourceBuffer.buffered to return the same object all the time. Technically these values can only change as part of the &quot;Coded Frame Removal&quot; and &quot;Coded Frame Processing&quot; algorithms.

I&apos;m assuming that you want the value to be stable as long as webapp Javascript is executing. Is this usually handled by using language like &quot;post a task to update the buffered attribute with the contents of intersection_ranges&quot;? If not, could you point me at a good example in other specs.


The spec text that describes always creating a new object for access HTMLMediaElement.buffered probably needs to remain though so that the behavior is consistent with non-MSE playback.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116974</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-01-09 20:05:06 +0000</bug_when>
    <thetext>&gt; Is this usually handled by using language like &quot;post a task to update the
&gt; buffered attribute with the contents of intersection_ranges&quot;?

Yep, this would work fine.  Just have to say which task queue to post it to.  Thank you!

For HTMLMediaElement, that would be bug 22471, so let&apos;s not worry about it here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117016</commentid>
    <comment_count>8</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-01-12 10:59:45 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #5)
&gt; &gt; my take is that returning a new object every time isn&apos;t terrible enough 
&gt; 
&gt; It&apos;s pretty terrible.  It&apos;s a behavior that only C++ implementors seem to
&gt; think is OK for a JS property get....  Not least because it&apos;s simple for
&gt; them to do.

Guilty as charged, I didn&apos;t even consider this problem when implementing these properties in Presto.

&gt; &gt; Ensuring that .buffered returns the same object as long as it hasn&apos;t changed
&gt; &gt; since last access
&gt; 
&gt; Can it change without the event loop spinning or script in some way invoking
&gt; browser APIs?  Because if not, then this is clearly the correct solution,
&gt; imo.

I think that&apos;s true for MediaSource as the append/remove bits are all async. HTMLMediaElement can synchronously detach from its backend by e.g. HTMLMediaElement.load(), but that&apos;s in response to an explicit call. I can think of no way &apos;video.buffered === video.buffered&apos; to ever be false with a definition like &quot;return the same object iff the ranges are identical to the previously returned object.&quot; I don&apos;t think MSE should do this if HTML doesn&apos;t, though.

Always returning the same object and having that be live is also possible, but I&apos;m not a fan of live objects, and it could possibly break existing code that keeps old ranges in order to compare with new ones.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117073</commentid>
    <comment_count>9</comment_count>
    <who name="Bartlomiej Gajda">b.gajda</who>
    <bug_when>2015-01-13 14:36:48 +0000</bug_when>
    <thetext>(In reply to Aaron Colwell from comment #6)
&gt; Technically these values can only change as part of the &quot;Coded
&gt; Frame Removal&quot; and &quot;Coded Frame Processing&quot; algorithms.

Just to be clear - value reported to user is also affected by changing MediaSource readyState state to ended/from ended to open, in cases with 2 track buffers with different buffered regions. 
Example: trackbuffer1: 3-5; trackbuffer2: 7-10; returns buffered 7-10 in ended state, empty range in open.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117081</commentid>
    <comment_count>10</comment_count>
    <who name="Aaron Colwell">acolwell</who>
    <bug_when>2015-01-13 16:35:20 +0000</bug_when>
    <thetext>Boris,

Would just changing the spec to return the same object if the ranges haven&apos;t changed, as Philip suggest, be sufficient? 

I&apos;m worried about making this attribute a live object for the following reasons:
1. It would become inconsistent with HTMLMediaElement.buffered behavior. I know you don&apos;t like this, but I think there is something to be said for keeping all TimeRanges attributes in the web platform behaving the same way especially if they are highly related like the .buffered attributes are.

2. This is one of the oldest parts of the MSE spec and is likely to break sites including large deployments like YouTube and Netflix for seemingly only aesthetic gain.

3. There is no simple way for the web app to make its own copy. The TimeRanges object doesn&apos;t have a way to clone itself so all web applications that wanted to keep a copy have to implement their own cloning logic.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117082</commentid>
    <comment_count>11</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-01-13 16:40:45 +0000</bug_when>
    <thetext>&gt; Would just changing the spec to return the same object if the ranges haven&apos;t
&gt; changed, as Philip suggest, be sufficient? 

Yep.  I said so in comment 5, right?

&gt; I&apos;m worried about making this attribute a live object

Sure.  I think the compat worries are well-justified, live objects are a pain to work with, and we don&apos;t need to go there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117083</commentid>
    <comment_count>12</comment_count>
    <who name="Aaron Colwell">acolwell</who>
    <bug_when>2015-01-13 16:43:13 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #11)
&gt; &gt; Would just changing the spec to return the same object if the ranges haven&apos;t
&gt; &gt; changed, as Philip suggest, be sufficient? 
&gt; 
&gt; Yep.  I said so in comment 5, right?

Ok. It wasn&apos;t clear to me.

&gt; 
&gt; &gt; I&apos;m worried about making this attribute a live object
&gt; 
&gt; Sure.  I think the compat worries are well-justified, live objects are a
&gt; pain to work with, and we don&apos;t need to go there.

Agreed. I&apos;ll make the changes in the next spec update then. Thanks. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117675</commentid>
    <comment_count>13</comment_count>
    <who name="Aaron Colwell">acolwell</who>
    <bug_when>2015-02-03 18:59:02 +0000</bug_when>
    <thetext>Change committed...
https://github.com/w3c/media-source/commit/7a495fe29540835d0e219d3d52f3041f556a1f7d</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119187</commentid>
    <comment_count>14</comment_count>
    <who name="Jean-Yves Avenard">jyavenard</who>
    <bug_when>2015-04-02 00:44:22 +0000</bug_when>
    <thetext>While this bug clearly describe that we should only return the same object (same reference) only if it hasn&apos;t changed.

And so is the summary:
&quot;Bug 27790 - Make .buffered attributes return the same object if nothing has changed.&quot;

is very clear.

I find the actual description of the buffered attribute however to not be reflecting this.
&quot;5.        If intersection ranges does not contain the exact same range information as the current value of this attribute, then update the current value of this attribute to intersection ranges.
6.        Return the current value of this attribute.
&quot;

I read this as always returning the same TimeRange object, and updating the object. Making it effectively a &quot;live&quot; object as described in comment 10.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119188</commentid>
    <comment_count>15</comment_count>
    <who name="Aaron Colwell">acolwell</who>
    <bug_when>2015-04-02 01:13:17 +0000</bug_when>
    <thetext>(In reply to Jean-Yves Avenard from comment #14)
&gt; While this bug clearly describe that we should only return the same object
&gt; (same reference) only if it hasn&apos;t changed.
&gt; 
&gt; And so is the summary:
&gt; &quot;Bug 27790 - Make .buffered attributes return the same object if nothing has
&gt; changed.&quot;
&gt; 
&gt; is very clear.
&gt; 
&gt; I find the actual description of the buffered attribute however to not be
&gt; reflecting this.
&gt; &quot;5.        If intersection ranges does not contain the exact same range
&gt; information as the current value of this attribute, then update the current
&gt; value of this attribute to intersection ranges.
&gt; 6.        Return the current value of this attribute.
&gt; &quot;
&gt; 
&gt; I read this as always returning the same TimeRange object, and updating the
&gt; object. Making it effectively a &quot;live&quot; object as described in comment 10.

That was not the intent. Please suggest some alternate text that would make step 5 clearer to you.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123689</commentid>
    <comment_count>16</comment_count>
    <who name="Matt Wolenetz">wolenetz</who>
    <bug_when>2015-10-13 22:54:54 +0000</bug_when>
    <thetext>This bug has been migrated to the GitHub issue tracker. Please follow/update progress using the GitHub issue:
https://github.com/w3c/media-source/issues/16

In particular, Jean-Yves Avenard, do you have a suggestion for improved text? (Please respond on the GitHub issue.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>