Add descriptive error message for looper mismatch in BaseMediaSource#3188
Add descriptive error message for looper mismatch in BaseMediaSource#3188NoNews wants to merge 1 commit intoandroidx:mainfrom
Conversation
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
|
Did the stack trace you had not point to the line of the 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. |
|
Hi @icbaker and thank you for the feedback!
Yes, once we were able to reproduce it (which was the hardest part as only tiny fraction of users were affected), we were able to see the trace.
Got it! Do you think we can still have some distinction and use a shorter message, to reduce the impact? Like: heckArgument(
this.looper == null || this.looper == looper,
"Wrong looper used");The reason we ask: without a message, our error reporting only showed |
|
Thanks for the extra context. I chatted about this with others on the team, and we are a bit surprised that your error telemetry completely drops stack traces and only reports exception messages. We think it's unreasonable to expect every exception message in the library to be unique (in order to identify the root cause from just the message), and it would make more sense for error-reporting telemetry to include the stack trace. I assume this would be obfuscated, but could of course be unobfuscated with the appropriate mapping file. Given this, we don't plan to add additional exception messages routinely in the codebase, and that includes this PR - so I'm going to close this. |
Reusing a cached
MediaSourceacross players with different playback threads throws a message-lessIllegalArgumentException, 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!