Explicit Handling of Fullscreen Mode Transition Failure
Minor
Commit Hash:
22f82a9e6b1c36d0f339c507ff33e6dd434fd139
Commit Time: 2025-10-30 17:57:59+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This submission primarily fixes the inconsistent state issue that may occur when a window fails to enter fullscreen mode on macOS. The current implementation relies on the
windowDidExitFullScreen notification to clean up the state, but in certain cases this notification may not be sent or handled correctly. This change modifies the NSWindowDelegate's windowDidFailToEnterFullScreen: method to explicitly handle these failure scenarios, ensuring that the fullscreen controller resets to the kWindowed state and notifies the client that the transition is complete. The main changes involve adding a new OnWindowDidFailToEnterFullscreen method to NativeWidgetNSWindowFullscreenController and invoking this method in the window delegate to handle failure cases.
🎯 Impact Analysis
This change has a positive impact on WebView2Mac. WebView2Mac relies on the fullscreen functionality of Remote Cocoa to manage the fullscreen state of its windows, particularly by implementing fullscreen control through HostingNSWindowBridge, which inherits from NativeWidgetNSWindowBridge. This fix addresses the following potential issues: 1) When a WebView2 window fails to enter fullscreen, it may lead to inconsistent states, affecting subsequent fullscreen operations; 2) It improves the robustness of fullscreen state management, ensuring that the client is correctly notified even in failure scenarios; 3) It resolves issues that could cause the WebView2 window to become "stuck" in a transitional state. Since HostingNSWindowBridge in WebView2Mac directly uses NativeWidgetNSWindowFullscreenController, this fix will directly enhance the reliability of the WebView2 fullscreen functionality.
Impacted Classes:
NativeWidgetNSWindowFullscreenController
ViewsNSWindowDelegate
NativeWidgetMacNSWindowHost