Bug 1579127 - only count the frame dropping due to system overload. r=mattwoodrow

When user adjusts the video playback rate, which might cause we sending images in a speed that is faster than the speend we composite images.

In this situation, the frame dropping actually won't cause any visual defect and we also don't want to report this frame dropping to user, because it's not caused by system overloading, it's just our compositor doesn't support compositing images in such a high rate.

Therefore, we should check if the dropped images are caused by system overload or high update rate, and only report the former to user.

Differential Revision: https://phabricator.services.mozilla.com/D46236

--HG--
extra : moz-landing-system : lando
This commit is contained in:
alwu 2019-10-08 08:06:13 +00:00
parent dc1ca082ff
commit d832456285
2 changed files with 33 additions and 2 deletions

View File

@ -6,6 +6,8 @@
#include "ImageComposite.h"
#include "gfxPlatform.h"
namespace mozilla {
using namespace gfx;
@ -111,8 +113,14 @@ int ImageComposite::ChooseImageIndex() {
// We're not returning the same image as the last call to ChooseImageIndex
// or the immediately next one. We can assume that the frames not returned
// have been dropped as they were too late to be displayed
mDroppedFrames += result - mLastChosenImageIndex - 1;
PROFILER_ADD_MARKER("Video frames dropped", GRAPHICS);
for (size_t idx = mLastChosenImageIndex; idx <= result; idx++) {
if (IsImagesUpdateRateFasterThanCompositedRate(mImages[result],
mImages[idx])) {
continue;
}
mDroppedFrames++;
PROFILER_ADD_MARKER("Video frames dropped", GRAPHICS);
}
}
mLastChosenImageIndex = result;
return result;
@ -174,6 +182,10 @@ uint32_t ImageComposite::ScanForLastFrameIndex(
for (++i; i < mImages.Length() && mImages[i].mFrameID < newFrameID &&
mImages[i].mProducerID == aNewImages[j].mProducerID;
i++) {
if (IsImagesUpdateRateFasterThanCompositedRate(aNewImages[j],
mImages[i])) {
continue;
}
dropped++;
}
break;
@ -206,5 +218,17 @@ const ImageComposite::TimedImage* ImageComposite::GetImage(
return &mImages[aIndex];
}
bool ImageComposite::IsImagesUpdateRateFasterThanCompositedRate(
const TimedImage& aNewImage, const TimedImage& aOldImage) const {
MOZ_ASSERT(aNewImage.mFrameID >= aOldImage.mFrameID);
const uint32_t compositedRate = gfxPlatform::TargetFrameRate();
if (compositedRate == 0) {
return true;
}
const double compositedInterval = 1.0 / compositedRate;
return aNewImage.mTimeStamp - aOldImage.mTimeStamp <
TimeDuration::FromSeconds(compositedInterval);
}
} // namespace layers
} // namespace mozilla

View File

@ -93,6 +93,13 @@ class ImageComposite {
// Return the index of what the last returned image would have been.
uint32_t ScanForLastFrameIndex(const nsTArray<TimedImage>& aNewImages);
// Return true if we send image in a speed which is faster than the one we can
// composite image. It's used to decide whether we should report the frame
// dropping, because we only want to know the frame dropping, which is caused
// by machine overload.
bool IsImagesUpdateRateFasterThanCompositedRate(
const TimedImage& aNewImage, const TimedImage& aOldImage) const;
/**
* Bias to apply to the next frame.
*/