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

ExoPlayer crashes on DRM protected contents with IMA ads #9617

Closed
baiqindotfubotv opened this issue Oct 27, 2021 · 4 comments
Closed

ExoPlayer crashes on DRM protected contents with IMA ads #9617

baiqindotfubotv opened this issue Oct 27, 2021 · 4 comments

Comments

@baiqindotfubotv
Copy link

This crash is 100% reproducible with DRM protected contents with IMA ads. Right now it only happens on my Pixel 2XL android 11. I also found a way to reproduce with ExoPlayer demo app:

(1) Check out to r2.15.0
(2) Add a sample to media.exolist.json:

{
        "name": "HD (cenc)",
        "uri": "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd",
        "drm_scheme": "widevine",
        "drm_license_uri": "https://proxy.uat.widevine.com/proxy?provider=widevine_test",
        "ad_tag_uri": "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpost&cmsid=496&vid=short_onecue&correlator="
}

(3) Open that sample from demo app, wait for preroll to finish, the playback will crash after 15 seconds.

Crash log:

     com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(2, null, null, video/avc, avc1.42801F, -1, null, [1280, 720, 30.0], [-1, -1]), format_supported=YES
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:558)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:223)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(2, null, null, video/avc, avc1.42801F, -1, null, [1280, 720, 30.0], [-1, -1])
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1034)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:585)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:2139)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.processEndOfStream(MediaCodecRenderer.java:2014)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1847)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:823)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:978)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:482)
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:223) 
        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:2127)
        at android.media.MediaCodec.configure(MediaCodec.java:2043)
        at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:50)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1121)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1027)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:585) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:2139) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.processEndOfStream(MediaCodecRenderer.java:2014) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1847) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:823) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:978) 
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:482) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
@icbaker
Copy link
Collaborator

icbaker commented Oct 28, 2021

This sounds like a duplicate of #8696 but there isn't quite enough information in the provided logcat snippet to be sure.

Can you either provide a full adb bugreport or look for the following output in logcat:

E/SurfaceUtils: Failed to connect to surface 0x71e621ca70, err -22
E/MediaCodec: nativeWindowConnect returned an error: Invalid argument (-22)

If it is a duplicate of that issue then you may be able to fix the problem using MediaItem.Builder#setDrmSessionForClearPeriods(true), but it won't work in all cases (see #8696 for more details). There are some other possible (more invasive) workarounds detailed in #8696 (comment).

@baiqindotfubotv
Copy link
Author

baiqindotfubotv commented Oct 28, 2021

@icbaker Yes I see the following error before the stacktrace:

2021-10-28 08:22:10.343 14914-17678/com.google.android.exoplayer2.demo E/SurfaceUtils: native window cannot handle protected buffers: the consumer should either be a hardware composer or support hardware protection
2021-10-28 08:22:10.365 14914-17833/com.google.android.exoplayer2.demo E/SurfaceUtils: Failed to connect to surface 0x77b78de140, err -22
2021-10-28 08:22:10.365 14914-17833/com.google.android.exoplayer2.demo E/MediaCodec: nativeWindowConnect returned an error: Invalid argument (-22)
2021-10-28 08:22:10.365 14914-17663/com.google.android.exoplayer2.demo E/MediaCodec: configure failed with err 0xffffffea, resetting...
2021-10-28 08:22:10.385 14914-17663/com.google.android.exoplayer2.demo E/MediaCodecVideoRenderer: Video codec error

Also using setDrmSessionForClearPeriods(true) doesn't solve the issue. The difference is that without the option the crash happens right before the first midroll. With it the crash happens right after preroll.

@icbaker
Copy link
Collaborator

icbaker commented Oct 28, 2021

Also using setDrmSessionForClearPeriods(true) doesn't solve the issue. The difference is that without the option the crash happens right before the first midroll. With it the crash happens right after preroll.

This is likely because the ad has different decoder requirements to the content, so the decoder has to be re-initialized when transitioning from the pre-roll to the content, even though both are secure decoders: #8696 (comment)

@icbaker
Copy link
Collaborator

icbaker commented Oct 28, 2021

Duplicate of #8696.

@icbaker icbaker closed this as completed Oct 28, 2021
@google google locked and limited conversation to collaborators Dec 28, 2021
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

3 participants