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.74k stars 416 forks source link

`Assertions.checkState` fails in `PlayerInfo$Builder.build()` #242

Open h6ah4i opened 1 year ago

h6ah4i commented 1 year ago

Media3 Version

1.0.0-beta03

Devices that reproduce the issue

Devices that do not reproduce the issue

I think this issue is not device-specific.

Reproducible in the demo app?

No

Reproduction steps

Sorry, I have not been able to reproduce it myself. I can see crash reports on the Crashlytics dashboard for this issue.

Expected result

The following assertion should not be failed.

Assertions.checkState(
    timeline.isEmpty()
        || sessionPositionInfo.positionInfo.mediaItemIndex < timeline.getWindowCount());

https://github.com/androidx/media/blob/1.0.0-beta03/libraries/session/src/main/java/androidx/media3/session/PlayerInfo.java#L311

Actual result

Occasionally, the following exception is raised and the app crashes.

Fatal Exception: java.lang.IllegalStateException:
       at androidx.media3.common.util.Assertions.checkState(Assertions.java:85)
       at androidx.media3.session.PlayerInfo$Builder.build(PlayerInfo.java:311)
       at androidx.media3.session.PlayerInfo.copyWithSessionPositionInfo(PlayerInfo.java:515)
       at androidx.media3.session.MediaControllerImplBase.updateSessionPositionInfoIfNeeded(MediaControllerImplBase.java:2621)
       at androidx.media3.session.MediaControllerImplBase.notifyPeriodicSessionPositionInfoChanged(MediaControllerImplBase.java:2240)
       at androidx.media3.session.MediaControllerStub.lambda$onPeriodicSessionPositionInfoChanged$6(MediaControllerStub.java:169)
       at androidx.media3.session.MediaControllerStub$$ExternalSyntheticLambda10.run(:2)
       at androidx.media3.session.MediaControllerStub.lambda$dispatchControllerTaskOnHandler$11(MediaControllerStub.java:278)
       at androidx.media3.session.MediaControllerStub$$ExternalSyntheticLambda11.run(:4)
       at androidx.media3.common.util.Util.postOrRun(Util.java:627)
       at androidx.media3.session.MediaControllerStub.dispatchControllerTaskOnHandler(MediaControllerStub.java:270)
       at androidx.media3.session.MediaControllerStub.onPeriodicSessionPositionInfoChanged(MediaControllerStub.java:168)
       at androidx.media3.session.MediaSessionStub$Controller2Cb.onPeriodicSessionPositionInfoChanged(MediaSessionStub.java:1665)
       at androidx.media3.session.MediaSessionImpl.lambda$notifyPeriodicSessionPositionInfoChangesOnHandler$10(MediaSessionImpl.java:714)
       at androidx.media3.session.MediaSessionImpl$$ExternalSyntheticLambda0.run(:2)
       at androidx.media3.session.MediaSessionImpl.dispatchRemoteControllerTaskWithoutReturn(MediaSessionImpl.java:627)
       at androidx.media3.session.MediaSessionImpl.dispatchRemoteControllerTaskWithoutReturn(MediaSessionImpl.java:600)
       at androidx.media3.session.MediaSessionImpl.notifyPeriodicSessionPositionInfoChangesOnHandler(MediaSessionImpl.java:713)
       at androidx.media3.session.MediaSessionImpl.$r8$lambda$zYsdAycGCkw3-ZeAd9qvGjw1w-M()
       at androidx.media3.session.MediaSessionImpl$$ExternalSyntheticLambda3.run(:2)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7872)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

NOTE: I am using a slightly modified version of 1.0.0-beta03. I have added some debug logging code to the library, so the line numbers in the stack traces are not identical to the original 1.0.0-beta03.

Media

n/a

Bug Report

henryglendening-hh commented 7 months ago

I'm seeing this exception occur occasionally in my crash reports. Is there any idea what's causing it?

For reference, I'm on version 1.3.0