Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
768 stars 305 forks source link

MediaService.OnDestroy throws null reference exception #823

Closed janwiebe-jump closed 1 year ago

janwiebe-jump commented 3 years ago

🐛 Bug Report

In my appcenter logs I see the following exception (and crash) occur MediaBrowserService.OnDestroy () System.NullReferenceException: Object reference not set to an instance of an object

MediaBrowserService.OnDestroy ()
Service.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.31(intptr,intptr)

It happens on Android 8, 9 and 10.

Expected behavior

The app shouldn't crash

Reproduction steps

Unknown

Configuration

Version: 1.0.8

Platform:

jamsoft commented 3 years ago

I can confirm I've seen this issue too.

DamienDoumer commented 1 year ago

Anybody has an idea how to fix this ?

fahad-pk commented 1 year ago

I am facing the same issue with Android 12,13.

DamienDoumer commented 1 year ago

This issue is the number one issue I have in prod. Does anyone know how to reproduce this please ? It happens on Android 12 too.

GaboBrandX commented 1 year ago

This issue is the number one issue I have in prod. Does anyone know how to reproduce this please ? It happens on Android 12 too.

Hi @DamienDoumer. Were you able to solve it? We're facing the same issue. Thanks!

DamienDoumer commented 1 year ago

Hi @GaboBrandX nope, I'm thinking about just adding a couple of null ref handeling stuff and making a PR, not the perfect solution but at least it will prevent crash.

DamienDoumer commented 1 year ago

Hello @martijn00 I sent a message to Baseflow, requesting collaboration to solve this issue. We're actually using it in our production app and it's causing an outstanding number of crash. I tried correcting it myself but found some issues. Please, if you're open to guide me just a little bit, I'll resolve it and make a PR.

nhinze commented 1 year ago

I have the same issue. To reproduce: toggle Blue Tooth on your Android Device. The app doesn't even need to be opened. You'll get the "X App Crashed" report card. I think you need to have your phone in developer mode to see it possibly.

DamienDoumer commented 1 year ago

Hello @martijn00, Please what is the commit on which the build for version "1.1.1" was released ? The migration to dotnet7 and MAUI makes it imposible to install the library older Xamarin.Forms apps.

martijn00 commented 1 year ago

The newer versions only support .net6 or MAUI. I believe this crash is fixed in the newer versions so i suggest to update to MAUI.

DamienDoumer commented 1 year ago

Thanks for your reply, @martijn00 I noticed that I need to upgrade. But what if upgrading to MAUI isn't an option? Please could you tell me on which branch or commit version 1.1.1 was released? I'll clone from there and add a fix for our app.

martijn00 commented 1 year ago

Probably around here: https://github.com/Baseflow/XamarinMediaManager/tree/1.1.0

DamienDoumer commented 1 year ago

Thanks @martijn00

DamienDoumer commented 1 year ago

Hello everyone! I resolved the bug, I tested it internally in my company and I deployed it in prod. After my fix, all the crashes we had in prod due to this issue have disappeared on the latest release. Since migrating to MAUI isn't an option right now, and that this library has fully moved to dotnet 7, I forked it at the last commit compatible with Xamarin.Forms and applied the fixes from there. You can checkout my fork here, and the fix is in the branch named AndroidMediaBrowserBugFix: https://github.com/DamienDoumer/XamarinMediaManager/tree/Fixes/AndroidMediaBrowserBugFix

I also built the library with my fixes. You can find the dlls here: MediaManager.zip

martijn00 commented 1 year ago

Thanks! I've pulled this into MediaManager as well.

SKallem439 commented 1 year ago

Hi Team, We released the new app version couple of weeks back. I am getting a number of crashes on the Android app. I am using the 1.1.1 plugin. I can't migrate to the latest one due to which I can't migrate to the latest .netCore because a lot of other functionalities will depend on it and it will impact other flows. If downgrade to the 1.1.0 version, Media can't play at all. What should I do? Am I missing anything here? My Targeted SDK is Android 31 (Android 12).

Please share your suggestions/feedback. A lot of end users were impacted.

@martijn00 @DamienDoumer

Anujai1 commented 1 year ago

@DamienDoumer I created nuget package from dll files you shared but package size is more than 3 MB. Have you added extra files like Exoplayer something?

DamienDoumer commented 1 year ago

@Anujai1 I just used the packages already present after the build process, and Exoplayer is in it.

SKallem439 commented 1 year ago

Hi Team,

We released the new app version a couple of weeks back. I am getting a number of crashes on the Android app. I am using the 1.1.1 plugin. I can't migrate to the latest one due to which I can't migrate to the latest .netCore because a lot of other functionalities will depend on it and it will impact other flows. If downgraded to the 1.1.0 version, Media can't play at all. What should I do? Am I missing anything here? My Targeted SDK is Android 31 (Android 12).

Please share your suggestions/feedback. A lot of end users were impacted. I need your help on this to get it fixed because a lot of users are impacted with the crash.

Please let me know If you need any further information on this.

Thanks & Regards, Sandeep. K.

On Tue, Apr 4, 2023 at 7:31 PM Damien Doumer @.***> wrote:

@Anujai1 https://github.com/Anujai1 I just used the packages already present after the build process, and Exoplayer is in it.

— Reply to this email directly, view it on GitHub https://github.com/Baseflow/XamarinMediaManager/issues/823#issuecomment-1496029575, or unsubscribe https://github.com/notifications/unsubscribe-auth/A63JSJM5GU4L5HR2LMVSS7LW7QSVHANCNFSM47NN7R2A . You are receiving this because you commented.Message ID: @.***>

Anujai1 commented 1 year ago

@SKallem439 you can create nuget package from files shared by Damien above, use it in your project and test it.

PavanZensark commented 1 year ago

@Anujai1 how do we use this in our project

mtln commented 1 year ago

@DamienDoumer I experience the same problems. Would you please give me some instructions: How can I create a nuget package from the zip you shared in order to use your patched version instead of v 1.1.1? Thanks!

Anujai1 commented 1 year ago

@PavanZensark, @mtln you can create nuget from Nuget Package Explorer or I have attached already created nuget here:

https://drive.google.com/file/d/1dTuzCnGNAioo4XAHQGMIg2VDIdZxXMuJ/view?usp=sharing

DamienDoumer commented 1 year ago

Hello @mtln @Anujai1 as I mentionned in my solution for the issue, You can download the zip file I made with the dlls and reference them in the respective projects. I did not make a nugget package, I built my fix on the last working Xamarin branch branch in release mode, and zipped the ddls.