Bug 1299018 - Report late frames as dropped instead of presented.
MozReview-Commit-ID: FYHMGqUHjoL
--- 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) {