Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e7e4231516b7817b4dc6200703d207933f828059
      
https://github.com/WebKit/WebKit/commit/e7e4231516b7817b4dc6200703d207933f828059
  Author: Phipson Lee <[email protected]>
  Date:   2026-07-02 (Thu, 02 Jul 2026)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/AnimatedResize.mm

  Log Message:
  -----------
  Snapshot for relayout during live resize sometimes stays visible for too long 
on visionOS
https://bugs.webkit.org/show_bug.cgi?id=317160
rdar://179733894

Reviewed by Abrar Rahman Protyasha.

This PR addresses an issue where at the end of the responsive live resize on 
visionOS,
the snapshot view sometimes does not get removed for ~1-2s. This happens 
because in this flow,
we rely on the 500ms endResizeTimer to fire, which triggers an updated commit 
to the web process.
However, in this state, we rely on the user triggering a bounds update to then 
trigger another
liveResize cycle, such that the snapshot gets removed when we next trigger
`ensureLiveResizeAnimationView`.

In the case where the window has settled to a set size,
because there is no new resizeAnimationView being created, we never remove the 
snapshot, so
WebKit falls back to its 1s timer. In total, this means that the user
is waiting for 1.5s-2s after the window has been resized before the snapshot 
gets removed,
accounting for the time spent committing to the layer tree via the web process.

The fix here is that we assume that when endLiveResize is called with the 500ms 
timer
it is safe to remove the snapshot immediately without needing to wait on the 
next resizeAnimationView
container to get created.

We make this change by storing didForceEndLiveResize (renamed to better reflect 
intent of variable)
as a property of the LiveResizeSnapshotState associated with the specific 
transactionID during
which it was created. To that end, we introduce an argument to `_endLiveResize` 
and
`_endLiveResizeWithResponsiveRelayout` that passes that value over. Together
we use that to track whether to remove the snapshot immediately.

* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
Introduce didForceEndLiveResize in the LiveResizeSnapshotState

* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _didCommitLayerTree:mainFrameData:pageData:transactionID:]):
Updates the responsive relayout presentation update to check for the 
transactionID and
whether the liveSnapshot was created from a forceEndLiveResize or not. If not, 
we remove
the snapshot.

(-[WKWebView didMoveToWindow]):
Update call to endLiveResize to now pass a boolean for didForceEndLiveResize.

(-[WKWebView _rescheduleEndLiveResizeTimer]):
Update captures for the timer to plumb the value of didForceEndLiveResize for 
endLiveResize.

(-[WKWebView _endLiveResizeWithResponsiveRelayout:]):
Updates call to now receive the didForceEndLiveResize to then pass into the 
next liveResizeSnapshotState

(-[WKWebView _endLiveResize:]):
Update the call to pass in the didForceEndLiveResize boolean to avoid transient 
states via the
perProcessState

(-[WKWebView _endLiveResizeWithResponsiveRelayout]):
Update calls to pass didEndLiveResizeImmediately to the snapshot state. Read by 
didCommitLayerTree
to skip waiting until the next resizeAnimationView gets created.
(-[WKWebView _endLiveResize]): Deleted.

* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/AnimatedResize.mm:
(TEST(AnimatedResize, 
MinimumEffectiveDeviceWidthChangeIsDeferredDuringLiveResize)):
(TEST(AnimatedResize, PinScrollPositionRelativeToTopEdgeOnPageScaleChange)):
(TEST(AnimatedResize, 
PinScrollPositionRelativeToTopEdgeOnPageScaleChangeAfterIncreasedSize)):
(TEST(AnimatedResize, ChangingWebViewGeometryDuringLiveResizeDoesNotHang)):
Updated unit tests to account for the new call for _endLiveResize

Canonical link: https://commits.webkit.org/316439@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to