-
Notifications
You must be signed in to change notification settings - Fork 461
Description
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
MediaElement crashes when created inside ItemTemplate of CarouselView with the following error:
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()
Expected Behavior
MediaElement runs without issues on iOS
Steps To Reproduce
Open and build this demo:
https://github.com/RomanTelexy/MediaElement.Crash.Demo.iOS
NOTE: Because this is iOS only bug, you'll need to provide your own certificate in order to run it on iOS.
I tested it on iPad A16 (iPad OS 18.4 & 18.5), as well as on iPad A16 Emulator (same OS versions)
Link to public reproduction project repository
https://github.com/RomanTelexy/MediaElement.Crash.Demo.iOS
Environment
- .NET MAUI CommunityToolkit:6.1.2
- OS:iPad OS 18.4 & 18.5, running from Visual Studio 2022 on Win 11 (v 24H2)
- .NET MAUI:9.0.110Anything else?
This seems like a regression of this issue. It also came back here.
I think the culprit is inside TryGetCurrentPage which runs inside constructor, more specifically this line doesn't have a desired effect, when not using Shell navigation. window.Navigation.NavigationStack only displays correct data after the page was constructed. For instance, if you check the same NavigationStack inside OnAppearing - you will be able to find a page.
I have a detailed demo of this behavior over here:
https://github.com/RomanTelexy/Maui.NavigationDemo