Bug 1299018 - Report late frames as dropped instead of presented. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 30 Aug 2016 11:39:27 +0800
changeset 407223 9ecfc56864ba88647dfade8a9774d1132a364f6e
parent 407222 68d24e6f784c7e375cf6c84c5c92496464d4f7e0
child 529813 dc1e5d39bc3d9dda5afaa101d4bcf091c90afa30
push id27897
push userjwwang@mozilla.com
push dateTue, 30 Aug 2016 03:53:50 +0000
bugs1299018
milestone49.0
Bug 1299018 - Report late frames as dropped instead of presented. 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) {