Baseflow / XamarinMediaManager

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

Connecting Bluetooth device causes crash (stemming from MediaBrowserService.OnDestroy()) #873

Open rhedgpeth opened 1 year ago

rhedgpeth commented 1 year ago

πŸ› Bug Report

Currently have an app that will crash when connecting a known bluetooth device. The app itself targets Android 12, and is using Plugin.MediaManager.Form v1.1.1. It also seems to be occurring almost exclusively on Google Pixel devices, if that's at all helpful.

It's unclear to me what is causing the crash, but I suspect, based on some of the logs below, that it might have something to do with the targeted Android version (possibly related to this feature request?) Or maybe it's environmental.. not sure.

08-17 12:09:47.374  5390  5390 I MediaPlayerList: Adding wrapped media player: com.xxx.xxx at key: 2
08-17 12:09:47.397  5621  5621 V mono-stdout: com.xxx.xxx: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
08-17 12:09:47.397  5621  5621 V mono-stdout: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
08-17 12:09:47.407  5390  5390 I AvrcpBrowsedPlayerWrapper: onConnected: com.xxx.xxx is connected
08-17 12:09:47.407  5390  5390 D AvrcpBrowsablePlayerConnector: Browse player callback called: package=com.xxx.xxx : status=0
08-17 12:09:47.407  5390  5390 D AvrcpBrowsablePlayerConnector: Received a message: msg.what=1
08-17 12:09:47.407  5390  5390 I AvrcpBrowsablePlayerConnector: Checking root contents for com.xxx.xxx
08-17 12:09:47.428  1789  2000 D CompatibilityChangeReporter: Compat change id reported: 168419799; UID 10432; state: DISABLED
08-17 12:09:47.433  5621  5621 D AndroidRuntime: Shutting down VM
08-17 12:09:47.433  5621  5621 E AndroidRuntime: FATAL EXCEPTION: main
08-17 12:09:47.433  5621  5621 E AndroidRuntime: Process: com.xxx.xxx, PID: 5621
08-17 12:09:47.433  5621  5621 E AndroidRuntime: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
08-17 12:09:47.433  5621  5621 E AndroidRuntime:   at MediaManager.Platforms.Android.MediaSession.MediaBrowserService.OnDestroy () [0x0004c] in <2d77835a04ac470c9ff4c7b0511fd250>:0 
08-17 12:09:47.433  5621  5621 E AndroidRuntime:   at Android.App.Service.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <56d36f98164f4038b32ab84f04a73483>:0 
08-17 12:09:47.433  5621  5621 E AndroidRuntime:   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at crc646e364d2ff34954e7.MediaBrowserService.n_onDestroy(Native Method)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at crc646e364d2ff34954e7.MediaBrowserService.onDestroy(MediaBrowserService.java:58)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.app.ActivityThread.handleStopService(ActivityThread.java:4736)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.app.ActivityThread.access$2100(ActivityThread.java:256)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2134)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7870)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-17 12:09:47.433  5621  5621 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Expected behavior

The app would not crash.

Reproduction steps

Open app, background to connect a bluetooth device.

Configuration

Version: 1.1.1

Platform:

EBusch commented 1 year ago

Just wanted to add a +1 and say I am also seeing this behavior, happy to help provide more details if needed.

martijn00 commented 1 year ago

This might be fixed in 1.2.2