Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 40f08476d98a53903891d3b7dc91509cfc071cea
https://github.com/WebKit/WebKit/commit/40f08476d98a53903891d3b7dc91509cfc071cea
Author: Phipson Lee <[email protected]>
Date: 2026-06-15 (Mon, 15 Jun 2026)
Changed paths:
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
Log Message:
-----------
Relayout during live resize on visionOS can cause webpage UI to shift and
misposition
https://bugs.webkit.org/show_bug.cgi?id=316388
rdar://175530464
Reviewed by Abrar Rahman Protyasha and Simon Fraser.
This PR updates the existing live resize mechanisms for visionOS when the user
is
resizing the window. Previously, in 312437@main, we introduced a more responsive
update heuristic such that the WKWebView will relayout its content more
frequently
during live resize. This however would cause synchronization issues where the
webview
would try to commit updates into its layer tree while simultaneously supplying
new
liveResizeParameters to the web process. It also introduced issues where the
snapshot,
which was intended to cover the web content during the relayout, would snapshot
the
content while updates were committing, making the resize transition buggy.
This patch addresses these issues by introducing the following changes:
1. The perProcessState now maintains a transactionIDForEndLiveResize which
corresponds to
the last transactionID sent to the Web Process to dispatch the resize update.
We pause
subsequent dispatches until the Web Process commits the changes to the layer
tree with the
same or greater transactionID.
2. We introduce a LiveResizeSnapshotState that maintains the snapshot instance
and the width
it was captured. We store that as a tuple keyed by the transactionID. When a
relayout is dispatched,
we store the transactionID and the snapshotView in the state variable, until
the layer tree has
committed all its changes and the next resizeAnimationView has been created.
This ensures we only
maintain one snapshot and that the snapshot does not get removed before the
relayout has completed.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
Introduce the following new variables:
- transactionIDForEndLiveResize — set when the UI Process ends a resize cycle
and dispatch new
layout to web process. Marks which commit the UI Process is waiting for.
- waitingForEndLiveResizePresentationUpdate — set when the matching commit
arrives after the commit
has been presented, enabling the next live resize update.
- resizeAnimationViewIsUpdating — set when a new animation view is created
while a snapshot exists.
Indicates the animation view needs to render before the snapshot can be removed.
- _liveResizeSnapshotState — holds the snapshot view and its initial width for
scaling.
Optional pair of {TransactionID, {snapshotView, initialWidth}}.
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _processWillSwapOrDidExit]):
(-[WKWebView _didCommitLayerTree:mainFrameData:pageData:transactionID:]):
Checks whether the transactionID is same or greater than the stored
transactionIDForEndLiveResize. If true,
we will reset waitingForEndLiveResizePresentationUpdate after the next
presentation update so that live resize
can dispatch again.
(-[WKWebView _beginAutomaticLiveResizeIfNeeded]):
Guard live resize updates based on transactionID and whether we are waiting for
a presentation update or not.
(-[WKWebView _rescheduleEndLiveResizeTimer]):
(-[WKWebView _updateLiveResizeTransform]):
(-[WKWebView _updateLiveSnapshotTransform]):
(-[WKWebView _removeLiveSnapshotState]):
(-[WKWebView _frameOrBoundsMayHaveChanged]):
(-[WKWebView _ensureResizeAnimationView]):
Update when we add and remove the live snapshot view such that it is captured
before the resize dispatch and removed
only after the resizeAnimationView for the next resize update has been set.
(-[WKWebView _endLiveResize]):
Create the new snapshot view and update the new state variables. We also remove
the early removal of the snapshot
and defer that until the updated layer tree corresponding to
transactionIDForEndLiveResize has been returned.
Canonical link: https://commits.webkit.org/315206@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications