Close NSPopovers before entering immersive fullscreen

Commit: b68f9597 | 2025-11-10 21:13:42+00:00

← Back to List

Close NSPopovers before entering immersive fullscreen

Minor
Commit Hash: b68f95979b56637f857d6e33ae7f7627b715ce02
Commit Time: 2025-11-10 21:13:42+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit adds a utility function CloseNSPopovers() in immersive_mode_controller_cocoa.mm to close all open NSPopover windows before entering immersive fullscreen mode. This change addresses an AppKit bug that causes crashes when entering immersive fullscreen while an NSPopover is visible. The fix is only applied to macOS versions prior to 26, as macOS 26 appears to have resolved this issue. The function iterates through all child windows of the parent window, identifies windows of type _NSPopoverWindow, and closes them.

🎯 Impact Analysis

The impact of this change on WebView2Mac is **Minor**. Here's why:

1. **Limited Functional Impact**: This modification primarily targets preparation work in ImmersiveModeControllerCocoa before entering fullscreen mode, adding cleanup logic for NSPopover windows. While WebView2Mac inherits and uses Remote Cocoa's immersive fullscreen functionality, it typically does not directly manage or create NSPopover windows.

2. **Defensive Fix**: This is a defensive bug fix to prevent crashes at the AppKit level. Even if NSPopover windows exist in the WebView2Mac host application (e.g., for displaying tooltips or popup menus), this fix ensures these windows are properly closed when entering fullscreen mode, thereby improving stability.

3. **Compatibility Consideration**: This fix is only applied to macOS versions prior to 26, demonstrating proper handling of different system versions. For WebView2Mac, this means better stability guarantees when running on older macOS versions.

4. **No Interface Changes**: This change does not modify any public interfaces, virtual function signatures, or Mojo interface definitions, so it will not affect WebView2Mac's derived classes (such as HostingNSWindowBridge) implementations.

5. **Potential Benefit**: If WebView2Mac applications have experienced NSPopover-related crashes when entering fullscreen mode, this fix will directly resolve the issue. Even if this problem hasn't been encountered before, this fix provides additional stability guarantees.

Impacted Classes:

remote_cocoa::ImmersiveModeControllerCocoa