Bug 1424416 - MediaFormatReader does not drain decoders that do not require it. r?jya draft
authorBryce Van Dyk <bvandyk@mozilla.com>
Tue, 10 Apr 2018 12:23:28 -0400
changeset 779927 e8f5e8372b2a3caa5912685f853b7888a0f68f19
parent 779926 60a7a2a44163c8aba6ba8bcfa06d9587194517f4
push id105908
push userbvandyk@mozilla.com
push dateTue, 10 Apr 2018 20:37:51 +0000
reviewersjya
bugs1424416
milestone61.0a1
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
dom/media/MediaFormatReader.cpp
--- 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]