Backed out changeset ecb87e0e1cab ("Bug 1269178: P1. Retry InternalSeek if previous attempt failed once more data is available. r=gerald")
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 04 May 2016 15:24:32 +1000
changeset 296334 2d8cf9ffd16e2f923679f64c918fe9b147e81961
parent 296333 97acde75c885d8a2c242df03f8582ee68270cf07
child 296335 df20f438502df1a33c71aea95d3ded5b84a2d2a7
push id76303
push userjyavenard@mozilla.com
push dateFri, 06 May 2016 07:32:02 +0000
treeherdermozilla-inbound@7d9879db28af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1269178
milestone49.0a1
backs outecb87e0e1cab69d1861e6178f0794d0a44c70918
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
Backed out changeset ecb87e0e1cab ("Bug 1269178: P1. Retry InternalSeek if previous attempt failed once more data is available. r=gerald")
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -742,17 +742,16 @@ MediaFormatReader::NeedInput(DecoderData
   // decoded sample. To account for H.264 streams which may require a longer
   // run of input than we input, decoders fire an "input exhausted" callback,
   // which overrides our "few more samples" threshold.
   return
     !aDecoder.mDraining &&
     !aDecoder.mError &&
     aDecoder.mDecodingRequested &&
     !aDecoder.mDemuxRequest.Exists() &&
-    !aDecoder.mSeekRequest.Exists() &&
     aDecoder.mOutput.Length() <= aDecoder.mDecodeAhead &&
     (aDecoder.mInputExhausted || !aDecoder.mQueuedSamples.IsEmpty() ||
      aDecoder.mTimeThreshold.isSome() ||
      aDecoder.mNumSamplesInput - aDecoder.mNumSamplesOutput <= aDecoder.mDecodeAhead);
 }
 
 void
 MediaFormatReader::ScheduleUpdate(TrackType aTrack)
@@ -780,32 +779,18 @@ MediaFormatReader::UpdateReceivedNewData
 
   if (!decoder.mReceivedNewData) {
     return false;
   }
 
   // Update our cached TimeRange.
   decoder.mTimeRanges = decoder.mTrackDemuxer->GetBuffered();
 
-  // We do not want to clear mWaitingForData while there are pending
-  // demuxing or seeking operations that could affect the value of this flag.
-  // This is in order to ensure that we will retry once they complete as we may
-  // now have new data that could potentially allow those operations to
-  // successfully complete if tried again.
-  if (decoder.mSeekRequest.Exists()) {
-    // Nothing more to do until this operation complete.
-    return true;
-  }
-  if (decoder.mDemuxRequest.Exists()) {
-    // We may have pending operations to process, so we want to continue
-    // after UpdateReceivedNewData returns.
-    return false;
-  }
-
-  if (decoder.mDrainComplete || decoder.mDraining) {
+  if (decoder.mDrainComplete || decoder.mDraining ||
+      decoder.mDemuxRequest.Exists()) {
     // We do not want to clear mWaitingForData or mDemuxEOS while
     // a drain is in progress in order to properly complete the operation.
     return false;
   }
 
   bool hasLastEnd;
   media::TimeUnit lastEnd = decoder.mTimeRanges.GetEnd(&hasLastEnd);
   if (hasLastEnd) {
@@ -820,29 +805,20 @@ MediaFormatReader::UpdateReceivedNewData
   if (decoder.mTimeThreshold) {
     decoder.mTimeThreshold.ref().mWaiting = false;
   }
   decoder.mWaitingForData = false;
 
   if (decoder.mError) {
     return false;
   }
-
-  bool hasPendingSeek =
-    decoder.mTimeThreshold && !decoder.mTimeThreshold.ref().mHasSeeked;
-  if (hasPendingSeek || decoder.HasWaitingPromise()) {
-    if (hasPendingSeek) {
-      LOG("Attempting Internal Seek");
-      InternalSeek(aTrack, decoder.mTimeThreshold.ref());
-    }
-    if (decoder.HasWaitingPromise()) {
-      MOZ_ASSERT(!decoder.HasPromise());
-      LOG("We have new data. Resolving WaitingPromise");
-      decoder.mWaitingPromise.Resolve(decoder.mType, __func__);
-    }
+  if (decoder.HasWaitingPromise()) {
+    MOZ_ASSERT(!decoder.HasPromise());
+    LOG("We have new data. Resolving WaitingPromise");
+    decoder.mWaitingPromise.Resolve(decoder.mType, __func__);
     return true;
   }
   if (!mSeekPromise.IsEmpty()) {
     MOZ_ASSERT(!decoder.HasPromise());
     if (mVideo.mSeekRequest.Exists() || mAudio.mSeekRequest.Exists()) {
       // Already waiting for a seek to complete. Nothing more to do.
       return true;
     }
@@ -1002,40 +978,36 @@ MediaFormatReader::InternalSeek(TrackTyp
   decoder.mTimeThreshold = Some(aTarget);
   RefPtr<MediaFormatReader> self = this;
   decoder.ResetDemuxer();
   decoder.mSeekRequest.Begin(decoder.mTrackDemuxer->Seek(decoder.mTimeThreshold.ref().mTime)
              ->Then(OwnerThread(), __func__,
                     [self, aTrack] (media::TimeUnit aTime) {
                       auto& decoder = self->GetDecoderData(aTrack);
                       decoder.mSeekRequest.Complete();
-                      MOZ_ASSERT(decoder.mTimeThreshold);
-                      decoder.mTimeThreshold.ref().mHasSeeked = true;
                       self->NotifyDecodingRequested(aTrack);
                     },
                     [self, aTrack] (DemuxerFailureReason aResult) {
                       auto& decoder = self->GetDecoderData(aTrack);
                       decoder.mSeekRequest.Complete();
                       switch (aResult) {
                         case DemuxerFailureReason::WAITING_FOR_DATA:
                           self->NotifyWaitingForData(aTrack);
                           break;
                         case DemuxerFailureReason::END_OF_STREAM:
-                          decoder.mTimeThreshold.reset();
                           self->NotifyEndOfStream(aTrack);
                           break;
                         case DemuxerFailureReason::CANCELED:
                         case DemuxerFailureReason::SHUTDOWN:
-                          decoder.mTimeThreshold.reset();
                           break;
                         default:
-                          decoder.mTimeThreshold.reset();
                           self->NotifyError(aTrack);
                           break;
                       }
+                      decoder.mTimeThreshold.reset();
                     }));
 }
 
 void
 MediaFormatReader::DrainDecoder(TrackType aTrack)
 {
   MOZ_ASSERT(OnTaskQueue());
 
@@ -1148,18 +1120,17 @@ MediaFormatReader::Update(TrackType aTra
         if (!decoder.mReceivedNewData) {
           LOG("Rejecting %s promise: WAITING_FOR_DATA", TrackTypeToStr(aTrack));
           decoder.RejectPromise(WAITING_FOR_DATA, __func__);
         }
       }
       // Now that draining has completed, we check if we have received
       // new data again as the result may now be different from the earlier
       // run.
-      if (UpdateReceivedNewData(aTrack) ||
-          (decoder.mTimeThreshold && decoder.mSeekRequest.Exists())) {
+      if (UpdateReceivedNewData(aTrack)) {
         LOGV("Nothing more to do");
         return;
       }
     }
   }
 
   if (decoder.mNeedDraining) {
     DrainDecoder(aTrack);
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -132,25 +132,22 @@ private:
   bool DecodeDemuxedSamples(TrackType aTrack,
                             MediaRawData* aSample);
 
   struct InternalSeekTarget {
     InternalSeekTarget(const media::TimeUnit& aTime, bool aDropTarget)
       : mTime(aTime)
       , mDropTarget(aDropTarget)
       , mWaiting(false)
-      , mHasSeeked(false)
     {}
 
     media::TimeUnit mTime;
     bool mDropTarget;
     bool mWaiting;
-    bool mHasSeeked;
   };
-
   // Perform an internal seek to aTime. If aDropTarget is true then
   // the first sample past the target will be dropped.
   void InternalSeek(TrackType aTrack, const InternalSeekTarget& aTarget);
 
   // Drain the current decoder.
   void DrainDecoder(TrackType aTrack);
   void NotifyNewOutput(TrackType aTrack, MediaData* aSample);
   void NotifyInputExhausted(TrackType aTrack);