Asynchronous onGetLibraryRoot deadlocks legacy MediaBrowser
@tonihei is already working on this.
Since Aug 28, 2026.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.11.0
More version details
1.11.0
The same callback works with 1.9.0/1.10.1.
Devices that reproduce the issue
- Pixel 9 with android auto simulator
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Yes
Reproduction steps
On the demo app, return an incomplete ListenableFuture from MediaLibrarySession.Callback.onGetLibraryRoot().
Complete it successfully from a background thread after 100 ms. Example code:
override fun onGetLibraryRoot(
session: MediaLibraryService.MediaLibrarySession,
browser: MediaSession.ControllerInfo,
params: MediaLibraryService.LibraryParams?,
): ListenableFuture<LibraryResult<MediaItem>> {
val future = SettableFuture.create<LibraryResult<MediaItem>>()
Log.i("AsyncRootRepro", "Returning incomplete root future")
executor.schedule(
{
Log.i("AsyncRootRepro", "Completing root future")
future.set(
LibraryResult.ofItem(
MediaItemTree.getRootItem(),
params,
)
)
},
100,
TimeUnit.MILLISECONDS,
)
return future
}
Connect a controller like Android Auto. The background log confirms the future completes, but the browser never connects and the service main thread ANRs.
Returning Futures.immediateFuture with the identical LibraryResult (as in the default demo-session sample) works.
Expected result
MediaLibrarySession.Callback explicitly returns a ListenableFuture, so a non-immediate result should complete without deadlocking legacy browser compatibility.
Actual result
Only an already-completed future works. Asynchronous future deadlocks the service main thread.
Media
see ready example on de demo-sesion at https://github.com/kelmer44/media-interstitials/tree/anr-deadlock
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.