ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

PlaybackStatsListener causes crash

Open indieboyalex opened this issue 5 years ago • 12 comments

ExoPlayer 2.13.2

Upgrading from ExoPlayer 2.12.3 -> 2.13.2 I'm finding that everything works fine, but when I close my PlayerActivity my app is crashing. The error we get is:

java.lang.IllegalArgumentException
        at com.google.android.exoplayer2.util.Assertions.checkArgument(Assertions.java:41)
        at com.google.android.exoplayer2.analytics.PlaybackStatsListener$PlaybackStatsTracker.updatePlaybackState(PlaybackStatsListener.java:679)
        at com.google.android.exoplayer2.analytics.PlaybackStatsListener$PlaybackStatsTracker.onFinished(PlaybackStatsListener.java:477)
        at com.google.android.exoplayer2.analytics.PlaybackStatsListener.onSessionFinished(PlaybackStatsListener.java:183)
        at com.google.android.exoplayer2.analytics.DefaultPlaybackSessionManager.finishAllSessions(DefaultPlaybackSessionManager.java:247)
        at com.google.android.exoplayer2.analytics.PlaybackStatsListener.onEvents(PlaybackStatsListener.java:291)
        at com.google.android.exoplayer2.analytics.AnalyticsCollector.lambda$setPlayer$1$AnalyticsCollector(AnalyticsCollector.java:141)
        at com.google.android.exoplayer2.analytics.-$$Lambda$AnalyticsCollector$yS3z67Oa1f_t9PmuRvwn2pyVDcQ.invoke(Unknown Source:8)
        at com.google.android.exoplayer2.util.ListenerSet$ListenerHolder.release(ListenerSet.java:287)
        at com.google.android.exoplayer2.util.ListenerSet.release(ListenerSet.java:230)
        at com.google.android.exoplayer2.util.ListenerSet.handleMessage(ListenerSet.java:266)
        at com.google.android.exoplayer2.util.ListenerSet.lambda$eEvjP-IE0x3J2lRvKfFbbjRFRvc(Unknown Source:0)
        at com.google.android.exoplayer2.util.-$$Lambda$ListenerSet$eEvjP-IE0x3J2lRvKfFbbjRFRvc.handleMessage(Unknown Source:2)
        at android.os.Handler.dispatchMessage(Handler.java:108)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

I've noticed that in our code:

playerStatsListener = PlaybackStatsListener(false, null)
addAnalyticsListener(playerStatsListener!!)

if I simply comment out the addAnalyticsListener call then the crash does not happen.

Is this crash a new problem with PlaybackStatsListener, and is there a fix for it?

A secondary question would be, given that we're not using a callback with PSL, is there any drawback to simple not adding the listener (at least until such time as the crash is fixed)?

I'm not sure if this counts as a separate issue to https://github.com/google/ExoPlayer/issues/8675 or not as we are using DRM protected Widevine-DASH VOD content, not a live stream.

indieboyalex avatar Mar 29 '21 10:03 indieboyalex

Looks like the same issue as #8675, which may occur if you reset the same player with new media or use another player with the same listener attached, AND a seek happens just before the new playback starts. You said it's happening when you close your Activity? Can you check whether something in your code is attempting to seek just before you release the player?

tonihei avatar Mar 29 '21 10:03 tonihei

I can't see anything in the code that would be causing a seek and none of the available logging suggests any kind of seek is going on.

indieboyalex avatar Mar 29 '21 11:03 indieboyalex

If you have a way to reproduce, can you describe what we'd need to do to see the same problem here or upload a small example project showing the problem?

Alternatively, it's probably quicker to wait until we uploaded the fix for #8675 and test against the ExoPlayer version with this fix to see if it's indeed the same problem.

tonihei avatar Mar 29 '21 11:03 tonihei

It looks like if I remove the PSL from the player before calling release then I don't get the crash (at least this seems to be working from the limited testing I've done so far)

indieboyalex avatar Mar 29 '21 12:03 indieboyalex

Yes, this is avoiding the issue, but I'm trying to find out whether there is something we need to fix here besides the fix for #8675.

tonihei avatar Mar 29 '21 12:03 tonihei

Well from what I've looked at today, what I've seen is:

  • There was no issue in Exo 2.12, but only once we upgraded - so it's a new behaviour
  • I could not find any seek being called anywhere. This was happening in both player versions in our app (1 for mobile, 1 for TV). The player(s) are however very complicated so I'd probably only be able to be 90% confident this wasn't the issue. Apologies that I can't be 100% confident of this.
  • Workaround mentioned above does at least work (so we can complete the version update for our app at any rate)

indieboyalex avatar Mar 29 '21 12:03 indieboyalex

@VivekBhalodiyaMM This is unrelated and old bug that got fixed in 2.13.0

tonihei avatar Mar 30 '21 15:03 tonihei

@VivekBhalodiyaMM This is unrelated and old bug that got fixed in 2.13.0

Thank you @tonihei I'll verify and check.

VivekBhalodiyaMM avatar Mar 31 '21 04:03 VivekBhalodiyaMM

As an update to this:

We attempted to do as much as we could to ensure the analytics listeners were removed before releasing the player. This resolved any crashing issues we were seeing locally. However out in the wild we were still seeing a huge volume of crashes related to this Assertion check, and nothing seemed to suggest a problem on our side. Eventual solution was to clone the repo, and compile with assertions disabled. Bingo - no more crashes. It was either this or revert to the previously stable version of ExoPlayer before the crashes started happening.

indieboyalex avatar May 19 '21 06:05 indieboyalex

Did you try to use the fix for #8675? It's now also been released as part of 2.14.0, so you should be able to upgrade to this version to get the fix as well.

tonihei avatar May 19 '21 08:05 tonihei

Hey @iNdieboyjeff. 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 avatar Jun 08 '21 01:06 google-oss-bot

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

@iNdieboyjeff 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.

google-oss-bot avatar Jun 17 '21 01:06 google-oss-bot