Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in MediaControllerImplBase.FlushCommandQueueHandler.handleMessage #74

Closed
marcbaechinger opened this issue May 7, 2022 · 0 comments
Assignees
Labels

Comments

@marcbaechinger
Copy link
Contributor

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
@marcbaechinger marcbaechinger self-assigned this May 7, 2022
icbaker pushed a commit that referenced this issue May 24, 2022
@androidx androidx locked and limited conversation to collaborators Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant