这是indexloc提供的服务,不要输入任何密码
Skip to content

MediaCodec.setOutputSurface SberBox #2529

@KingOfRaccoon

Description

@KingOfRaccoon

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions