Had some time to try your suggestion today and wrote this very simple patch:
```diff
diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -748,6 +748,7 @@ AsyncPanZoomController::AsyncPanZoomCont
mPinchPaintTimerSet(false),
mTestAttributeAppliers(0),
mTestHasAsyncKeyScrolled(false),
+ mCurrentIsRootContent(false),
mCheckerboardEventLock("APZCBELock") {
if (aGestures == USE_GESTURE_DETECTOR) {
mGestureEventListener = new GestureEventListener(this);
@@ -5159,7 +5160,12 @@ void AsyncPanZoomController::NotifyLayer
bool viewportSizeUpdated = false;
bool needToReclampScroll = false;
- if ((aIsFirstPaint && aThisLayerTreeUpdated) || isDefault) {
+ bool isRootContent = Metrics().IsRootContent();
+ bool hasIsRootContentChanged = isRootContent != mCurrentIsRootContent;
+ mCurrentIsRootContent = isRootContent;
+
+ if ((aIsFirstPaint && aThisLayerTreeUpdated) || isDefault ||
+ hasIsRootContentChanged) {
// Initialize our internal state to something sane when the content
// that was just painted is something we knew nothing about previously
CancelAnimation();
diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -1771,6 +1771,8 @@ class AsyncPanZoomController {
uint8_t mTestAttributeAppliers;
// Flag to track whether or not this APZC has ever async key scrolled.
bool mTestHasAsyncKeyScrolled;
+ // Cache the last value of IsRootContent() seen by NotifyLayersUpdate().
+ bool mCurrentIsRootContent;
/* ===================================================================
* The functions and members in this section are used for checkerboard
```
Unfortunately, this trips another assert with the test HTML file provided:
```
Assertion failure: apzc->IsRootContent(), at /mnt/usb/work/debug/mozilla-unified/gfx/layers/apz/src/APZCTreeManager.cpp:758
```
Which is this code:
```c++
756 if (Maybe<uint64_t> zoomAnimationId = apzc->GetZoomAnimationId()) {
757 // for now we only support zooming on root content APZCs
758 MOZ_ASSERT(apzc->IsRootContent());
759
760 LayoutDeviceToParentLayerScale zoom = apzc->GetCurrentPinchZoomScale(
761 AsyncPanZoomController::eForCompositing);
```
So either I've misunderstood your suggestion, or we appear to need a different strategy.
```
Bug 1681955 Comment 7 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Had some time to try your suggestion today and wrote this very simple patch:
```diff
diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -748,6 +748,7 @@ AsyncPanZoomController::AsyncPanZoomCont
mPinchPaintTimerSet(false),
mTestAttributeAppliers(0),
mTestHasAsyncKeyScrolled(false),
+ mCurrentIsRootContent(false),
mCheckerboardEventLock("APZCBELock") {
if (aGestures == USE_GESTURE_DETECTOR) {
mGestureEventListener = new GestureEventListener(this);
@@ -5159,7 +5160,12 @@ void AsyncPanZoomController::NotifyLayer
bool viewportSizeUpdated = false;
bool needToReclampScroll = false;
- if ((aIsFirstPaint && aThisLayerTreeUpdated) || isDefault) {
+ bool isRootContent = Metrics().IsRootContent();
+ bool hasIsRootContentChanged = isRootContent != mCurrentIsRootContent;
+ mCurrentIsRootContent = isRootContent;
+
+ if ((aIsFirstPaint && aThisLayerTreeUpdated) || isDefault ||
+ hasIsRootContentChanged) {
// Initialize our internal state to something sane when the content
// that was just painted is something we knew nothing about previously
CancelAnimation();
diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -1771,6 +1771,8 @@ class AsyncPanZoomController {
uint8_t mTestAttributeAppliers;
// Flag to track whether or not this APZC has ever async key scrolled.
bool mTestHasAsyncKeyScrolled;
+ // Cache the last value of IsRootContent() seen by NotifyLayersUpdate().
+ bool mCurrentIsRootContent;
/* ===================================================================
* The functions and members in this section are used for checkerboard
```
Unfortunately, this trips another assert with the test HTML file provided:
```
Assertion failure: apzc->IsRootContent(), at /mnt/usb/work/debug/mozilla-unified/gfx/layers/apz/src/APZCTreeManager.cpp:758
```
Which is this code:
```c++
756 if (Maybe<uint64_t> zoomAnimationId = apzc->GetZoomAnimationId()) {
757 // for now we only support zooming on root content APZCs
758 MOZ_ASSERT(apzc->IsRootContent());
759
760 LayoutDeviceToParentLayerScale zoom = apzc->GetCurrentPinchZoomScale(
761 AsyncPanZoomController::eForCompositing);
```
So either I've misunderstood your suggestion, or we appear to need a different strategy.