androidx / androidx/media

MediaUtils.mergePlayerInfo crashes with IllegalStateException on invalid PlayerInfo from remote session

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

@marcbaechinger is already working on this.

Since May 29, 2026.

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

Description

Version

Media3 1.10.0

More version details

No response

Devices that reproduce the issue
  • TCL Smart Tv Pro
Devices that do not reproduce the issue

No response

Reproducible in the demo app?

No response

Reproduction steps

MediaUtils.mergePlayerInfo() throws an IllegalStateException via Preconditions.checkState() when a remote MediaSession sends a PlayerInfo update with an out-of-bounds currentMediaItemIndex. This crash is not catchable by the client app.

Note : this is probably related to #1447

Context

I develop an Android TV launcher that connects to active MediaSessions (via MediaSessionManager.getActiveSessions() → SessionToken.createSessionToken() → MediaController.Builder.buildAsync()) in order to display a "Now Playing" row. The launcher simply listens to player state/metadata changes and does not control playback.

Why this is a problem

The crash originates from a misbehaving remote app, not from the client. The client MediaController has no way to validate or reject the incoming PlayerInfo before mergePlayerInfo() is called.
The crash happens inside Media3's internal handler dispatch (MediaControllerStub.dispatchControllerTaskOnHandler), so there is no way for the client app to catch it — it's not wrapped in any client-facing callback.
Impact: For a launcher, any third-party app with a broken MediaSession can crash the entire launcher, which is the user's home screen.

Expected result

mergePlayerInfo() should handle an invalid index gracefully — for example by logging a warning and ignoring the update (or clamping the index) — rather than crashing the client process. The client should not be punished for a remote session sending inconsistent state.

Actual result

A remote app (in this case com.crunchyroll.crunchyroid, interface version=8) sends a PlayerInfo update where newIndex = 1 but the timeline only contains 1 item (count = 1). This triggers a fatal

IllegalStateException in MediaUtils.mergePlayerInfo():
Fatal Exception: java.lang.IllegalStateException: Invalid PlayerInfo update, old index: 0 (count=1), new index = 1, sent from com.crunchyroll.crunchyroid, interface version=8
    at androidx.core.util.Preconditions.checkState(Preconditions.java:169)
    at androidx.media3.session.MediaUtils.mergePlayerInfo(MediaUtils.java:150)
    at androidx.media3.session.MediaControllerImplBase.onPlayerInfoChanged(MediaControllerImplBase.java:2965)
    at androidx.media3.session.MediaControllerStub.lambda$onPlayerInfoChangedWithExclusions$12(MediaControllerStub.java:309)
    at androidx.media3.session.MediaControllerStub.lambda$dispatchControllerTaskOnHandler$18(MediaControllerStub.java:431)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:233)
    at android.os.Looper.loop(Looper.java:328)
    at android.app.ActivityThread.main(ActivityThread.java:8305)
Media

I don't have any media related to this issue as this is not originating from my app. I didn't reproduce it myself, it has only been seen on crashlytics.

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

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.