diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index fae00c6d30c8..c55ba854f935 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -8708,6 +8708,13 @@ static void MaybeReflowForInflationScreenSizeChange( metrics.SetBaseScrollOffset(apzScrollPosition); if (aIsRootContent) { + if (aLayerManager->GetIsFirstPaint()) { + // Restore the visual viewport offset to the copy stored on the + // main thread. + presShell->SetPendingVisualViewportOffset( + Some(presShell->GetVisualViewportOffset())); + } + if (const Maybe& visualOffset = presShell->GetPendingVisualViewportOffset()) { metrics.SetVisualViewportOffset(CSSPoint::FromAppUnits(*visualOffset));