ingageco/capacitor-music-controls-plugin

java.lang.RuntimeException: crashes reported (Google Play Console)

Closed this issue ยท 6 comments

Following is a crash log retrieved from the Google Play Console, for a published app which makes use of this Capacitor v3 plugin. There are several instances of this crash, reported on Android 11, 12 and 13 devices.

Exception java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge (Bridge.java:772)
  at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.os.HandlerThread.run (HandlerThread.java:67)
Caused by java.lang.reflect.InvocationTargetException:
  at java.lang.reflect.Method.invoke
  at com.getcapacitor.PluginHandle.invoke (PluginHandle.java:138)
  at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge (Bridge.java:763)
Caused by java.lang.NullPointerException: Attempt to invoke interface method 'android.media.session.ISessionController android.media.session.ISession.getController()' on a null object reference
  at android.media.session.MediaSession.<init> (MediaSession.java:207)
  at android.media.session.MediaSession.<init> (MediaSession.java:163)
  at android.support.v4.media.session.MediaSessionCompatApi21.createSession (MediaSessionCompatApi21.java:46)
  at android.support.v4.media.session.MediaSessionCompat$MediaSessionImplApi21.<init> (MediaSessionCompat.java:3380)
  at android.support.v4.media.session.MediaSessionCompat$MediaSessionImplApi28.<init> (MediaSessionCompat.java:3906)
  at android.support.v4.media.session.MediaSessionCompat.<init> (MediaSessionCompat.java:493)
  at android.support.v4.media.session.MediaSessionCompat.<init> (MediaSessionCompat.java:456)
  at com.ingageco.capacitormusiccontrols.CapacitorMusicControls.initialize (CapacitorMusicControls.java:145)
  at com.ingageco.capacitormusiccontrols.CapacitorMusicControls.create (CapacitorMusicControls.java:71)

Any idea why this is happening?

This looks like it's pretty deep - nothing obvious that I can see in the error like previous issues. I'll have to go through the trace and see if anything makes sense.

@NorthFred Found this: appears we need to release the media session - google/ExoPlayer#9436

Fix attempted in 1.0.15

This needs to be verified with an app in production, cause the logs are taken from the Play Console. Will come back to this.

@NorthFred let me know when you can verify this fix

@ingageco I published a production release just a moment ago with the newest version of the music controls plugin. I'll keep an eye on the crash logs in the coming days and report back during next week. I wasn't able to reproduce this during my own testing, but the bug was found on several user's devices...

@ingageco So far there haven't been any entries in the crash logs referring to this issue, so it looks like it got resolved. Seems the fix is working!