Skip to content

Commit

Permalink
Disable tunneling on internal Surface related Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Jan 4, 2023
1 parent eea4f0f commit ec8b369
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.schabi.newpipe.player;

import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND;
Expand Down Expand Up @@ -1391,7 +1392,7 @@ public void onCues(@NonNull final CueGroup cueGroup) {
@SuppressWarnings("SwitchIntDef")
@Override
public void onPlayerError(@NonNull final PlaybackException error) {
Log.e(TAG, "ExoPlayer - onPlayerError() called with:", error);
Log.e(TAG, "ExoPlayer - onPlayerError() called with:" + error.toBundle());

saveStreamProgressState();
boolean isCatchableException = false;
Expand Down Expand Up @@ -1429,6 +1430,24 @@ public void onPlayerError(@NonNull final PlaybackException error) {
setRecovery();
reloadPlayQueueManager();
break;
case ERROR_CODE_FAILED_RUNTIME_CHECK:
// Try to handle tunneling related exceptions
final String stackTrace = Log.getStackTraceString(error.getCause());
Log.d(TAG, "Unexpected PlaybackException! Cause: " + stackTrace);
if (trackSelector.getParameters().tunnelingEnabled
&& stackTrace.contains("Surface")) {
trackSelector.setParameters(trackSelector.buildUponParameters()
.setTunnelingEnabled(false));
// Reload playback on unexpected errors:
setRecovery();
reloadPlayQueueManager();
break;
} else {
Log.d(TAG, "Conditinns for recovery not met. Tunneling enabled?: "
+ trackSelector.getParameters().tunnelingEnabled
+ ", Surface keyword found?: " + stackTrace.contains("Surface"));
}
// fall through to default
default:
// API, remote and renderer errors belong here:
onPlaybackShutdown();
Expand Down

0 comments on commit ec8b369

Please sign in to comment.