Bug 1332845 - Remove direct listeners before ending track in TrackUnionStream. r=jesup, a=gchang
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 07 Apr 2017 17:35:26 +0200
changeset 396055 74f3c44c94f2854f0aea1606ec73b8ef53b43da7
parent 396054 43dc349fa417b02371b4bd0723bb6eea9b68f6d3
child 396056 910583861999ead0e59064a2ae516f71af0200de
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, gchang
bugs1332845
milestone54.0
Bug 1332845 - Remove direct listeners before ending track in TrackUnionStream. r=jesup, a=gchang There was a race where ending the track before removing the direct listener here, allowed the source to append more data (notifying the direct listener) after the consumer had been notified of the ending track. MozReview-Commit-ID: E08UeMNQhGx
dom/media/TrackUnionStream.cpp
--- a/dom/media/TrackUnionStream.cpp
+++ b/dom/media/TrackUnionStream.cpp
@@ -52,23 +52,23 @@ TrackUnionStream::TrackUnionStream(Abstr
 }
 
   void TrackUnionStream::RemoveInput(MediaInputPort* aPort)
   {
     STREAM_LOG(LogLevel::Debug, ("TrackUnionStream %p removing input %p", this, aPort));
     for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
       if (mTrackMap[i].mInputPort == aPort) {
         STREAM_LOG(LogLevel::Debug, ("TrackUnionStream %p removing trackmap entry %d", this, i));
-        EndTrack(i);
         nsTArray<RefPtr<DirectMediaStreamTrackListener>> listeners(
           mTrackMap[i].mOwnedDirectListeners);
         for (auto listener : listeners) {
           // Remove listeners while the entry still exists.
           RemoveDirectTrackListenerImpl(listener, mTrackMap[i].mOutputTrackID);
         }
+        EndTrack(i);
         mTrackMap.RemoveElementAt(i);
       }
     }
     ProcessedMediaStream::RemoveInput(aPort);
   }
   void TrackUnionStream::ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags)
   {
     if (IsFinishedOnGraphThread()) {