Repository navigation
Description
Current behavior 🐛
MacOSMediaPlayerPresenterExtension keeps a private shadow copy of a native view pointer alongside the NativeHandle that actually owns it:
private readonly nint _nativeView; // MacOSMediaPlayerPresenterExtension.cs:24
...
_nativeView = NativeUno.uno_mediaplayer_create_view(); // :37
_presenter.Content = new MacOSNativeElement { NativeHandle = _nativeView }; // :40
...
NativeUno.uno_mediaplayer_set_view(_playerExtension._nativePlayer, _nativeView, nativeWindow.Handle); // :65The MacOSNativeElement created on line 40 owns the peer, and DisposeNativePeer() zeroes its NativeHandle when the element leaves the visual tree (see #24172). Nothing zeroes _nativeView. The extension also keeps no reference to the element it created, so it has no way to observe the disposal.
Once the presenter has been reparented, _nativeView is a pointer to a deallocated NSView, and uno_mediaplayer_set_view messages freed memory — objc_msgSend into a dead object, which takes down the process rather than failing the call.
This is structurally identical to the MacOSNativeWebView._webview bug fixed in #24112, which caused reproducible Segmentation fault: 11 / Bash exited with code '139' failures on the macOS CI shard.
Expected behavior 🎯
The extension resolves the handle through the owning element on each use and refuses a disposed peer, mirroring the TryGetHandle / TryGetLiveElement pattern introduced in #24112 — so a stale peer produces a logged no-op instead of a native crash.
How to reproduce it (as minimally and precisely as possible) 🔬
Latent — not currently reachable, filed pre-emptively.
CI evidence says the path is not hit today: in build 228879, When_MediaPlayerElement_SetIsFullWindow_Check_Fullscreen started at 13:35:51 and the host ran another 20 minutes before dying in the WebView2 path at 13:56:12. The uno_native_* guards added in #24112 do close the MediaPlayer route in practice.
It becomes reachable again if the guards are relaxed, or if any new code path reaches uno_mediaplayer_set_view after a reparent.
Workaround 🛠️
None needed today — see above.
Renderer 🎨
Skia
Affected platforms 📱💻🖥️
macOS (Skia)
Anything else we need to know? 💬
Spotted by @Xiaoy312 while fixing the equivalent WebView2 defect in #24112, and deliberately left out of that PR because the CI evidence showed it was not live. Blocked conceptually on the lifetime contract in #24172 — a proper fix there may remove the need for defensive handle resolution here.
Activity