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 crashing while trying to release DefaultDrmSession (Assertions.checkState) #9193

Closed
saurabharora90 opened this issue Jul 15, 2021 · 4 comments
Assignees
Labels

Comments

@saurabharora90
Copy link

saurabharora90 commented Jul 15, 2021

A small percentage of our users are facing crashes within Exoplayer 2.13.3

Stacktrace:

Fatal Exception: java.lang.IllegalStateException
       at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:86)
       at com.google.android.exoplayer2.drm.DefaultDrmSession.release(DefaultDrmSession.java:307)
       at com.google.android.exoplayer2.drm.DefaultDrmSessionManager$ReferenceCountListenerImpl.lambda$onReferenceCountDecremented$0(DefaultDrmSessionManager.java:795)
       at com.google.android.exoplayer2.drm.-$$Lambda$DefaultDrmSessionManager$ReferenceCountListenerImpl$lohQXhovvcCpLXYZ8GSk9gsNCn8.run(-.java:2)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:193)
       at android.os.HandlerThread.run(HandlerThread.java:65)

I am trying to understand if there is something we aren't handling properly with the DRM Session Manager?

This is how we create the session manager:

DefaultDrmSessionManager.Builder()
        .setUseDrmSessionsForClearContent(C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO)
       //additional configuration omitted for brevity 
        .build(
            HttpMediaDrmCallback(
                licenseUrl,
                dataSourceFactory
            )
        )


DashMediaSource.Factory(dataSourceFactory)
        .setDrmSessionManager(drmSessionManager)
        .createMediaSource(mediaItem)
@saurabharora90 saurabharora90 changed the title ExoPlayer crashing while trying to release DefaultDrmSession (Assertions.checkState) ExoPlayer crashing while trying to release DefaultDrmSession (Assertions.checkState) Jul 15, 2021
@icbaker icbaker self-assigned this Jul 16, 2021
@icbaker
Copy link
Collaborator

icbaker commented Jul 16, 2021

Thanks for the report - I think there's a bug in the way DefaultDrmSessionManager releases it's internal 'keep-alive' references when it's released.

Specifically if the manager is released while there's still at least one active 'external' session reference the manager will incorrectly release both references (one of the release calls will be delayed by sessionKeepaliveMs, defaults to 5mins). If this races against the external reference being explicitly released (which it should be) then you'll see the stack trace you've included because the session sees 'too many' release calls.

I'll send a fix.


One question:

A small percentage of our users are facing crashes within Exoplayer 2.13.3

Is this causing playback problems or app crashes, or is it just visible in the logs?

icbaker added a commit that referenced this issue Jul 20, 2021
Before this fix, if DefaultDrmSessionManager.release() was called while
there was at least one 'external' session reference still active (i.e.
session.referenceCount > 1) then the manager will release it's reference
immediately but when the session's reference count subsequently drops to
1 (due to external references being released) the manager will schedule
a task to release its internal reference *again*.

This change fixes the problem by only scheduling the timed release if
the manager is unreleased. This ensures that the internal references
are only released once.

Issue: #9193

#minor-release

PiperOrigin-RevId: 385580741
@icbaker icbaker closed this as completed Jul 21, 2021
@saurabharora90
Copy link
Author

Is this causing playback problems or app crashes, or is it just visible in the logs?

Sorry missed the question. Guess it was an edit.

It is causing app crashes.

icbaker added a commit that referenced this issue Jul 21, 2021
Before this fix, if DefaultDrmSessionManager.release() was called while
there was at least one 'external' session reference still active (i.e.
session.referenceCount > 1) then the manager will release it's reference
immediately but when the session's reference count subsequently drops to
1 (due to external references being released) the manager will schedule
a task to release its internal reference *again*.

This change fixes the problem by only scheduling the timed release if
the manager is unreleased. This ensures that the internal references
are only released once.

Issue: #9193

PiperOrigin-RevId: 385580741
@fpitters
Copy link

fpitters commented Sep 6, 2021

Probably not related. We are seeing a weird crash after bumping to 2.14.2 (from 2.13.2) with a close stacktrace

Fatal Exception: java.lang.IllegalStateException
       at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:84)
       at com.google.android.exoplayer2.drm.DefaultDrmSession.release(DefaultDrmSession.java:308)
       at com.google.android.exoplayer2.drm.DefaultDrmSessionManager$PreacquiredSessionReference.lambda$release$1(DefaultDrmSessionManager.java:1015)
       at com.google.android.exoplayer2.drm.DefaultDrmSessionManager$PreacquiredSessionReference.lambda$release$1$DefaultDrmSessionManager$PreacquiredSessionReference(DefaultDrmSessionManager.java:3)
       at com.google.android.exoplayer2.drm.-$$Lambda$DefaultDrmSessionManager$PreacquiredSessionReference$nYc-XCZkgUmlTVMJKF9VQKrj-NU.run(-.java:3)
       at android.os.Handler.handleCallback(Handler.java:761)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:156)
       at android.os.HandlerThread.run(HandlerThread.java:61)

The incidence is low, few ~5 out of 25K a day and not device specific, happening across all brands. Although Huawei devices have 40% of the share.

Let me know if you have any comment or insight.

@icbaker
Copy link
Collaborator

icbaker commented Sep 6, 2021

@fpitters Can you please file a new issue?

@google google locked and limited conversation to collaborators Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants