<?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>26939</bug_id>
          
          <creation_ts>2014-09-30 09:20:53 +0000</creation_ts>
          <short_desc>Information returned on MediaStreamTrack ended event</short_desc>
          <delta_ts>2014-11-11 14:47:17 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebRTC Working Group</product>
          <component>Media Capture and Streams</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Harald Alvestrand">harald</reporter>
          <assigned_to name="Dominique Hazael-Massieux">dom</assigned_to>
          <cc>annevk</cc>
    
    <cc>d</cc>
    
    <cc>jib</cc>
    
    <cc>public-media-capture</cc>
    
    <cc>stefan.lk.hakansson</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112450</commentid>
    <comment_count>0</comment_count>
    <who name="Harald Alvestrand">harald</who>
    <bug_when>2014-09-30 09:20:53 +0000</bug_when>
    <thetext>From mailing list on Aug 29:

How do I get information about what happened to a MediaStreamTrack when it&apos;s ended?

What we currently have is an event handler of type &quot;ended&quot;, which uses the Event interface, which, as defined in http://www.w3.org/TR/dom/#events has the interface:

&lt;&lt;copy deleted&gt;&gt;

The &quot;type&quot; field is set to &quot;ended&quot; if I understand the spec correctly.

We COULD get information back in a way that&apos;s consistent with other interfaces if we did two changes:

- Declare the type of interface for &quot;ended&quot; to be MediaStreamErrorEvent
- Declare the &quot;error&quot; attribute of the MediaStreamErrorEvent to be nullable (for the case where there is no error)

We could also make a new event type with a different interface than MediaStreamErrorEvent, or do something entirely different - but not offering any way to differentiate between &quot;the track ended because the user called stop() on it&quot; and &quot;the track ended because the driver crashed and there&apos;s memory corruption in the buffers&quot; seems like a non-optimal situation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112469</commentid>
    <comment_count>1</comment_count>
    <who name="Jan-Ivar Bruaroey [:jib]">jib</who>
    <bug_when>2014-09-30 15:23:02 +0000</bug_when>
    <thetext>Firstly, people should not operate WebRTC while driving.

I don&apos;t have a strong preference, but if we&apos;re going to use events to report success/failure, then overloading MediaStreamErrorEvent to make it fireable without an error seems useful. It also shouldn&apos;t be a problem in practice (it&apos;s not like listeners to the related &apos;onoverconstrained&apos; are going to need to check for null all of a sudden).

I hate to say it, but the &apos;ended&apos; attribute would actually have made for a great promise! E.g.

  pc.ended.then(() =&gt; log(&quot;Ended!&quot;)), err =&gt; log(&quot;Dropped! &quot; + err));</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112474</commentid>
    <comment_count>2</comment_count>
    <who name="Jan-Ivar Bruaroey [:jib]">jib</who>
    <bug_when>2014-09-30 16:06:40 +0000</bug_when>
    <thetext>uh, if a track was named &apos;pc&apos;. Trying again:

  track.ended.then(() =&gt; log(&quot;Ended!&quot;)), err =&gt; log(&quot;Terminated! &quot; + err));</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114247</commentid>
    <comment_count>3</comment_count>
    <who name="Stefan Hakansson LK">stefan.lk.hakansson</who>
    <bug_when>2014-10-30 16:53:44 +0000</bug_when>
    <thetext>Discussed at the f2f Oct 30 2014. J-I presented a proposal to use an ended Promise, but the consensus ended up with stick with only the ended event, but add error info to the event.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114251</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-30 17:11:58 +0000</bug_when>
    <thetext>Was there any rationale presented to not go with a promise? Seems like a perfect place to use a promise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114253</commentid>
    <comment_count>5</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2014-10-30 17:23:51 +0000</bug_when>
    <thetext>The argument against promises was with consistency with other state transition events.

However, both a promise (since it&apos;s a better fit than events for this kind of thing) and an event (for consistency) seems feasible?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114493</commentid>
    <comment_count>6</comment_count>
    <who name="Dominique Hazael-Massieux">dom</who>
    <bug_when>2014-11-04 15:43:28 +0000</bug_when>
    <thetext>Proposed edit that reuses MediaStreamErrorEvent:
https://github.com/w3c/mediacapture-main/pull/50 as discussed at the F2F</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114799</commentid>
    <comment_count>7</comment_count>
    <who name="Stefan Hakansson LK">stefan.lk.hakansson</who>
    <bug_when>2014-11-11 14:47:17 +0000</bug_when>
    <thetext>The PR (#50) has been incorporated now, and as far as I can tell it fixes this bug.

Closing the bug.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>