-
Notifications
You must be signed in to change notification settings - Fork 414
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] MediaElement Crash Android #2423
Comments
Hi @Pmr-precure! We have added the
needs reproduction
label to this issue, which indicates that we are unable to take further action until you provide a reproduction sample that we can use to reproduce + fix your bug. In accordance with the |
Only way i have been able to fix this issue is to add GC.SupressFinalize(this) in the dispose method of the MediaControlService. And then call dispose(true) from the onDestroy() method. No idea if this is the fix or not. Or simply just remove the mediaSession.Release() and Dispose since it seems like its already disposed from somewhere else. :) |
I am having a very similar issue. I was disposing of the media element myself as well to avoid memory leaks in IOS; however, on Android, I get this very same crash regardless of whether I dispose of it or not. When I leave the page where MediaElement lives, all seems fine, but if I call EDIT: 4.1.2 on .NET 9 doesn't have this issue. Something in 5.0.0 could be introducing this problem. |
Yes i can confirm the crash doesnt happen on 4.1.2. |
Can you test the sample app with current main branch. The media 3 PR was just merged a few hours ago. It should solve most issues. |
Can you try using maui 9.0.30 with latest visual studio workload? I just tested the sample app and it builds and runs in both debug and release mode. I have seen the issue you are facing on a much older version of the android workload. Are you testing against main? |
Im testing against main yes. Got a new error now |
Based on the screenshots you provided can u update visual studio to latest to see if that fixes your issue? |
I will try that when im back in office. Ill let you know. Br |
I looked at the sample and it does not have the correct permissions for android manifest. You are missing the service. |
The minimum supported version of android for media element is API level 26 for dotnet 9.x going forward |
Roger that, will test now. And get back to you. I still think its odd that you need to add the permisson to use the MediaElement, since we dont want to use the foreground service anyways, we only show some tutorials etc. |
I can confirm that the current main branch with the media3 update fixes this issue! Hurray It doesnt fix this samples other "Already disposed" bug. Thank you very much @ne0rrmatrix BR |
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
Hi,
I have a weird issue, I dispose my mediaelements manually because of other issues.
But now im starting to get this crash:
This is the dispose method of the MediaControlService.Android. It doesnt get called by the DisconnectHandler method, but seems to get randomly called. Since it seems to happen random i havnt been able to replicate. But it causes a lot of crashes in our app.
**
EDIT**
I finally managed to replicate the issue, and it seems to be because of the Garbage Collector.
Our App is using Bluetooth and doing a lot of data processing, so the GC is working hard.
And at somepoint the GC apparently "kills" the MediaSession which leads to this crash ( Eventhough the media service should have been disposed already) .
In this repo https://github.com/Pmr-precure/MauiTestProject/tree/Audio_And_Session_Dispose_Bug
i added a "MemoryFiller" so after starting the video by pressing "Click me", then go back to the homepage and start the memory filler. The crash will happen seconds later.
I think this issue could be the same? #2359
Expected Behavior
Not randomly crash.
Steps To Reproduce
Git clone
Run project
Press the button, and see it crash.
Link to public reproduction project repository
Git repo
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: