Version
Media3 1.2.0
More version details
Using a thread looper rather than main thread in the custom player, it got crashed.
Then delay few milliseconds at the end of service onCreate, it rarely crashed. But this is not a solution.
Is it an intented behavior or I mis-used the threading? I don't want player run on main thread, because it blocks UI sometimes.
Devices that reproduce the issue
Pixel 4 XL (Android 13)
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
- Using the code
class AudioPlaybackService : MediaLibraryService() {
private var mediaSession: MediaLibrarySession? = null
private val thread: HandlerThread = HandlerThread("AudioPlaybackService").apply { start() }
override fun getMainLooper(): Looper {
return thread.looper
}
override fun onCreate() {
super.onCreate()
val player = AudioPlayer(mainLooper) // A custom Player
mediaSession = MediaLibrarySession.Builder(this, player, callback)
}
}
- Run the app and see crash
Expected result
It won't crash at starup
Actual result
java.lang.IllegalStateException: Future was expected to be done: androidx.media3.session.MediaControllerHolder@7887bc2[status=PENDING]
at com.google.common.base.Preconditions.checkState(Preconditions.java:590)
at com.google.common.base.Preconditions.checkState(Preconditions.java:590)
at com.google.common.util.concurrent.Futures.getDone(Futures.java:1147)
at androidx.media3.session.MediaNotificationManager.getConnectedControllerForSession(MediaNotificationManager.java:269)
at androidx.media3.session.MediaNotificationManager.shouldRunInForeground(MediaNotificationManager.java:192)
at androidx.media3.session.MediaSessionService.onUpdateNotificationInternal(MediaSessionService.java:565)
at androidx.media3.session.MediaSessionService$MediaSessionListener.onNotificationRefreshRequired(MediaSessionService.java:624)
at androidx.media3.session.MediaSessionImpl.lambda$onNotificationRefreshRequired$12$androidx-media3-session-MediaSessionImpl(MediaSessionImpl.java:797)
at androidx.media3.session.MediaSessionImpl$$ExternalSyntheticLambda10.run(D8$$SyntheticClass:0)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7924)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Media
None
Bug Report
Version
Media3 1.2.0
More version details
Using a thread looper rather than main thread in the custom player, it got crashed.
Then delay few milliseconds at the end of service
onCreate, it rarely crashed. But this is not a solution.Is it an intented behavior or I mis-used the threading? I don't want player run on main thread, because it blocks UI sometimes.
Devices that reproduce the issue
Pixel 4 XL (Android 13)
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
Expected result
It won't crash at starup
Actual result
Media
None
Bug Report
adb bugreportto android-media-github@google.com after filing this issue.