Commit 78669f87 by andrewlewis Committed by Rohit Singh

Release sample pipelines before asset loaders

The video asset loader renders decoder output to a surface texture, and if the
video sample pipeline is in the process of updating the surface texture image
at the moment when the asset loader video decoder is released this seems to
cause `MediaCodec.release` to get stuck.

Swap the release order so that we stop updating the texture before trying to
release the codec.

PiperOrigin-RevId: 523401619
parent eac4b536
...@@ -343,9 +343,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -343,9 +343,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
boolean releasedPreviously = released; boolean releasedPreviously = released;
if (!released) { if (!released) {
released = true; released = true;
for (int i = 0; i < sequenceAssetLoaders.size(); i++) { // The video sample pipeline can hold buffers from the asset loader's decoder in a surface
// texture, so we release the video sample pipeline first to avoid releasing the codec while
// its buffers are pending processing.
for (int i = 0; i < samplePipelines.size(); i++) {
try { try {
sequenceAssetLoaders.get(i).release(); samplePipelines.get(i).release();
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (releaseExportException == null) { if (releaseExportException == null) {
releaseExportException = ExportException.createForUnexpected(e); releaseExportException = ExportException.createForUnexpected(e);
...@@ -355,9 +358,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -355,9 +358,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
} }
} }
for (int i = 0; i < samplePipelines.size(); i++) { for (int i = 0; i < sequenceAssetLoaders.size(); i++) {
try { try {
samplePipelines.get(i).release(); sequenceAssetLoaders.get(i).release();
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (releaseExportException == null) { if (releaseExportException == null) {
releaseExportException = ExportException.createForUnexpected(e); releaseExportException = ExportException.createForUnexpected(e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment