Skip to content

Fix IOS crash when entering Full Screen#1755

Merged
TheCodeTraveler merged 8 commits intoCommunityToolkit:mainfrom
ne0rrmatrix:FixIOSFullScreenCrash
Mar 27, 2024
Merged

Fix IOS crash when entering Full Screen#1755
TheCodeTraveler merged 8 commits intoCommunityToolkit:mainfrom
ne0rrmatrix:FixIOSFullScreenCrash

Conversation

@ne0rrmatrix
Copy link
Copy Markdown
Member

  • Bug fix

Description of Change

The most significant changes involve the removal of the MediaElementUnloaded method and the Unloaded event handler from the MediaElementPage.xaml.cs and MediaElementPage.xaml files respectively. These were previously used to disconnect the handler when the media element was unloaded. Additionally, the OnNavigatedFrom method in the MediaElementPage.xaml.cs file was updated to stop the media element from playing when navigation away from the page occurs.

List of changes:

  1. Removal of the MediaElementUnloaded method from the MediaElementPage.xaml.cs file. This method was previously used to disconnect the handler when the media element was unloaded.
  2. Update to the OnNavigatedFrom method in the MediaElementPage.xaml.cs file to include a call to MediaElement.Stop(). This stops the media element from playing when navigation away from the page occurs.
  3. Removal of the Unloaded event handler from the MediaElementPage.xaml file. This event handler was previously used to call the MediaElementUnloaded method when the media element was unloaded.

Linked Issues

PR Checklist

Additional information

While adding Full Screen controls an unloaded event was added that called MediaElement.Handler?.Disconnect(); When entering full screen on IOS this event was called. I do not know why IOS calls unload event for switching to or from full screen it just does. This issue is an IOS only issue. It does not affect Mac.

I have tested this PR against Windows, Mac Catalyst, IOS and Android with almost no issues. For unknown reasons when returning to normal mode from full screen on IOS it pauses playback. This does not happen in Mac Catalyst. This is the only issue with this PR atm. I have no idea why IOS pauses upon returning from full screen.

…Unloaded` method and the `Unloaded` event handler from the `MediaElementPage.xaml.cs` and `MediaElementPage.xaml` files respectively. These were previously used to disconnect the handler when the media element was unloaded. Additionally, the `OnNavigatedFrom` method in the `MediaElementPage.xaml.cs` file was updated to stop the media element from playing when navigation away from the page occurs.

List of changes:

1. Removal of the `MediaElementUnloaded` method from the `MediaElementPage.xaml.cs` file. This method was previously used to disconnect the handler when the media element was unloaded.
2. Update to the `OnNavigatedFrom` method in the `MediaElementPage.xaml.cs` file to include a call to `MediaElement.Stop()`. This stops the media element from playing when navigation away from the page occurs.
3. Removal of the `Unloaded` event handler from the `MediaElementPage.xaml` file. This event handler was previously used to call the `MediaElementUnloaded` method when the media element was unloaded.
@ne0rrmatrix ne0rrmatrix marked this pull request as ready for review March 15, 2024 12:12
@vhugogarcia
Copy link
Copy Markdown
Contributor

Hello @ne0rrmatrix , on this PR there is only changes on the sample application of the Community Toolkit Media Element. Per what I understand the issue is on the sample only? 🤔

@briankanelson, could you please confirm, if the changes applied by James at the XAML page help you the fix the issue on your project: #1110 (comment) ?

@ne0rrmatrix
Copy link
Copy Markdown
Member Author

Hello @ne0rrmatrix , on this PR there is only changes on the sample application of the Community Toolkit Media Element. Per what I understand the issue is on the sample only? 🤔

@briankanelson, could you please confirm, if the changes applied by James at the XAML page help you the fix the issue on your project: #1110 (comment) ?

Yes @vhugogarcia it is only a fix to sample app.

Copy link
Copy Markdown
Contributor

@vhugogarcia vhugogarcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested these changes and I can confirm, it fixes the iOS crash on the Media Element sample when entering full screen. Thanks @ne0rrmatrix for the help!

@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) March 27, 2024 14:23
@TheCodeTraveler TheCodeTraveler merged commit eaf72cb into CommunityToolkit:main Mar 27, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MediaElement 1.0.2 crashes on iOS when exiting full screen mode and using AppShell

4 participants