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

Decoder init failed error when transitioning from DRM protected content to clear content in a playlist #9095

Closed
strangesource opened this issue Jun 22, 2021 · 5 comments
Assignees

Comments

@strangesource
Copy link

Description:

The following exception occurs when transitioning from a DRM protected media item to a clear media item in a playlist:

2021-06-22 07:55:07.634 28518-28518/com.google.android.exoplayer2.demo E/EventLogger: playerFailed [eventTime=8.62, mediaPos=0.00, window=1, period=1
      com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(4, null, null, video/avc, avc1.64002A, 18316946, null, [1920, 856, 24.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:245)
        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(4, null, null, video/avc, avc1.64002A, 18316946, null, [1920, 856, 24.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.drainAndReinitializeCodec(MediaCodecRenderer.java:1818)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1480)
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:713)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:998)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:830)
        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:245) 
        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:2128)
        at android.media.MediaCodec.configure(MediaCodec.java:2044)
        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.drainAndReinitializeCodec(MediaCodecRenderer.java:1818) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1480) 
        at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:713) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:998) 
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:830) 
        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:245) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
    ]

This can only be observed on specific devices. I reliably reproduced it on a OnePlus AC2003 with Android 11 but customers of us reported it also on Samsung S10 with Android 11.

Please find the adb bugreport attached.

Steps to reproduce:

In the demo app define one DRM protected source and one clear source in a play list, e.g. as follows:

 List<MediaItem> mediaItems = new ArrayList<>();
      MediaItem.Builder builderProtectedItem =
              new MediaItem.Builder()
                      .setUri("https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd")
                      .setMimeType(MimeTypes.APPLICATION_MPD)
                      .setMediaMetadata(new MediaMetadata.Builder().setTitle("DRM protected").build())
              .setDrmUuid(C.WIDEVINE_UUID)
              .setDrmLicenseUri("https://proxy.uat.widevine.com/proxy?provider=widevine_test");

      mediaItems.add(builderProtectedItem.build());

      MediaItem.Builder builderClearItem =
              new MediaItem.Builder()
                      .setUri("https://storage.googleapis.com/wvmedia/clear/h264/tears/tears.mpd")
                      .setMimeType(MimeTypes.APPLICATION_MPD)
                      .setMediaMetadata(new MediaMetadata.Builder().setTitle("Clear Sample").build());

      mediaItems.add(builderClearItem.build());

After starting playback of the first source, transitioning to the next source causes the described issue.

Versions

  • ExoPlayer version number: 2.12.0, b2333c8
  • Android version: Android 11
  • Android device: OnePlus AC2003
@strangesource strangesource changed the title Decoder init failed error when transitioning from DRM protected content to clear content in a playlist Decoder init failed error when transitioning from DRM protected content to clear content in a playlist Jun 22, 2021
@icbaker icbaker self-assigned this Jun 22, 2021
@icbaker
Copy link
Collaborator

icbaker commented Jun 22, 2021

From the provided BR this looks like the same issue reported in #8696, in particular these lines:

06-22 08:24:11.323 10327  2291  9600 D SurfaceUtils: connecting to surface 0x76ca3f3ed0, reason connectToSurface
06-22 08:24:11.323  1000   969  3208 E BufferQueueProducer: [SurfaceView - com.google.android.exoplayer2.demo/com.google.android.exoplayer2.demo.PlayerActivity#0](id:3c90000000f,api:3,p:2291,c:969) connect: already connected (cur=3 req=3)
06-22 08:24:11.325 10327  2291  9600 E SurfaceUtils: Failed to connect to surface 0x76ca3f3ed0, err -22
06-22 08:24:11.325 10327  2291  9600 E MediaCodec: nativeWindowConnect returned an error: Invalid argument (-22)
06-22 08:24:11.325 10327  2291  8965 E MediaCodec: configure failed with err 0xffffffea, resetting...

The reporter there confirmed the following workaround works (providing the secure decoder is capable of decoding the clear content):

Additionally, calling setDrmSessionForClearPeriods(true) on the MediaItem does resolve the error. But raises the question of what other issues this will potentially cause.

I will dupe this to that issue and follow up on that thread.

@strangesource
Copy link
Author

Thanks for your response @icbaker.
setDrmSessionForClearPeriods does not work out of the box as the two MediaItems use a different DrmSessionManager. When reusing the DrmSessionManager for the clear source it does work.

@icbaker
Copy link
Collaborator

icbaker commented Jun 22, 2021

FYI DrmSessionManager instances are re-used more often after 2.13.1 (release notes):

  • Re-use the previous DrmSessionManager instance when playing a playlist (if possible)

@strangesource
Copy link
Author

strangesource commented Jun 22, 2021

I did see that release note but I don't think this helps here as the MediaItem is clear and there is no reason to actually use a DrmSessionManager at all. 🤔 But maybe I am missing something. (It did not work when quickly testing it in release-v2)

Edit: It does work when I configure both sources as DRM protected. Maybe that was the missing piece.

@icbaker
Copy link
Collaborator

icbaker commented Jun 22, 2021

Edit: It does work when I configure both sources as DRM protected. Maybe that was the missing piece.

Ah yeah, that's also a slightly sharp edge of the API: #8957

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