You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NullPointerException in MediaControllerImplBase.FlushCommandQueueHandler.handleMessage #74
From #73 a stack trace reported the following NullPointerException that is actually unrelated to the question of the other issue.
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.media3.session.IMediaSession.flushCommandQueue(androidx.media3.session.IMediaController)' on a null object reference
at androidx.media3.session.MediaControllerImplBase$FlushCommandQueueHandler.handleMessage(MediaControllerImplBase.java:3041)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:255)
at android.app.ActivityThread.main(ActivityThread.java:8212)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
The stack trace documents that MSG_FLUSH_COMMAND_QUEUE was executed after the field MediaControllerImplBase.iSession was nulled in MediaControllerimplbase.release(). It looks like this situation can happen fairly easily when an app calls a method that requests the command queue to be flushed with a handler message and then calls release() afterwards.
This can be easily reproduced by adding the two lines at the end of PlayerActivity.setController().
We need to fix this. Probably easiest by removing all messages from the handler in release() and probably also not letting FlushCommandQueueHandler add a message when the iSession is null.
Activity
Remove all handler messages when controller is released