Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Navigating back from MediaElement and calling DisconnectHandler results in crash #1245

Closed
2 tasks done
sjorsmiltenburg opened this issue Jun 14, 2023 · 3 comments · Fixed by #1304
Closed
2 tasks done
Labels
bug Something isn't working 📽️ MediaElement Issue/PR that has to do with MediaElement unverified

Comments

@sjorsmiltenburg
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

I have the mediaelement working on windows to play my video.
But when i navigate back and, as per the documentation, try to release the resources by calling
MyMediaElement.Handler?.DisconnectHandler();
during unload. It crashes with a Catastrophic Failure Exception.

I found multiple issues reporting this problem (like this one: #962), but all issues seem to have been closed as in "fixed". So I don't understand why I'm still seeing this behaviour with the latest version.
Or maybe the documentation is outdated and we no longer need to call the DisconnectHandler method??

I'm using

  • CommunityToolkit.Maui 5.2.0
  • CommunityToolkit.Maui.MediaElement 2.0.0

Expected Behavior

no crash on navigate back

Steps To Reproduce

a reproduction sample is here: https://github.com/sjorsmiltenburg/maui_bugs

Steps to Reproduce

  • build and run repro sample on windows
  • click the bug 5 button
  • navigate back

Link to public reproduction project repository

https://github.com/sjorsmiltenburg/maui_bugs

Environment

CommunityToolkit.Maui 5.2.0
CommunityToolkit.Maui.MediaElement 2.0.0

Anything else?

No response

@jfversluis
Copy link
Member

So I think we do have a bug that we're calling Dispose twice. However, if I change that to happen only once, still if I call Player.MediaPlayer.Dispose() that will always throw an exception and I'm not sure why...

@ne0rrmatrix
Copy link
Contributor

I noticed the same thing and can confirm this is an issue.

@pictos
Copy link
Member

pictos commented Jul 23, 2023

Right now the workaround is to add a delay before calling the DisconnectHandler

private async void Bug5View_Unloaded(object sender, EventArgs e)
{
    await Task.Delay(2_000);
    MyMediaElement.Handler?.DisconnectHandler();
}

The exception is related with the Frame navigation failure, So I don't think we are calling the Dispose method twice. I think the issue is that we dispose the FramewokElement (control in winUI) too son

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 📽️ MediaElement Issue/PR that has to do with MediaElement unverified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants