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] Media Element cannot be disconnected #2388

Open
2 tasks done
cagriy opened this issue Dec 17, 2024 · 2 comments · Fixed by #2215
Open
2 tasks done

[BUG] Media Element cannot be disconnected #2388

cagriy opened this issue Dec 17, 2024 · 2 comments · Fixed by #2215
Labels
bug Something isn't working 📽️ MediaElement Issue/PR that has to do with MediaElement unverified

Comments

@cagriy
Copy link

cagriy commented Dec 17, 2024

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

Upon exiting a page that has a MediaElement, although calling the DisconnectHandler as recommended, MediaElement does not get removed.

Expected Behavior

MediaElement should be garbage collected.

Steps To Reproduce

  1. Open and run the solution from the reproduction repository
  2. Click the button to go to the second page where the memory element lives
  3. Click the back button to go to the main page
  4. Check gcdump vie heapview and search for MediaElement

Link to public reproduction project repository

https://github.com/cagriy/MemoryLeak9

Environment

- .NET MAUI CommunityToolkit Media Element: 5.0.0
- OS: iOS 18.1
- .NET MAUI: 9.0.21

Anything else?

No response

@cagriy cagriy added bug Something isn't working unverified labels Dec 17, 2024
@brminnick brminnick mentioned this issue Dec 17, 2024
6 tasks
@cagriy
Copy link
Author

cagriy commented Dec 18, 2024

Hi @brminnick, I've upgraded Media Element to 5.0.0, but I still see the same problem. Is there anything else I need to be doing to make sure the media element is disconnected correctly?

The reproduction repo now includes a sample with the upgraded media element.

Sorry if I am missing something obvious.

@brminnick brminnick reopened this Dec 18, 2024
@vhugogarcia vhugogarcia added the 📽️ MediaElement Issue/PR that has to do with MediaElement label Dec 19, 2024
@ne0rrmatrix
Copy link
Contributor

Handler disconnect is done automatically by Maui now. If you want more info: https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0. You can control it yourself if you set the handler disconnect policy.

Example:

 <toolkit:MediaElement
     x:Name="MediaElement"
     HandlerProperties.DisconnectPolicy="Manual"
     Source="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"/>

The above code will let you control it manually. It is up to you if you want it to work this way now. By default it will work automatically in the background.

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