Bug 1253860 - Stop APZC from reprocessing stale metrics on unrelated layer tree updates. r?botond
MozReview-Commit-ID: 1mI8Y9W92PU
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -3249,16 +3249,26 @@ void AsyncPanZoomController::NotifyLayer
bool aIsFirstPaint,
bool aThisLayerTreeUpdated)
{
APZThreadUtils::AssertOnCompositorThread();
ReentrantMonitorAutoEnter lock(mMonitor);
bool isDefault = mFrameMetrics.IsDefault();
+ if (!aThisLayerTreeUpdated && !isDefault) {
+ // No new information here, skip it. Note that this is not just an
+ // optimization; it's correctness too. In the case where we get one of these
+ // stale aLayerMetrics *after* a call to UpdateScrollOffset, processing the
+ // stale aLayerMetrics would clobber the more up-to-date information from
+ // UpdateScrollOffset.
+ MOZ_ASSERT(aLayerMetrics == mLastContentPaintMetrics);
+ APZC_LOG("%p NotifyLayersUpdated short-circuit\n", this);
+ return;
+ }
mLastContentPaintMetrics = aLayerMetrics;
mFrameMetrics.SetScrollParentId(aLayerMetrics.GetScrollParentId());
APZC_LOG_FM(aLayerMetrics, "%p got a NotifyLayersUpdated with aIsFirstPaint=%d, aThisLayerTreeUpdated=%d",
this, aIsFirstPaint, aThisLayerTreeUpdated);
{ // scope lock
MutexAutoLock lock(mCheckerboardEventLock);