Bug 1302379 - Remove FinishedOnInactive hack from DOMMediaStream. r=jib
☠☠ backed out by 7272d77d4e80 ☠ ☠
authorAndreas Pehrson <apehrson@mozilla.com>
Wed, 13 Nov 2019 08:58:32 +0000
changeset 501796 306341d0b5869bafb98f11492f64f3aa0e4e51a7
parent 501795 3ff0d72d23a267ace6188dcb339b06e7d09d51f2
child 501797 355f090421a6b38618b3f2e2e0c08d9166a78e72
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1302379
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1302379 - Remove FinishedOnInactive hack from DOMMediaStream. r=jib It is no longer needed with captured tracks' lifetimes spanning across seek operations. Differential Revision: https://phabricator.services.mozilla.com/D52051
dom/html/HTMLMediaElement.cpp
dom/media/DOMMediaStream.cpp
dom/media/DOMMediaStream.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1704,19 +1704,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourcePointer)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLoadBlockedDoc)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSourceLoadCandidate)
   if (tmp->mAudioChannelWrapper) {
     tmp->mAudioChannelWrapper->Shutdown();
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioChannelWrapper)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mErrorSink->mError)
-  for (OutputMediaStream& s : tmp->mOutputStreams) {
-    s.mStream->SetFinishedOnInactive(true);
-  }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOutputStreams)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOutputTrackSources)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPlayed)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mTextTrackManager)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioTrackList)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mVideoTrackList)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaKeys)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mIncomingMediaKeys)
@@ -3315,17 +3312,16 @@ void HTMLMediaElement::UpdateOutputTrack
     }
     if (!IsPlaybackEnded() &&
         mSrcAttrStream == mOutputStreams[i].mFinishWhenEndedAttrStream) {
       continue;
     }
     LOG(LogLevel::Debug,
         ("Playback ended or source changed. Discarding stream %p",
          mOutputStreams[i].mStream.get()));
-    mOutputStreams[i].mStream->SetFinishedOnInactive(true);
     mOutputStreams.RemoveElementAt(i);
     if (mOutputStreams.IsEmpty()) {
       mTracksCaptured = nullptr;
     }
   }
 
   // Finally add new MediaTracks.
   for (const auto& mediaTrack : mediaTracksToAdd) {
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -451,30 +451,16 @@ void DOMMediaStream::RegisterTrackListen
   mTrackListeners.AppendElement(aListener);
 }
 
 void DOMMediaStream::UnregisterTrackListener(TrackListener* aListener) {
   MOZ_ASSERT(NS_IsMainThread());
   mTrackListeners.RemoveElement(aListener);
 }
 
-void DOMMediaStream::SetFinishedOnInactive(bool aFinishedOnInactive) {
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (mFinishedOnInactive == aFinishedOnInactive) {
-    return;
-  }
-
-  mFinishedOnInactive = aFinishedOnInactive;
-
-  if (mFinishedOnInactive && !ContainsLiveTracks(mTracks)) {
-    NotifyTrackRemoved(nullptr);
-  }
-}
-
 void DOMMediaStream::NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack) {
   MOZ_ASSERT(NS_IsMainThread());
 
   aTrack->AddConsumer(mPlaybackTrackListener);
 
   for (int32_t i = mTrackListeners.Length() - 1; i >= 0; --i) {
     mTrackListeners[i]->NotifyTrackAdded(aTrack);
   }
@@ -513,20 +499,16 @@ void DOMMediaStream::NotifyTrackRemoved(
     }
 
     if (!mActive) {
       NS_ASSERTION(false, "Shouldn't remove a live track if already inactive");
       return;
     }
   }
 
-  if (!mFinishedOnInactive) {
-    return;
-  }
-
   if (mAudible) {
     // Check if we became inaudible.
     if (!ContainsLiveAudioTracks(mTracks)) {
       mAudible = false;
       NotifyInaudible();
     }
   }
 
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -184,20 +184,16 @@ class DOMMediaStream : public DOMEventTa
   // being destroyed, so we don't hold on to a dead pointer. Main thread only.
   void RegisterTrackListener(TrackListener* aListener);
 
   // Unregisters a track listener from this MediaStream. The caller must call
   // UnregisterTrackListener before being destroyed, so we don't hold on to
   // a dead pointer. Main thread only.
   void UnregisterTrackListener(TrackListener* aListener);
 
-  // Tells this MediaStream whether it can go inactive as soon as no tracks
-  // are live anymore.
-  void SetFinishedOnInactive(bool aFinishedOnInactive);
-
  protected:
   virtual ~DOMMediaStream();
 
   void Destroy();
 
   // Dispatches NotifyActive() to all registered track listeners.
   void NotifyActive();
 
@@ -238,19 +234,15 @@ class DOMMediaStream : public DOMEventTa
   // The track listeners subscribe to changes in this stream's track set.
   nsTArray<TrackListener*> mTrackListeners;
 
   // True if this stream has live tracks.
   bool mActive = false;
 
   // True if this stream has live audio tracks.
   bool mAudible = false;
-
-  // For compatibility with mozCaptureStream, we in some cases do not go
-  // inactive until the MediaDecoder lets us. (Remove this in Bug 1302379)
-  bool mFinishedOnInactive = true;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(DOMMediaStream, NS_DOMMEDIASTREAM_IID)
 
 }  // namespace mozilla
 
 #endif /* NSDOMMEDIASTREAM_H_ */