Bug 1408294 - Assert that NotifyPull produces data. r?padenot
MozReview-Commit-ID: CtC8A83iJgg
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -3728,16 +3728,20 @@ SourceListener::Remove()
}
LOG(("SourceListener %p removed on purpose, mFinished = %d", this, (int) mFinished));
mRemoved = true; // RemoveListener is async, avoid races
mWindowListener = nullptr;
// If it's destroyed, don't call - listener will be removed and we'll be notified!
if (!mStream->IsDestroyed()) {
+ // We disable pulling before removing so we don't risk having live tracks
+ // without a listener attached - that wouldn't produce data and would be
+ // illegal to the graph.
+ mStream->SetPullEnabled(false);
mStream->RemoveListener(this);
}
}
void
SourceListener::StopTrack(TrackID aTrackID)
{
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -1183,16 +1183,39 @@ MediaStreamGraphImpl::UpdateGraph(GraphT
stream,
MediaTimeToSeconds(stream->GetTracksEnd()),
MediaTimeToSeconds(endTime)));
// Data can't be added to a finished stream, so underruns are irrelevant.
stream->mStartBlocking = std::min(endTime, aEndBlockingDecisions);
}
} else {
stream->mStartBlocking = WillUnderrun(stream, aEndBlockingDecisions);
+
+ SourceMediaStream* s = stream->AsSourceStream();
+ if (s && s->mPullEnabled) {
+ for (StreamTracks::TrackIter i(s->mTracks); !i.IsEnded(); i.Next()) {
+ if (i->IsEnded()) {
+ continue;
+ }
+ if (i->GetEnd() < stream->GraphTimeToStreamTime(aEndBlockingDecisions)) {
+ LOG(LogLevel::Error,
+ ("SourceMediaStream %p track %u (%s) is live and pulled, but wasn't fed "
+ "enough data. Listeners=%zu. Track-end=%f, Iteration-end=%f",
+ stream,
+ i->GetID(),
+ (i->GetType() == MediaSegment::AUDIO ? "audio" : "video"),
+ stream->mListeners.Length(),
+ MediaTimeToSeconds(i->GetEnd()),
+ MediaTimeToSeconds(stream->GraphTimeToStreamTime(aEndBlockingDecisions))));
+ MOZ_DIAGNOSTIC_ASSERT(false,
+ "A non-finished SourceMediaStream wasn't fed "
+ "enough data by NotifyPull");
+ }
+ }
+ }
}
}
for (MediaStream* stream : mSuspendedStreams) {
stream->mStartBlocking = mStateComputedTime;
}
// The loop is woken up so soon that IterationEnd() barely advances and we