Commit bcaadf43 by ibaker Committed by Oliver Woodman

Remove checkState calls from DefaultDrmSession#acquire() and release()

Issue: #9392 reports occasional IllegalStateExceptions from release()
in crashlytics,`with no way to reproduce locally. It seems likely there
is a bug somewhere in DRM handling, and ideally we would find that and
fix it.

However we haven't been able to find the problem, and in the meantime
these exceptions cause the entire app to crash. Although this is
arguably useful from a debugging perspective, it's obviously a poor
experience for developers and users, since all we're actually trying to
do is release the session, so maybe we shouldn't strictly care that it's
already released?

This change replaces the exception with an error log, which might be a
useful debugging hint if we see other DRM unexpected behaviour due to
references to released sessions being held for too long.

PiperOrigin-RevId: 403942546
parent a242aa22
......@@ -28,6 +28,10 @@
* Fix bug in `MediaCodecVideoRenderer` that resulted in re-using a
released `Surface` when playing without an app-provided `Surface`
([#9476](https://github.com/google/ExoPlayer/issues/9476)).
* DRM:
* Log an error (instead of throwing `IllegalStateException`) when calling
`DefaultDrmSession#release()` on a fully released session
([#9392](https://github.com/google/ExoPlayer/issues/9392)).
* Android 12 compatibility:
* Keep `DownloadService` started and in the foreground whilst waiting for
requirements to be met on Android 12. This is necessary due to new
......
......@@ -296,7 +296,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override
public void acquire(@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher) {
checkState(referenceCount >= 0);
if (referenceCount < 0) {
Log.e(TAG, "Session reference count less than zero: " + referenceCount);
referenceCount = 0;
}
if (eventDispatcher != null) {
eventDispatchers.add(eventDispatcher);
}
......@@ -320,7 +323,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override
public void release(@Nullable DrmSessionEventListener.EventDispatcher eventDispatcher) {
checkState(referenceCount > 0);
if (referenceCount <= 0) {
Log.e(TAG, "release() called on a session that's already fully released.");
return;
}
if (--referenceCount == 0) {
// Assigning null to various non-null variables for clean-up.
state = STATE_RELEASED;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment