androidx / androidx/media

MediaCodec.setOutputSurface SberBox

Open
#2,529 0 comments 1 reaction 1 assignee View on GitHub

@tonihei is already working on this.

Since Jun 12, 2025.

bug: device specific
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 main branch

More version details

I have bug similar to issue #8329 which addressed MediaCodec format handling, this enhancement would add proactive Surface state management to prevent common MediaCodec crashes.

The most common crash pattern we observe:

androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
    Caused by: java.lang.IllegalArgumentException
        at android.media.MediaCodec.native_setSurface(Native Method)
        at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1979)
        at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.setOutputSurface
        at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.setOutputSurfaceV23


This is a known bug of some implementations of some platform video codecs. ExoPlayer can not fix it, only workaround it by releasing the codec and then re-initializing it instead of setting the outputSurface:
ExoPlayer/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java


I create pull request for add needed Util.Device value (sberbox) in function evaluateDeviceNeedsSetOutputSurfaceWorkaround

Devices that reproduce the issue

SberBox tv consoles

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps
  1. Start video
  2. Stop video
  3. Delay 5 minutes
  4. Start screensaver Activity
  5. Close screensaver
Expected result

The media don't crash after start screensaver

Actual result

The most common crash pattern we observe:

androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
    Caused by: java.lang.IllegalArgumentException
        at android.media.MediaCodec.native_setSurface(Native Method)
        at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1979)
        at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.setOutputSurface
        at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.setOutputSurfaceV23
Media

https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.