androidx / androidx/media

Duplicate MediaSession

Open
#451 6 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Jun 8, 2023.

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

Description

After migrating to media3 from ExoPlayer and new MediaSession api, we've started getting some rare crash reports on duplicate media sessions:

Fatal Exception: java.lang.IllegalStateException: Session ID must be unique. ID=.MySession
       at androidx.media3.session.MediaSession.<init>(MediaSession.java:553)
       at androidx.media3.session.MediaSession$Builder.build(MediaSession.java:360)

Session is correctly cleaned up on fragment stop/destroy lifecycles, but I guess there can be conditions where you're not able to release it (due to some timeout or fragment crash) and the reference to it escapes your scope. So I think it would be convenient to have some static method to retrieve a MediaSession by it's id, or have some flag in the builder to force release previous session if it exists?

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.