Report swallowed exceptions in ExternalTextureManager

The error was swallowed if
ExternalTextureManager.removeAllSurfaceTextureFrames was throwing.

PiperOrigin-RevId: 668480565
This commit is contained in:
kimvde 2024-08-28 09:12:08 -07:00 committed by Copybara-Service
parent c2e81052e8
commit 070e8217ac
2 changed files with 13 additions and 3 deletions

View File

@ -110,6 +110,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// a frame to arrive on the SurfaceTexture. // a frame to arrive on the SurfaceTexture.
private long firstTryToRemoveAllFramesTimeMs; private long firstTryToRemoveAllFramesTimeMs;
@Nullable private volatile RuntimeException releaseAllFramesException;
/** /**
* Creates a new instance. The caller's thread must have a current GL context. * Creates a new instance. The caller's thread must have a current GL context.
* *
@ -185,6 +187,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
Log.w(TAG, "Interrupted when waiting for MediaCodec frames to arrive."); Log.w(TAG, "Interrupted when waiting for MediaCodec frames to arrive.");
} }
if (releaseAllFramesException != null) {
throw releaseAllFramesException;
}
} }
/** /**
@ -350,7 +355,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
private void releaseAllFramesFromMediaCodec(CountDownLatch latch) { private void releaseAllFramesFromMediaCodec(CountDownLatch latch) {
try {
removeAllSurfaceTextureFrames(); removeAllSurfaceTextureFrames();
} catch (RuntimeException e) {
releaseAllFramesException = e;
latch.countDown();
}
if (pendingFrames.isEmpty() if (pendingFrames.isEmpty()
// Assumes a frame that is registered would not take longer than SURFACE_TEXTURE_TIMEOUT_MS // Assumes a frame that is registered would not take longer than SURFACE_TEXTURE_TIMEOUT_MS

View File

@ -284,8 +284,8 @@ import java.util.concurrent.TimeoutException;
private void handleException(Exception exception) { private void handleException(Exception exception) {
synchronized (lock) { synchronized (lock) {
if (shouldCancelTasks) { if (shouldCancelTasks) {
// Ignore exception after cancelation as it can be caused by a previously reported exception // Ignore exception after cancellation as it can be caused by a previously reported
// that is the reason for the cancelation. // exception that is the reason for the cancellation.
return; return;
} }
shouldCancelTasks = true; shouldCancelTasks = true;