androidx / androidx/media

Hook for delaying MediaLibraryService.onDestroy() after session release

Open
#2,380 3 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Apr 30, 2025.

needs triage question
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

I am seeing that MediaLibraryService.onDestroy() is called rapidly (almost instantly) after media session release. This may generally be considered desirable, but I also need a hook to properly release resources that release asynchronously (coroutine cancellation) prior to onDestroy() being called. I have not been able to find such a hook, despite trying various suspects.

The only thing that worked was blocking onDestroy() for a little while until coroutines have completed, but this is unacceptable, for obvious reasons.

My MediaLibrarySession runs off the main thread, so I could block in my custom thread if I could find a proper code location to insert some blocking code there.

Media3 1.6.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.