media icon indicating copy to clipboard operation
media copied to clipboard

llegalArgumentException error in PlaybackStatsListener

Open bernhardpflug opened this issue 1 year ago • 0 comments

Version

Media3 1.2.1

More version details

We added the PlaybackStatsListener in our streaming application with several thousand stream playbacks per day. On around 100 sessions per day we get this Exception

Fatal Exception: java.lang.IllegalArgumentException
androidx.media3.common.util.Assertions.checkArgument (Assertions.java:40)
androidx.media3.exoplayer.analytics.PlaybackStatsListener$PlaybackStatsTracker.updatePlaybackState (PlaybackStatsListener.java:660)
androidx.media3.exoplayer.analytics.PlaybackStatsListener$PlaybackStatsTracker.onEvents (PlaybackStatsListener.java:579)
androidx.media3.exoplayer.analytics.PlaybackStatsListener.onEvents (PlaybackStatsListener.java:271)
androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector.lambda$setPlayer$1 (DefaultAnalyticsCollector.java:137)
androidx.media3.common.util.ListenerSet$ListenerHolder.iterationFinished (ListenerSet.java:348)
androidx.media3.common.util.ListenerSet.handleMessage (ListenerSet.java:293)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:211)
android.app.ActivityThread.main (ActivityThread.java:6775)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)

Similar to being reported from someone here: https://github.com/google/ExoPlayer/issues/11263

After catching it and adding some logs we see that in these cases the public void onEvents(Player player, Events events) seems to fire two subsequent events in a non-chronological order, pls find some example Crashlytics logs attached.

In the last log statements you can always see the called method within PlaybackStatsListener with the playback state, the currentPlaybackStateStartTimeMs that is set at that time and the event timestamp. There are always two events happening within 500ms that seems to get mixed up, often a BUFFERING and an ENDED event.

According to this issue we also checked and can confirm that we are releasing the listener before releasing exoplayer.

de.exaring.waipu.firetv.live_issue_c22fc93d75ceea13d7ae4952290effea_error_session_65D7AF0903470001565F472435E0CA28_DNE_1_v2.log de.exaring.waipu.firetv.live_issue_c22fc93d75ceea13d7ae4952290effea_error_session_65D7B45D00C0000148BE9C5E1DEA7CE7_DNE_3_v2.log de.exaring.waipu.firetv.live_issue_c22fc93d75ceea13d7ae4952290effea_error_session_65D787E1030F00013047C14C92037CE9_DNE_1_v2.log de.exaring.waipu.firetv.live_issue_c22fc93d75ceea13d7ae4952290effea_error_session_65D6417200D7000176B6511F83882447_DNE_3_v2.log

Devices that reproduce the issue

Numerous Android TV and FireTV devices across multiple Android versions

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Unable to reproduce it on our test devices, seems to happen only in around 0,1% our sessions

Expected result

Dealing with non-chronological events in PlaybackStatsListener implementation

Actual result

Fatal Exception: java.lang.IllegalArgumentException androidx.media3.common.util.Assertions.checkArgument (Assertions.java:40) androidx.media3.exoplayer.analytics.PlaybackStatsListener$PlaybackStatsTracker.updatePlaybackState (PlaybackStatsListener.java:660) androidx.media3.exoplayer.analytics.PlaybackStatsListener$PlaybackStatsTracker.onEvents (PlaybackStatsListener.java:579) androidx.media3.exoplayer.analytics.PlaybackStatsListener.onEvents (PlaybackStatsListener.java:271) androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector.lambda$setPlayer$1 (DefaultAnalyticsCollector.java:137) androidx.media3.common.util.ListenerSet$ListenerHolder.iterationFinished (ListenerSet.java:348) androidx.media3.common.util.ListenerSet.handleMessage (ListenerSet.java:293) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop (Looper.java:211) android.app.ActivityThread.main (ActivityThread.java:6775) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)

Media

non

Bug Report

  • [ ] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

bernhardpflug avatar Feb 26 '24 14:02 bernhardpflug