Restrict window resize helper to active live resizes
Moderate
Commit Hash:
eed227a26be88594ce0abe84139e4ae3a5ce6903
Commit Time: 2026-03-24 13:54:31
Impact Level: Moderate
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This commit fixes WindowResizeHelperMac::WaitForSingleTaskToRun() being incorrectly invoked outside of live resize scenarios (especially during startup). Key changes include:
1. Added pure virtual method IsWindowInLiveResize() to the CATransactionCoordinator::PreCommitObserver interface, for querying whether the observed window is in an active live resize.
2. NativeWidgetNSWindowBridge implements IsWindowInLiveResize(), returning [window_ inLiveResize].
3. In CATransactionCoordinator::PreCommitHandler()'s wait loop, added a check: if no observed window is in live resize, the wait time is reduced to near-zero (1 nanosecond), only processing already-queued tasks without waiting for new ones. This behavior is gated by Feature Flag kOnlyUseWindowResizeHelperOnResize.
4. Added Feature Flag kOnlyUseWindowResizeHelperOnResize, disabled by default, as a gradual rollout control switch.
1. Added pure virtual method IsWindowInLiveResize() to the CATransactionCoordinator::PreCommitObserver interface, for querying whether the observed window is in an active live resize.
2. NativeWidgetNSWindowBridge implements IsWindowInLiveResize(), returning [window_ inLiveResize].
3. In CATransactionCoordinator::PreCommitHandler()'s wait loop, added a check: if no observed window is in live resize, the wait time is reduced to near-zero (1 nanosecond), only processing already-queued tasks without waiting for new ones. This behavior is gated by Feature Flag kOnlyUseWindowResizeHelperOnResize.
4. Added Feature Flag kOnlyUseWindowResizeHelperOnResize, disabled by default, as a gradual rollout control switch.
🎯 Impact Analysis
This change has a moderate impact on WebView2Mac that warrants attention. Key analysis:
1. **New pure virtual method on PreCommitObserver interface**: CATransactionCoordinator::PreCommitObserver gains a new pure virtual method IsWindowInLiveResize(). NativeWidgetNSWindowBridge implements this interface and runs in the app shim process. WebView2Mac uses NativeWidgetNSWindowBridge for CATransaction commit synchronization of its child windows. Upon integration, Edge's NativeWidgetNSWindowBridge must implement this new method or compilation will fail.
2. **Affects CATransaction commit timing**: The wait logic change in CATransactionCoordinator::PreCommitHandler() directly affects UI render frame commit timing. When the Feature Flag is enabled, WaitForSingleTaskToRun wait time outside live resize scenarios is reduced from potentially hundreds of milliseconds to near-zero. This positively impacts WebView2Mac's rendering pipeline by avoiding unnecessary frame commit delays during startup.
3. **WebView2Mac embedded WebView scenario**: WebView2Mac's embedded WebView windows typically don't undergo live resize (controlled by the host app), but NativeWidgetNSWindowBridge still participates in CATransaction coordination as a PreCommitObserver. After this fix, when WebView2Mac windows are not in live resize, PreCommitHandler won't block CA commits waiting for render tasks, improving frame commit latency during startup and normal operation.
4. **Feature Flag disabled by default**: kOnlyUseWindowResizeHelperOnResize is disabled by default, so behavior remains unchanged immediately after integration. When upstream gradually enables this Feature, WebView2Mac will automatically benefit.
5. **ui_base_features.h/cc changes**: The new Feature Flag declaration and definition are in the ui/base layer as a general Mac platform feature and won't conflict with Edge's own Feature Flags.
1. **New pure virtual method on PreCommitObserver interface**: CATransactionCoordinator::PreCommitObserver gains a new pure virtual method IsWindowInLiveResize(). NativeWidgetNSWindowBridge implements this interface and runs in the app shim process. WebView2Mac uses NativeWidgetNSWindowBridge for CATransaction commit synchronization of its child windows. Upon integration, Edge's NativeWidgetNSWindowBridge must implement this new method or compilation will fail.
2. **Affects CATransaction commit timing**: The wait logic change in CATransactionCoordinator::PreCommitHandler() directly affects UI render frame commit timing. When the Feature Flag is enabled, WaitForSingleTaskToRun wait time outside live resize scenarios is reduced from potentially hundreds of milliseconds to near-zero. This positively impacts WebView2Mac's rendering pipeline by avoiding unnecessary frame commit delays during startup.
3. **WebView2Mac embedded WebView scenario**: WebView2Mac's embedded WebView windows typically don't undergo live resize (controlled by the host app), but NativeWidgetNSWindowBridge still participates in CATransaction coordination as a PreCommitObserver. After this fix, when WebView2Mac windows are not in live resize, PreCommitHandler won't block CA commits waiting for render tasks, improving frame commit latency during startup and normal operation.
4. **Feature Flag disabled by default**: kOnlyUseWindowResizeHelperOnResize is disabled by default, so behavior remains unchanged immediately after integration. When upstream gradually enables this Feature, WebView2Mac will automatically benefit.
5. **ui_base_features.h/cc changes**: The new Feature Flag declaration and definition are in the ui/base layer as a general Mac platform feature and won't conflict with Edge's own Feature Flags.
Impacted Classes:
ui::CATransactionCoordinator::PreCommitObserver
remote_cocoa::NativeWidgetNSWindowBridge
ui::CATransactionCoordinator