androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.71k stars 409 forks source link

DRM & ClearKey 1.4.X Unexpected runtime error #1732

Closed KingLucius closed 3 weeks ago

KingLucius commented 2 months ago

Version

Media3 1.4.0

More version details

From 1.4.0 and up has this issue, downgrading to 1.3.1 fixes it

Devices that reproduce the issue

Amazon FireTV Stick 4K (Mantis)

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

I can provide sample ClearKey link in private to test

Expected result

Media working like in 1.3.1

Actual result

09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal: Playback error
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:   androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:720)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at android.os.Handler.dispatchMessage(Handler.java:98)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at android.os.Looper.loop(Looper.java:154)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at android.os.HandlerThread.run(HandlerThread.java:61)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:   Caused by: android.media.MediaCodec$CryptoException: Operation not supported in this configuration
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2584)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.dequeueOutputBufferIndex(SynchronousMediaCodecAdapter.java:108)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1994)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:873)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.render(MediaCodecVideoRenderer.java:1018)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1136)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:561)
09-13 07:39:36.096 18108 18297 E ExoPlayerImplInternal:       ... 3 more
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal: Disable failed.
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:   android.media.MediaCodec$CryptoException: Operation not supported in this configuration
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at android.media.MediaCodec.native_flush(Native Method)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at android.media.MediaCodec.flush(MediaCodec.java:2068)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:168)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:960)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:953)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:780)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.video.MediaCodecVideoRenderer.onDisabled(MediaCodecVideoRenderer.java:794)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.BaseRenderer.disable(BaseRenderer.java:220)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1846)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1566)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1523)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:722)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at android.os.Handler.dispatchMessage(Handler.java:98)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at android.os.Looper.loop(Looper.java:154)
09-13 07:39:36.097 18108 18297 E ExoPlayerImplInternal:       at android.os.HandlerThread.run(HandlerThread.java:61)

Media

Will send to android-media-github@google.com

Bug Report

icbaker commented 2 months ago

We didn't receive this. Please re-send it with subject Issue #1732. Thanks!

KingLucius commented 1 month ago

We didn't receive this. Please re-send it with subject Issue #1732. Thanks!

Done

icbaker commented 1 month ago

The email contains a logcat snippet, not the zip file produced by adb bugreport. The full bugreport often contains additional info which can help to understand issues. Please run adb bugreport after reproducing the issue, and email us the resulting zip file, then update this issue.

KingLucius commented 1 month ago

The email contains a logcat snippet, not the zip file produced by adb bugreport. The full bugreport often contains additional info which can help to understand issues. Please run adb bugreport after reproducing the issue, and email us the resulting zip file, then update this issue.

Updated the email with adb bugreport zip file result

icbaker commented 1 month ago

Thanks - please can you add an EventLogger (https://developer.android.com/media/media3/exoplayer/debug-logging) and reproduce and take a new BR.

Please can you also provide a BR of a successful playback using 1.3.1, so we can understand what might be behaving differently.

KingLucius commented 1 month ago

Thanks - please can you add an EventLogger (https://developer.android.com/media/media3/exoplayer/debug-logging) and reproduce and take a new BR.

Please can you also provide a BR of a successful playback using 1.3.1, so we can understand what might be behaving differently.

Updated, please check

icbaker commented 1 month ago

Thanks - I can't see any EventLogger output in the BR, so I'm not sure if you added it correctly (you need to add a line like player.addAnalyticsListener(new EventLogger())).

However I can see a difference between the two BRs without this, that I suspect is responsible for the error you're seeing.

At 1.3.1 we are instantiating an "insecure" (i.e. not HW-secure) video decoder:

OMXMaster: makeComponentInstance(OMX.MTK.VIDEO.DECODER.AVC) in mediacodec process

At 1.4.0 we are instantiating a HW-secure one (note the .secure suffix):

OMXMaster: makeComponentInstance(OMX.MTK.VIDEO.DECODER.AVC.secure) in mediacodec process

ClearKey doesn't support HW-secure playback.

At a guess, I suspect the change in behaviour might have been introduced by https://github.com/androidx/media/commit/c872af4bc00608be70b74a2f61078e5d65ed8322 where we switched from using MediaCrypto.requiresSecureDecoderComponent(String) to MediaDrm.requiresSecureDecoder(String).

We made a related follow-up fix/workaround that was included in 1.4.1 where MediaDrm.requiresSecureDecoder(String) was returning false when it should have been returning true (and MediaCrypto.requiresSecureDecoderComponent(String) was returning true): https://github.com/androidx/media/commit/b184677b7b50652ea9a97d1504c80f171143d7d9 (and then a follow-up fix to this for an edge-case that will be in 1.5.0-beta01: https://github.com/androidx/media/commit/0b86f8949865ed685ff1aad89962867b5629ee8d).

In your case, my hypothesis would suggest that MediaDrm.requiresSecureDecoder(String) is incorrectly returning true while MediaCrypto.requiresSecureDecoderComponent(String) is returning false. Would you be able to test this hypothesis?

If you have a local dependency on ExoPlayer this is quite easy, because you can just add some logging here in MediaCodecRenderer:

https://github.com/androidx/media/blob/be4d31ba87d240e76f7a34458073a124d61bfeff/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecRenderer.java#L579-L584

Something like:

if (codecDrmSession != null 
    && (codecDrmSession.getState() == DrmSession.STATE_OPENED
        || codecDrmSession.getState() == DrmSession.STATE_OPENED_WITH_KEYS)) {
  Log.w(
    "issue-1732",
    "drmSession.requiresSecureDecoder()="
        + codecDrmSession.requiresSecureDecoder(checkStateNotNull(inputFormat.sampleMimeType));
}
if (mediaCrypto != null) {
  Log.w(
    "issue-1732",
    "mediaCrypto.requiresSecureDecoderComponent()="
        + mediaCrypto.requiresSecureDecoderComponent(checkStateNotNull(mimeType));
}
google-oss-bot commented 1 month ago

Hey @KingLucius. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 3 weeks ago

Since there haven't been any recent updates here, I am going to close this issue.

@KingLucius if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.