Skip to content

Commit

Permalink
Fix bug in MCVR where dummySurface is released but surface isn't nulled
Browse files Browse the repository at this point in the history
The fix for Issue: #8776 was to release and null-out dummySurface if
it doesn't match the security level of the decoder. But it's possible
that this.surface is already set to this.dummySurface, in which case we
must also null out this.surface otherwise we will later try and re-use
the old, released DummySurface instance.

This logic already exists in MCVR#onReset, so I pulled it into a
releaseDummySurface() helper function.

Issue: #9476
#minor-release
PiperOrigin-RevId: 399420476
  • Loading branch information
icbaker authored and marcbaechinger committed Sep 28, 2021
1 parent 3e7b2d0 commit 679e375
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
`GlUtil.glAssertionsEnabled` instead.
* Move `Player.addListener(EventListener)` and
`Player.removeListener(EventListener)` out of `Player` into subclasses.
* Video:
* Fix bug in `MediaCodecVideoRenderer` that resulted in re-using a
released `Surface` when playing without an app-provided `Surface`
([#9476](https://github.com/google/ExoPlayer/issues/9476)).
* Android 12 compatibility:
* Keep `DownloadService` started and in the foreground whilst waiting for
requirements to be met on Android 12. This is necessary due to new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,7 @@ protected void onReset() {
super.onReset();
} finally {
if (dummySurface != null) {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
releaseDummySurface();
}
}
}
Expand Down Expand Up @@ -618,8 +614,7 @@ protected MediaCodecAdapter.Configuration getMediaCodecConfiguration(
float codecOperatingRate) {
if (dummySurface != null && dummySurface.secure != codecInfo.secure) {
// We can't re-use the current DummySurface instance with the new decoder.
dummySurface.release();
dummySurface = null;
releaseDummySurface();
}
String codecMimeType = codecInfo.codecMimeType;
codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
Expand Down Expand Up @@ -1178,6 +1173,14 @@ private boolean shouldUseDummySurface(MediaCodecInfo codecInfo) {
&& (!codecInfo.secure || DummySurface.isSecureSupported(context));
}

private void releaseDummySurface() {
if (surface == dummySurface) {
surface = null;
}
dummySurface.release();
dummySurface = null;
}

private void setJoiningDeadlineMs() {
joiningDeadlineMs =
allowedJoiningTimeMs > 0
Expand Down

0 comments on commit 679e375

Please sign in to comment.