Bug 1571821 - Use total frames instead of parsed frames to calculate benchmark. r=alwu

The problem reproduces when the system is loaded and the decoder is dropping most of the frames. When there are two benchmark calculations close to each other, the measured parsed frames of the first calculation can be buffered in the decoder and reported as dropped frames on the second calculation. Then on the second calculation, the number of dropped frames can be greater than the parsed frame which will hit the assert. The number of total frames is a better measure since it counts the frames that appeared in the in VideoSink plus the total dropped frames.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Chronopoulos 2019-09-09 20:08:59 +00:00
parent eb520e111a
commit e8c7250170
2 changed files with 9 additions and 9 deletions

View File

@ -13,27 +13,27 @@ namespace mozilla {
void DecoderBenchmark::StoreScore(const nsACString& aDecoderName,
const nsACString& aKey,
RefPtr<FrameStatistics> aStats) {
uint64_t parsedFrames = aStats->GetParsedFrames();
uint64_t totalFrames = aStats->GetTotalFrames();
uint64_t droppedFrames = aStats->GetDroppedFrames();
MOZ_ASSERT(droppedFrames <= parsedFrames);
MOZ_ASSERT(parsedFrames >= mLastParsedFrames);
MOZ_ASSERT(droppedFrames <= totalFrames);
MOZ_ASSERT(totalFrames >= mLastTotalFrames);
MOZ_ASSERT(droppedFrames >= mLastDroppedFrames);
uint64_t diffParsedFrames = parsedFrames - mLastParsedFrames;
uint64_t diffTotalFrames = totalFrames - mLastTotalFrames;
uint64_t diffDroppedFrames = droppedFrames - mLastDroppedFrames;
/* Update now in case the method returns at the if check bellow. */
mLastParsedFrames = parsedFrames;
mLastTotalFrames = totalFrames;
mLastDroppedFrames = droppedFrames;
/* A minimum number of 10 frames is required to store the score. */
if (diffParsedFrames < 10) {
if (diffTotalFrames < 10) {
return;
}
int32_t percentage =
100 - 100 * float(diffDroppedFrames) / float(diffParsedFrames);
100 - 100 * float(diffDroppedFrames) / float(diffTotalFrames);
MOZ_ASSERT(percentage >= 0);

View File

@ -53,12 +53,12 @@ class DecoderBenchmark final {
const nsACString& aKey);
~DecoderBenchmark() = default;
// Keep the last ParsedFrames and DroppedFrames from FrameStatistics.
// Keep the last TotalFrames and DroppedFrames from FrameStatistics.
// FrameStatistics keep an ever-increasing counter across the entire video and
// even when there are resolution changes. This code is called whenever there
// is a resolution change and we need to calculate the benchmark since the
// last call.
uint64_t mLastParsedFrames = 0;
uint64_t mLastTotalFrames = 0;
uint64_t mLastDroppedFrames = 0;
};