Minimal .NET MAUI (.NET 9) reproduction showing an iOS-only crash when using a MediaElement inside a CarouselView DataTemplate without Shell navigation.
This app intentionally removes Shell to keep the navigation stack minimal and surfaces an iOS crash related to MediaElement usage in a templated control.
Android (and likely Windows/MacCatalyst) run without crashing; iOS reproduces the fault.
{System.InvalidOperationException: Cannot find current page
at CommunityToolkit.Maui.Core.Views.MauiMediaElement..ctor(AVPlayerViewController playerViewController, MediaElement virtualView)
in /_/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.macios.cs:line 57
at CommunityToolkit.Maui.Core.Handlers.MediaElementHandler.CreatePlatformView()
AppoverridesCreateWindowto return aNavigationPageinstead of using Shell.MainPagecontains aCarouselViewwhoseItemTemplateis a very simpleMediaElementbound to a list of three remote MP4 URLs.- Crash occurs only on iOS. The same code path does not crash other platforms (based on current observations).
- Wrapping the
MainPagein aNavigationPagepermits exception capture/visibility; using plainnew Window(new MainPage())more directly exposes the failure scenario. - The scenario highlights a potential issue with
MediaElementlifecycle inside a recycled templated control (CarouselView).