Skip to content

Add descriptive error message for looper mismatch in BaseMediaSource#3188

Open
NoNews wants to merge 1 commit intoandroidx:mainfrom
NoNews:improve-base-media-source-looper-error-message
Open

Add descriptive error message for looper mismatch in BaseMediaSource#3188
NoNews wants to merge 1 commit intoandroidx:mainfrom
NoNews:improve-base-media-source-looper-error-message

Conversation

@NoNews
Copy link
Copy Markdown
Contributor

@NoNews NoNews commented Apr 26, 2026

Reusing a cached MediaSource across players with different playback threads throws a message-less IllegalArgumentException, silently swallowed into error code 1004.

Impact at Reddit Android App
We experienced ~2M errors/day. It only showed up in one specific edge case, so we had nothing to go on but telemetry with 1004 error code — and the empty exception made it much harder to pin down. (We spent a week debugging this).

We're currently experimenting with a single shared looper and seeing the problem addressed.

See #2263

Thank you!

The checkArgument in prepareSource() previously threw an
IllegalArgumentException with no message when a MediaSource was prepared
on a different looper than the one it was originally bound to. This
exception is caught and mapped to ERROR_CODE_FAILED_RUNTIME_CHECK (1004)
with no further context, making the root cause very hard to diagnose.

Add a message that names both loopers and points to
ExoPlayer.Builder.setPlaybackLooper() as the recommended fix.

Made-with: Cursor
@icbaker
Copy link
Copy Markdown
Collaborator

icbaker commented Apr 27, 2026

Did the stack trace you had not point to the line of the checkArgument call (and so the cause would be obvious by looking at the source)?

I think in general we write exception checks & messages on the assumption that the reader will cross-reference with the relevant source code for additional context. This is partly to keep APK bloat in check by avoiding long strings on every edge-case exception check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants