Skip to content

Sport Live stream sporadically crash #949

@StaehliJ

Description

@StaehliJ

Is there an existing issue for this?

  • I have searched existing issues and found no similar bug report.

Description of the problem

This happens in our Singleton player instance. When opening a stream that is long and, therefore, takes a long time to load and the user closes the player (in the meantime while it still is loading) it seems still in memory (so far so expected).
However there is a call on your side called sendEvent that will crash as the index / position of the media returns -1 (probably b/c) player has been closed in the meantime.

I can explain what we do actually.
We have a single player instance with hilt @singleton annotation. This is used to have seamless playback when navigating to another screen with the same video playing further. And also when navigating back (it is kind of a preivew player and when the user clicks on it a full screen immersive experience opens). when the fullscreen is closed, the preview should play from where the user left. (news app use case)
however, with a livestream it seems we call a disposable effect which accesses the media items and somehow it seems that it will return -1 in your code (maybe because some state changing in the meantime or because there is not enough info about the length of the media itself or the amount of media items).
long story short I think your sendEvent method should be wrapped with a try catch so it would not throw an exception and crash the player during this

at androidx.media3.common.Timeline.getWindow(Timeline.java:1087)                                                                                                  
at ch.srgssr.pillarbox.player.monitoring.Monitoring.sendEvent(Monitoring.kt:221)

It only happens in livestreams where the whole video length is not yet determined more specific this

player.currentTimeline.getWindow(player.currentMediaItemIndex, window)

Reported by @chjaeggi

Relevant stack trace or log output

Process: ch.srf.sport.debug, PID: 5135
java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
    at androidx.media3.exoplayer.PlaylistTimeline.getFirstWindowIndexByChildIndex(PlaylistTimeline.java:104)
    at androidx.media3.exoplayer.AbstractConcatenatedTimeline.getWindow(AbstractConcatenatedTimeline.java:199)
    at androidx.media3.common.Timeline.getWindow(Timeline.java:1087)
    at ch.srgssr.pillarbox.player.monitoring.Monitoring.sendEvent(Monitoring.kt:221)
    at ch.srgssr.pillarbox.player.monitoring.Monitoring.sendEvent$default(Monitoring.kt:213)
    at ch.srgssr.pillarbox.player.monitoring.Monitoring.onSessionCreated$lambda$1$lambda$0(Monitoring.kt:111)
    at ch.srgssr.pillarbox.player.monitoring.Monitoring.$r8$lambda$yN8seC-Z4PzR2AmGC4P49XLXF20(Unknown Source:0)
    at ch.srgssr.pillarbox.player.monitoring.Monitoring$$ExternalSyntheticLambda1.invoke(D8$$SyntheticClass:0)
    at ch.srgssr.pillarbox.player.PillarboxExoPlayerKt$runOnApplicationLooper$1.invokeSuspend(PillarboxExoPlayer.kt:438)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
    at android.os.Handler.handleCallback(Handler.java:995)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loopOnce(Looper.java:248)
    at android.os.Looper.loop(Looper.java:338)
    at android.app.ActivityThread.main(ActivityThread.java:8982)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [CoroutineName(pillarbox-heartbeat), StandaloneCoroutine{Cancelling}@f8bed8, Dispatchers.Default]

Reproducibility

Difficult

Steps to reproduce

  1. Play a sport stream into the SRF Sport App the urn was (urn:swisstxt:video:srf:1817015)
  2. Close the player and sometime the application crash.

Library version

4.0.0

Operating system

Any

Code sample

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions