Bug 1299018 - Report late frames as dropped instead of presented. r=kikuo, a=gchang
authorJW Wang <jwwang@mozilla.com>
Tue, 30 Aug 2016 11:39:27 +0800
changeset 342547 d66985bce16c91704e3b98ca8b4a67c298c78909
parent 342546 faf186e4d05c753650d70c4452397fd2bdad1936
child 342548 65ca5fd58d1eaedd2ce114aa62cccee16e247a03
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskikuo, gchang
bugs1299018
milestone49.0
Bug 1299018 - Report late frames as dropped instead of presented. r=kikuo, a=gchang MozReview-Commit-ID: FYHMGqUHjoL
dom/media/MediaData.h
dom/media/mediasink/VideoSink.cpp
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -540,16 +540,20 @@ public:
 
   // This frame's image.
   RefPtr<Image> mImage;
 
   int32_t mFrameID;
 
   bool mSentToCompositor;
 
+  // True if this video frame is reported as dropped
+  // for missing the compositor deadline.
+  bool mIsDropped = false;
+
   VideoData(int64_t aOffset,
             int64_t aTime,
             int64_t aDuration,
             bool aKeyframe,
             int64_t aTimecode,
             IntSize aDisplay,
             uint32_t aFrameID);
 
--- a/dom/media/mediasink/VideoSink.cpp
+++ b/dom/media/mediasink/VideoSink.cpp
@@ -337,16 +337,20 @@ VideoSink::RenderVideoFrames(int32_t aMa
 
   AutoTArray<ImageContainer::NonOwningImage,16> images;
   TimeStamp lastFrameTime;
   MediaSink::PlaybackParams params = mAudioSink->GetPlaybackParams();
   for (uint32_t i = 0; i < frames.Length(); ++i) {
     VideoData* frame = frames[i]->As<VideoData>();
 
     frame->mSentToCompositor = true;
+    // This frame is behind the current time. Let's report it as dropped.
+    if (aClockTime >= frame->GetEndTime()) {
+      frame->mIsDropped = true;
+    }
 
     if (!frame->mImage || !frame->mImage->IsValid()) {
       continue;
     }
 
     int64_t frameTime = frame->mTime;
     if (frameTime < 0) {
       // Frame times before the start time are invalid; drop such frames
@@ -400,17 +404,18 @@ VideoSink::UpdateRenderedVideoFrames()
     int32_t framesRemoved = 0;
     while (VideoQueue().GetSize() > 0) {
       RefPtr<MediaData> nextFrame = VideoQueue().PeekFront();
       if (nextFrame->mTime > clockTime) {
         remainingTime = nextFrame->mTime - clockTime;
         break;
       }
       ++framesRemoved;
-      if (!currentFrame->As<VideoData>()->mSentToCompositor) {
+      if (!currentFrame->As<VideoData>()->mSentToCompositor ||
+          currentFrame->As<VideoData>()->mIsDropped) {
         mFrameStats.NotifyDecodedFrames(0, 0, 1);
         VSINK_LOG_V("discarding video frame mTime=%lld clock_time=%lld",
                     currentFrame->mTime, clockTime);
       }
       currentFrame = VideoQueue().PopFront();
     }
     VideoQueue().PushFront(currentFrame);
     if (framesRemoved > 0) {