Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DecoderInitializationException: AVC to HEVC switch issue on some devices #9250

Closed
cdongieux opened this issue Aug 3, 2021 · 7 comments
Closed
Assignees

Comments

@cdongieux
Copy link

Since ExoPlayer 2.13.X (including the last 2.14.2 release) there is an issue in DASH Live streams having both AVC and HEVC profiles in their manifests. The issue occurs when switching from one decoder to another (mostly AVC to HEVC), it is 100% reproducible with a minimal ExoPlayer integration:

W/MediaCodecRenderer: Failed to initialize decoder: OMX.qcom.video.decoder.hevc.secure
      java.lang.IllegalArgumentException
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:2149)
        at android.media.MediaCodec.configure(MediaCodec.java:2061)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:50)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1137)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1044)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:2158)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.processEndOfStream(MediaCodecRenderer.java:2033)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1866)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:843)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:257)
        at android.os.HandlerThread.run(HandlerThread.java:67)
2021-08-03 17:09:03.789 31036-31064/tv.xxxx.exoplayeradaptivetrackselectiontest E/ExoPlayerImplInternal: Playback error
      com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(3518, null, null, video/hevc, hvc1.1.2.L123, 4800000, null, [1920, 1080, 50.0], [-1, -1]), format_supported=YES
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:555)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:257)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.hevc.secure, Format(3518, null, null, video/hevc, hvc1.1.2.L123, 4800000, null, [1920, 1080, 50.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1051)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:2158)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.processEndOfStream(MediaCodecRenderer.java:2033)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1866)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:843)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:257) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
     Caused by: java.lang.IllegalArgumentException
        at android.media.MediaCodec.native_configure(Native Method)
        at android.media.MediaCodec.configure(MediaCodec.java:2149)
        at android.media.MediaCodec.configure(MediaCodec.java:2061)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:50)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1137)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1044)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:606) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:2158) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.processEndOfStream(MediaCodecRenderer.java:2033) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1866) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:843) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:257) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 

According to Firebase Crashlytics where we upload our reports, this issue happens on Xiaomi, OnePlus, OPPO, Samsung and some other brands. It seems to be related to Qualcomm (OMX.qcom.video.decoder.hevc.secure) and Mediatek (OMX.MTK.VIDEO.DECODER.HEVC.secure) decoders.

Here is an overview of available video tracks in a DASH manifest:

MediaCodecVideoRenderer [
  Group:0, adaptive_supported=YES_NOT_SEAMLESS [
    [X] Track:0, id=379, mimeType=video/avc, bitrate=400000, codecs=avc1.64000d, drm=[widevine,cenc], res=384x216, fps=25.0, supported=YES
    [X] Track:1, id=380, mimeType=video/avc, bitrate=800000, codecs=avc1.64001e, drm=[widevine,cenc], res=640x360, fps=25.0, supported=YES
    [X] Track:2, id=381, mimeType=video/avc, bitrate=1600000, codecs=avc1.64001f, drm=[widevine,cenc], res=896x504, fps=25.0, supported=YES
    [X] Track:3, id=3517, mimeType=video/hevc, bitrate=1600000, codecs=hvc1.1.2.L93, drm=[widevine,cenc], res=896x504, fps=50.0, supported=YES
    [X] Track:4, id=382, mimeType=video/avc, bitrate=3000000, codecs=avc1.64001f, drm=[widevine,cenc], res=1280x720, fps=25.0, supported=YES
    [X] Track:5, id=3518, mimeType=video/hevc, bitrate=4800000, codecs=hvc1.1.2.L123, drm=[widevine,cenc], res=1920x1080, fps=50.0, supported=YES
    [X] Track:6, id=3519, mimeType=video/hevc, bitrate=14800000, codecs=hvc1.1.2.L123, drm=[widevine,cenc], res=1920x1080, fps=50.0, supported=YES
  ]
]

I'll give you the app sample private GitHub repo URL and necessary access token by email.

@cdongieux
Copy link
Author

And here is a logcat showing the sample app launch followed by the DecoderInitializationException when switching from AVC to HEVC
logcat_oppo_CPH2089.txt

Note the E/SurfaceUtils: native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection before the error.

@icbaker
Copy link
Collaborator

icbaker commented Aug 3, 2021

These lines in the logcat suggests to me this is a duplicate/same root cause as:

2021-08-03 18:02:58.410 5821-5937/tv.xxxx.exoplayeradaptivetrackselectiontest E/SurfaceUtils: Failed to connect to surface 0xb4000070ee197010, err -22
2021-08-03 18:02:58.410 5821-5937/tv.xxxx.exoplayeradaptivetrackselectiontest E/MediaCodec: nativeWindowConnect returned an error: Invalid argument (-22)
2021-08-03 18:02:58.410 5821-5857/tv.xxxx.exoplayeradaptivetrackselectiontest E/MediaCodec: configure failed with err 0xffffffea, resetting...

@cdongieux
Copy link
Author

I'm not sure, because in my case there is a switch between 2 DRM-protected video tracks, there a no clear content involved.

@icbaker
Copy link
Collaborator

icbaker commented Aug 4, 2021

I suspect #8696 just has an incomplete/imprecise title, and that the problem is really related to switching away from a secure decoder (so it occurs both when switching from a secure to a clear decoder and from one secure decoder to another different one).

I'm going to close this as a duplicate and update the title of #8696.

@icbaker
Copy link
Collaborator

icbaker commented Aug 4, 2021

According to Firebase Crashlytics where we upload our reports, this issue happens on Xiaomi, OnePlus, OPPO, Samsung and some other brands. It seems to be related to Qualcomm (OMX.qcom.video.decoder.hevc.secure) and Mediatek (OMX.MTK.VIDEO.DECODER.HEVC.secure) decoders.

Quick question: When I repro'd #8696 using a OnePlus AC2003 I didn't see any problems on Android 10 but immediately repro'd on Android 11. Does your crash analytics suggest this problem happens only (or much more frequently) on Android 11 than Android 10?

@cdongieux
Copy link
Author

93% on Android 11, 5% on Android 10.

@cdongieux
Copy link
Author

cdongieux commented Aug 4, 2021

Note that on #8696 a trick was to use setDrmSessionForClearPeriods(true) but in my case it does not work as content is protected, so I have no workaround for this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants