Bug 1266685 - Don't pass too many frames to the MediaPipelineTransmit VideoFrameConverter. r=jesup
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 15 Apr 2016 16:00:09 +0200
changeset 332416 b12d4b8634f3e1997dcaca3ac742c5ea3ea12df1
parent 332415 b9ac34e99e3048648c839de22de82f97eb4ce3a7
child 332417 3e12df7cefe4cf2e0b8dc11867e1008b21aa135a
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1266685
milestone48.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 1266685 - Don't pass too many frames to the MediaPipelineTransmit VideoFrameConverter. r=jesup MozReview-Commit-ID: 4XwcfBW9nkY
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -124,16 +124,27 @@ public:
     RefPtr<SharedThreadPool> pool =
       SharedThreadPool::Get(NS_LITERAL_CSTRING("VideoFrameConverter"));
 
     mTaskQueue = MakeAndAddRef<TaskQueue>(pool.forget());
   }
 
   void QueueVideoChunk(VideoChunk& aChunk, bool aForceBlack)
   {
+    if (aChunk.IsNull()) {
+      return;
+    }
+
+    // We get passed duplicate frames every ~10ms even with no frame change.
+    int32_t serial = aChunk.mFrame.GetImage()->GetSerial();
+    if (serial == last_img_) {
+      return;
+    }
+    last_img_ = serial;
+
     // A throttling limit of 1 allows us to convert 2 frames concurrently.
     // It's short enough to not build up too significant a delay, while
     // giving us a margin to not cause some machines to drop every other frame.
     const int32_t queueThrottlingLimit = 1;
     if (mLength > queueThrottlingLimit) {
       MOZ_MTLOG(ML_DEBUG, "VideoFrameConverter " << this << " queue is full." <<
                           " Throttling by throwing away a frame.");
 #ifdef DEBUG
@@ -153,20 +164,16 @@ public:
       MOZ_MTLOG(level, "VideoFrameConverter " << this << " stopped" <<
                        " throttling after throwing away " << mThrottleCount <<
                        " frames. Longest throttle so far was " <<
                        mThrottleRecord << " frames.");
       mThrottleCount = 0;
     }
 #endif
 
-    if (aChunk.IsNull()) {
-      return;
-    }
-
     bool forceBlack = aForceBlack || aChunk.mFrame.GetForceBlack();
 
     if (forceBlack) {
       // Reset the last-img check.
       // -1 is not a guaranteed invalid serial. See bug 1262134.
       last_img_ = -1;
 
       if (disabled_frame_sent_) {
@@ -175,23 +182,16 @@ public:
         // that can be avoided. We don't handle resolution changes while
         // disabled for now.
         return;
       }
 
       disabled_frame_sent_ = true;
     } else {
       disabled_frame_sent_ = false;
-
-      // We get passed duplicate frames every ~10ms even with no frame change.
-      int32_t serial = aChunk.mFrame.GetImage()->GetSerial();
-      if (serial == last_img_) {
-        return;
-      }
-      last_img_ = serial;
     }
 
     ++mLength; // Atomic
 
     nsCOMPtr<nsIRunnable> runnable =
       NS_NewRunnableMethodWithArgs<StorensRefPtrPassByPtr<Image>, bool>(
         this, &VideoFrameConverter::ProcessVideoFrame,
         aChunk.mFrame.GetImage(), forceBlack);