AndroidTV - DASH/Widevine - Unable to use 2 video decoders simultaneously on some recent devices - "MediaCodec$CryptoException: Operation not supported in this configuration"
See original GitHub issueHi,
There is a new issue spreading on some devices since this summer:
- Sony Bravia KD-75X85J AndroidTV 10
Build.DEVICE = BRAVIA_VH2
- Sony Bravia XBR-65X900H AndroidTV 10
Build.DEVICE = BRAVIA_VH1
- Hisense 65U8G AndroidTV 10 (detected this week)
I am using the latest exoplayer version: 2.16.0 While looking for regressions in my project, I went all the way back to exoplayer 2.9.6 and still had the bug.
I also found a workaround that I will explain.
Search existing issues, including issues that are closed:
(Issues with the same error but different problem)
- https://github.com/google/ExoPlayer/issues/4487
- https://github.com/google/ExoPlayer/issues/4101
- https://github.com/google/ExoPlayer/issues/8037
Clear reproduction steps including observed and expected behavior
- The main player is playing a DASH H264 Widevine stream in 720p or 1080p on a
SurfaceView
. This player uses the first secure hardware decoder of the device. - On top of the main player We start a PIP, DASH H264 Widevine 360p on a
TextureView
, audio disabled. This player uses the first non-secure decoder available. - Actual result: The PIP starts and plays, but the main player stops playing and throws a
MediaCodecVideoRenderer error
caused by:android.media.MediaCodec$CryptoException: Operation not supported in this configuration
(more details in logcat files) Expected result: Same as all other devices: Show the PIP and keep playing the main player.
// Error in the main player (which was playing correctly before starting the PIP)
11-11 21:02:18.205 10043 10959 D PlayerCodecSelector: video/avc -> [OMX.MTK.VIDEO.DECODER.AVC.secure]
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: Playback error
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(2, null, null, video/avc, avc1.4D4020, 2499968, null, [960, 540, 59.94006], [-1, -1]), format_supported=YES
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:558)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:103)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:214)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:67)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: Caused by: android.media.MediaCodec$CryptoException: Operation not supported in this configuration
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at android.media.MediaCodec.native_queueSecureInputBuffer(Native Method)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at android.media.MediaCodec.queueSecureInputBuffer(MediaCodec.java:2706)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.queueSecureInputBuffer(SynchronousMediaCodecAdapter.java:148)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1367)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:825)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:978)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:482)
11-11 21:02:18.209 10043 10959 E ExoPlayerImplInternal: ... 3 more
I am sending adb logcats with a lot more information at dev.exoplayer@gmail.com
- It is surprising to see the main player failing instead of the PIP which is the one trying to initialize. Having the error in the PIP would have been better for handling.
- During my troubleshooting on
BRAVIA_VH1
I also tried to force the second non-secure decoderc2.android.avc.decoder
instead of the defaultOMX.MTK.VIDEO.DECODER.AVC
. But still got the same outcome. - So far, since August we received complains only on the 3 devices I mentionned, the Hisense was reported this week, before that I thought it was Bravia specific (not all Bravias). Those devices all have great specs. They all run Android 10, but I doubt it is the reason.
- I can confirm the issue does not happen on all the other devices I tested:
Broadcom AOSP STB, Google ADT-3 (Android 11), Google TV chromecast, Many Nvidia Shields, FireTV 4K, FireTV Gen 2, many Bravia (not VH1 and VH2)
. - It seems related to the Widevine CDM or Android revision. FireTV 4K uses same decoders than BRAVIA_VH1 and does not have the bug. Decoder:
OMX.MTK.VIDEO.DECODER.AVC.secure
- I noticed on most other Bravias the second software decoder is
OMX.google.h264.decoder
but VH1 and VH2 havec2.android.avc.decoder
instead. (I could not verify on the customer’s HiSense if it is the same)
Workaround
The workaround was to force Widevine L3 on the PIP.
I would prefer to avoid it, it creates bugs on other devices. I am explaining it here only because I think it can help troubleshooting.
Operation not supported in this configuration
seems related to the Device unable to play widevine L1
, but I know for sure L1
works in the main player and we are not expecting to use L1
in the PIP. So I though maybe the system has a bug where it is not able to select L3
for the PreviewPlayer (as expected)…
Initially, the MainPlayer and PreviewPlayer (PIP) were each using a simple DrmSessionManager (1 instance each):
DefaultDrmSessionManager.Builder().build(delegatedDrmCallback)
- I kept it for the MainPlayer
- And for the PreviewPlayer, inside the
DefaultDrmSessionManger.Builder
I forced WidevineL3
with in thesecurityLevel
property. - Now we get the expected behavior: both players can play simultaneously. I got confirmation on
BRAVIA_VH1
andBRAVIA_VH2
. But unfortunately on most of all the other devices it creates a ~1 second video/audio freeze in the MainPlayer while initializing the PIP… So the workaround has to be conditionnal to a specific list of devices. Not ideal… it will not handle unknown and new devices.
There is a probability that more devices will be affected with upcoming OS updates.
If I missed something, if you have a fix or better workaround please let me know. Even if it is a manufacturer/exoplayer/widevine issue I have to come up with a solution/workaround for my product. Any help would be appreciated. Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
FYI
OMX.google.h264.decoder
is an alias forc2.android.avc.decoder
, so it’s not surprising they’re showing the same behaviour. Fromadb shell dumpsys media.player
on a Pixel 5:Thanks for the detailed report. @rrfrias may I ask to look into this?