Skip to content

Commit

Permalink
Release sample pipelines before asset loaders
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andrewlewis authored and rohitjoins committed Apr 12, 2023
1 parent eac4b53 commit 78669f8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,12 @@ private void endInternal(@EndReason int endReason, @Nullable ExportException exp
boolean releasedPreviously = released;
if (!released) {
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 {
sequenceAssetLoaders.get(i).release();
samplePipelines.get(i).release();
} catch (RuntimeException e) {
if (releaseExportException == null) {
releaseExportException = ExportException.createForUnexpected(e);
Expand All @@ -355,9 +358,9 @@ private void endInternal(@EndReason int endReason, @Nullable ExportException exp
}
}
}
for (int i = 0; i < samplePipelines.size(); i++) {
for (int i = 0; i < sequenceAssetLoaders.size(); i++) {
try {
samplePipelines.get(i).release();
sequenceAssetLoaders.get(i).release();
} catch (RuntimeException e) {
if (releaseExportException == null) {
releaseExportException = ExportException.createForUnexpected(e);
Expand Down

0 comments on commit 78669f8

Please sign in to comment.