Bug 1424416 - MediaFormatReader does not drain decoders that do not require it. r?jya
Use the new RequiresDraining() method on MediaDataDecoder to avoid unneeded
drains on decoders in the MediaFormatReader (MFR). This should mitigate issues
with webm/mkv audio where low sites appending small amounts of data at a time
can incur a lot of MFR internal seeks and frame drops when running out of data.
MozReview-Commit-ID: 1iS60qSz7y4
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -2541,25 +2541,33 @@ void
MediaFormatReader::DrainDecoder(TrackType aTrack)
{
MOZ_ASSERT(OnTaskQueue());
auto& decoder = GetDecoderData(aTrack);
if (decoder.mDrainState == DrainState::Draining) {
return;
}
+
if (!decoder.mDecoder ||
(decoder.mDrainState != DrainState::PartialDrainPending &&
decoder.mNumSamplesInput == decoder.mNumSamplesOutput)) {
// No frames to drain.
LOGV("Draining %s with nothing to drain", TrackTypeToStr(aTrack));
decoder.mDrainState = DrainState::DrainAborted;
ScheduleUpdate(aTrack);
return;
}
+ if (!decoder.mDecoder->RequiresDrainning()) {
+ LOGV("%s's decoder (%s) indicates draining is not required, aborting drain",
+ TrackTypeToStr(aTrack), decoder.mDescription.get());
+ decoder.mDrainState = DrainState::DrainAborted;
+ ScheduleUpdate(aTrack);
+ return;
+ }
decoder.mDrainState = DrainState::Draining;
DDLOG(DDLogCategory::Log, "draining", DDNoValue{});
RefPtr<MediaFormatReader> self = this;
decoder.mDecoder->Drain()
->Then(mTaskQueue, __func__,
[self, aTrack, &decoder]