diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 97d12679b0a..51ae4c49be8 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -3149,6 +3149,7 @@ AsyncPanZoomController::ReportCheckerboard(const TimeStamp& aSampleTime) if (!mCheckerboardEvent && (recordTrace || forTelemetry)) { mCheckerboardEvent = MakeUnique(recordTrace); } + mPotentialCheckerboardTracker.InTransform(IsTransformingState(mState)); if (magnitude) { mPotentialCheckerboardTracker.CheckerboardSeen(); } @@ -3634,7 +3635,6 @@ void AsyncPanZoomController::DispatchStateChangeNotification(PanZoomState aOldSt if (RefPtr controller = GetGeckoContentController()) { if (!IsTransformingState(aOldState) && IsTransformingState(aNewState)) { - mPotentialCheckerboardTracker.TransformStarted(); controller->NotifyAPZStateChange( GetGuid(), APZStateChange::TransformBegin); #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) @@ -3645,7 +3645,6 @@ void AsyncPanZoomController::DispatchStateChangeNotification(PanZoomState aOldSt } #endif } else if (IsTransformingState(aOldState) && !IsTransformingState(aNewState)) { - mPotentialCheckerboardTracker.TransformStopped(); controller->NotifyAPZStateChange( GetGuid(), APZStateChange::TransformEnd); #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) diff --git a/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.cpp b/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.cpp index 0f9a1d32d86..c83b9f45c24 100644 --- a/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.cpp +++ b/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.cpp @@ -40,21 +40,29 @@ PotentialCheckerboardDurationTracker::CheckerboardDone() } void -PotentialCheckerboardDurationTracker::TransformStarted() +PotentialCheckerboardDurationTracker::InTransform(bool aInTransform) { - MOZ_ASSERT(!mInTransform); - if (!Tracking()) { - mCurrentPeriodStart = TimeStamp::Now(); + if (aInTransform == mInTransform) { + // no-op + return; } - mInTransform = true; -} -void -PotentialCheckerboardDurationTracker::TransformStopped() -{ - MOZ_ASSERT(mInTransform); - mInTransform = false; if (!Tracking()) { + // Because !Tracking(), mInTransform must be false, and so aInTransform + // must be true (or we would have early-exited this function already). + // Therefore, we are starting a potential checkerboard period. + mInTransform = aInTransform; + mCurrentPeriodStart = TimeStamp::Now(); + return; + } + + mInTransform = aInTransform; + + if (!Tracking()) { + // Tracking() must have been true at the start of this function, or we + // would have taken the other !Tracking branch above. If it's false now, + // it means we just stopped tracking, so we are ending a potential + // checkerboard period. mozilla::Telemetry::AccumulateTimeDelta( mozilla::Telemetry::CHECKERBOARD_POTENTIAL_DURATION, mCurrentPeriodStart); diff --git a/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.h b/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.h index b6bd3ea882b..6154003ad63 100644 --- a/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.h +++ b/gfx/layers/apz/src/PotentialCheckerboardDurationTracker.h @@ -39,15 +39,10 @@ public: void CheckerboardDone(); /** - * This should be called when a transform is started. Calls to this must be - * interleaved with calls to TransformStopped(). + * This should be called at composition time, to indicate if the APZC is in + * a transforming state or not. */ - void TransformStarted(); - /** - * This should be called when a transform is stopped. Calls to this must be - * interleaved with calls to TransformStarted(). - */ - void TransformStopped(); + void InTransform(bool aInTransform); private: bool Tracking() const;