diff --git a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java index 05f8e57d90..3564a117e8 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java @@ -110,6 +110,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; // a frame to arrive on the SurfaceTexture. private long firstTryToRemoveAllFramesTimeMs; + @Nullable private volatile RuntimeException releaseAllFramesException; + /** * 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(); 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) { - removeAllSurfaceTextureFrames(); + try { + removeAllSurfaceTextureFrames(); + } catch (RuntimeException e) { + releaseAllFramesException = e; + latch.countDown(); + } if (pendingFrames.isEmpty() // Assumes a frame that is registered would not take longer than SURFACE_TEXTURE_TIMEOUT_MS diff --git a/libraries/effect/src/main/java/androidx/media3/effect/VideoFrameProcessingTaskExecutor.java b/libraries/effect/src/main/java/androidx/media3/effect/VideoFrameProcessingTaskExecutor.java index b9e1ed2fd9..e5498cc85e 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/VideoFrameProcessingTaskExecutor.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/VideoFrameProcessingTaskExecutor.java @@ -284,8 +284,8 @@ import java.util.concurrent.TimeoutException; private void handleException(Exception exception) { synchronized (lock) { if (shouldCancelTasks) { - // Ignore exception after cancelation as it can be caused by a previously reported exception - // that is the reason for the cancelation. + // Ignore exception after cancellation as it can be caused by a previously reported + // exception that is the reason for the cancellation. return; } shouldCancelTasks = true;