Description
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.
controller.pause() <- sends MSG_FLUSH_COMMAND_QUEUE
controller.release() <- controllerImplbase.iSession = null
When the message is executed in 'FlushCommandQueueHandler.handleMessage` the NPE is thrown.
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.
- AndroidX Media version number: 1.0.0.alpha03
- Android version: All versions
- Android device: All devices