Skip to content

Unexpected exception handling load completed - java.lang.IndexOutOfBoundsException during Player re-prepare #10838

Closed

Description

@ValliKarunakaran

ExoPlayer Version

2.18.1

Devices that reproduce the issue

Samsung Galaxy M31
OS Version 12

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

1)Play the Live content with SSAI enabled/multi-period and pause the playback
2) Resume the playback after few minutes(to say 8 mins or more).

Expected result

playback should recover from behindlivewindowexception and continues to play from the nearliveedge

Actual result

Exception During playback

LoadTask: Unexpected exception handling load completed
12-05 17:20:59.206 10829 29189 20310 E LoadTask:   java.lang.IndexOutOfBoundsException: Index: 3, Size: 1
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at java.util.ArrayList.get(ArrayList.java:437)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.manifest.DashManifest.getPeriod(DashManifest.java:126)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.DashMediaSource.createPeriod(DashMediaSource.java:465)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.MaskingMediaPeriod.createPeriod(MaskingMediaPeriod.java:128)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.MaskingMediaSource.onChildSourceInfoRefreshed(MaskingMediaSource.java:203)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.MaskingMediaSource.onChildSourceInfoRefreshed(MaskingMediaSource.java:38)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.CompositeMediaSource.lambda$prepareChildSource$0$CompositeMediaSource(CompositeMediaSource.java:115)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.-$$Lambda$CompositeMediaSource$lU5TDdLYJk4FzgCLkUChati_nlA.onSourceInfoRefreshed(Unknown Source:4)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.BaseMediaSource.refreshSourceInfo(BaseMediaSource.java:88)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.DashMediaSource.processManifest(DashMediaSource.java:847)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.DashMediaSource.onUtcTimestampResolved(DashMediaSource.java:774)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.DashMediaSource.onUtcTimestampLoadCompleted(DashMediaSource.java:676)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.DashMediaSource$UtcTimestampCallback.onLoadCompleted(DashMediaSource.java:1330)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.source.dash.DashMediaSource$UtcTimestampCallback.onLoadCompleted(DashMediaSource.java:1325)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at com.google.android.exoplayer2.upstream.Loader$LoadTask.handleMessage(Loader.java:478)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at android.os.Handler.dispatchMessage(Handler.java:106)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at android.os.Looper.loopOnce(Looper.java:226)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at android.os.Looper.loop(Looper.java:313)
12-05 17:20:59.206 10829 29189 20310 E LoadTask:       at android.os.HandlerThread.run(HandlerThread.java:67)

Media

Not Applicable

Bug Report

Activity

  1. marcbaechinger commented on Dec 7, 2022

    @marcbaechinger
    Contributor

    That's odd indeed.

    Can you give me a bit more details how this can be reproduced?

    From your description it sounds like you handle a PlaybackException and then you prepare the player again. Like something like this:

    @Override
    public void onPlayerError(PlaybackException error) {
      if (eror.errorCode == PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW) {
        // Re-initialize player at the current live window default position.
        player.seekToDefaultPosition();
        player.prepare();
      } else {
        // Handle other errors.
      }
    }
    

    Then this exception is thrown when the player is re-prepared. Is this correct?

    It would be great to have a chance to repro this, so if you have a live stream that you can share with us, that would be super helpful. If you're unable to share bug reports or test content publicly, please send them to dev.exoplayer@gmail.com using a subject in the format "Issue #10838".

    If it's not possible to send a stream, can you try whether you can avoid this exception by creating setting the source again in the case of the exception? Something like that instead of the above:

    @Override
    public void onPlayerError(PlaybackException error) {
      if (eror.errorCode == PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW) {
        player.setMediaItem(mediaItemOfLiveStream); // can use setMediaSource(liveSource) also
        player.prepare();
      } 
    }
    

    I have a hypothesis why this exception happens, and if you can avoid the exception with doing the above this would be a data point for me to dig some deeper there.

  2. ValliKarunakaran commented on Dec 8, 2022

    @ValliKarunakaran
    Author

    thanks @marcbaechinger. As you mentioned, I added the mediasource to the player while re-preparing the player.
    setMediaSource(liveSource)
    It works fine. I did not get IndexOutOfBoundsException during player re-prepare.
    Can I go ahead with the above fix and will it work for all streams during re-prepare?

  3. marcbaechinger commented on Dec 8, 2022

    @marcbaechinger
    Contributor

    Yes, if that works I'm pretty sure it works reliably if you set a new media source.

    However, we need to fix that on our end because it is not working as intended that an app needs to replace the media source.

  4. locked and limited conversation to collaborators on Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions