--- a/layout/generic/nsGfxScrollFrame.cpp+++ b/layout/generic/nsGfxScrollFrame.cpp@@ -2936,16 +2936,28 @@ ScrollFrameHelper::ScrollToImpl(nsPoint !isScrollOriginDowngrade; if (allowScrollOriginChange) { mLastScrollOrigin = aOrigin; mAllowScrollOriginDowngrade = false; } mLastSmoothScrollOrigin = nullptr; mScrollGeneration = ++sScrollGenerationCounter;+ // If the new scroll offset is going to clobber APZ's scroll offset, for+ // the RCD-RSF this will have the effect of resetting the visual viewport+ // offset to be the same as the new scroll (= layout viewport) offset.+ // The APZ callback transform, which reflects the difference between these+ // offsets, will subsequently be cleared. However, it we wait for APZ to+ // clear it, the main thread could end up using the old value and get+ // incorrect results, so just clear it now.+ if (mIsRoot && nsLayoutUtils::CanScrollOriginClobberApz(mLastScrollOrigin)) {+ content->SetProperty(nsGkAtoms::apzCallbackTransform, new CSSPoint(),+ nsINode::DeleteProperty<CSSPoint>);+ }+ ScrollVisual(); bool schedulePaint = true; if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && !nsLayoutUtils::ShouldDisableApzForElement(content) && gfxPrefs::APZPaintSkipping()) { // If APZ is enabled with paint-skipping, there are certain conditions in // which we can skip paints: