mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add thread names to the 'player accessed on wrong thread' message
This will help app developers identify which thread is being used and which is expected. PiperOrigin-RevId: 370409697
This commit is contained in:
parent
2a0b45ac77
commit
2b582b540a
1 changed files with 10 additions and 8 deletions
|
|
@ -588,9 +588,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TAG = "SimpleExoPlayer";
|
private static final String TAG = "SimpleExoPlayer";
|
||||||
private static final String WRONG_THREAD_ERROR_MESSAGE =
|
|
||||||
"Player is accessed on the wrong thread. See "
|
|
||||||
+ "https://exoplayer.dev/issues/player-accessed-on-wrong-thread";
|
|
||||||
|
|
||||||
protected final Renderer[] renderers;
|
protected final Renderer[] renderers;
|
||||||
|
|
||||||
|
|
@ -2014,13 +2011,18 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
// the app thread until the constructor finished executing.
|
// the app thread until the constructor finished executing.
|
||||||
constructorFinished.blockUninterruptible();
|
constructorFinished.blockUninterruptible();
|
||||||
if (Looper.myLooper() != getApplicationLooper()) {
|
if (Looper.myLooper() != getApplicationLooper()) {
|
||||||
|
String message =
|
||||||
|
Util.formatInvariant(
|
||||||
|
"Player is accessed on the wrong thread.\n"
|
||||||
|
+ "Current thread: '%s'\n"
|
||||||
|
+ "Expected thread: '%s'\n"
|
||||||
|
+ "See https://exoplayer.dev/issues/player-accessed-on-wrong-thread",
|
||||||
|
Looper.myLooper().getThread().getName(),
|
||||||
|
getApplicationLooper().getThread().getName());
|
||||||
if (throwsWhenUsingWrongThread) {
|
if (throwsWhenUsingWrongThread) {
|
||||||
throw new IllegalStateException(WRONG_THREAD_ERROR_MESSAGE);
|
throw new IllegalStateException(message);
|
||||||
}
|
}
|
||||||
Log.w(
|
Log.w(TAG, message, hasNotifiedFullWrongThreadWarning ? null : new IllegalStateException());
|
||||||
TAG,
|
|
||||||
WRONG_THREAD_ERROR_MESSAGE,
|
|
||||||
hasNotifiedFullWrongThreadWarning ? null : new IllegalStateException());
|
|
||||||
hasNotifiedFullWrongThreadWarning = true;
|
hasNotifiedFullWrongThreadWarning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue