Bug 1208328 - Don't block ended tracks on removal from MediaStream. r=jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 31 May 2016 14:55:51 +0200
changeset 377444 af67b8f8e0dfc340d50af7bcfe8e476159cefeac
parent 377443 49b0ebaff593c28b727602d7b61bab5feea80485
child 377445 d9660c84b0009a0d572ccc6ae8084897ffc59707
push id20793
push userpehrsons@gmail.com
push dateFri, 10 Jun 2016 10:14:15 +0000
reviewersjesup
bugs1208328
milestone50.0a1
Bug 1208328 - Don't block ended tracks on removal from MediaStream. r=jesup After ending the MediaInputPort (to the playback stream) gets removed if locked to the track specifically. Trying to remove the track at this point would try to block it in the same MediaInputPort - but since it doesn't exist would trigger an NS_ERROR instead. MozReview-Commit-ID: IpRL6FAGxPp
dom/media/DOMMediaStream.cpp
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -595,17 +595,21 @@ DOMMediaStream::RemoveTrack(MediaStreamT
     LOG(LogLevel::Debug, ("DOMMediaStream %p does not contain track %p", this, &aTrack));
     return;
   }
 
   // If the track comes from a TRACK_ANY input port (i.e., mOwnedPort), we need
   // to block it in the port. Doing this for a locked track is still OK as it
   // will first block the track, then destroy the port. Both cause the track to
   // end.
-  BlockPlaybackTrack(toRemove);
+  // If the track has already ended, it's input port might be gone, so in those
+  // cases blocking the underlying track should be avoided.
+  if (!aTrack.Ended()) {
+    BlockPlaybackTrack(toRemove);
+  }
 
   DebugOnly<bool> removed = mTracks.RemoveElement(toRemove);
   MOZ_ASSERT(removed);
 
   NotifyTrackRemoved(&aTrack);
 
   LOG(LogLevel::Debug, ("DOMMediaStream %p Removed track %p", this, &aTrack));
 }