When reading the AdaptationSet from the Dash manifest (MPD) the ExoPlayer didn鈥檛 check the provided indices of the Period and AdaptationSet elements. This could result in an IndexOutOfBoundsException when the referenced period or adaption set didn鈥檛 exist.
The reason for the faulty reference is probably an error in the manifest file, but the ExoPlayer should handle it more robustly and without a crash. Currently I can鈥檛 provide a manifest to reproduce the crash. However, the crash has occurred several times on different devices. I'm not sure if a simple check of the indices is sufficient. Maybe the correct index of the period and the adaption set must be checked and handled earlier.
ExoPlayer r2.3.1
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.get(ArrayList.java:411)
at java.util.Collections$UnmodifiableList.get(Collections.java:1295)
at com.google.android.exoplayer2.source.dash.DefaultDashChunkSource.getAdaptationSet(DefaultDashChunkSource.java:303)
at com.google.android.exoplayer2.source.dash.DefaultDashChunkSource.updateManifest(DefaultDashChunkSource.java:145)
at com.google.android.exoplayer2.source.dash.DashMediaPeriod.updateManifest(DashMediaPeriod.java:94)
at com.google.android.exoplayer2.source.dash.DashMediaSource.processManifest(DashMediaSource.java:455)
at com.google.android.exoplayer2.source.dash.DashMediaSource.onManifestLoadCompleted(DashMediaSource.java:365)
at com.google.android.exoplayer2.source.dash.DashMediaSource$ManifestCallback.onLoadCompleted(DashMediaSource.java:730)
at com.google.android.exoplayer2.source.dash.DashMediaSource$ManifestCallback.onLoadError(DashMediaSource.java:724)
at com.google.android.exoplayer2.source.dash.DashMediaSource$ManifestCallback.onLoadCanceled(DashMediaSource.java:724)
at com.google.android.exoplayer2.source.dash.DashMediaSource$ManifestCallback.onLoadCompleted(DashMediaSource.java:724)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.handleMessage(Loader.java:355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.google.android.exoplayer2.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
I can be a little bit more specific about the crash now. It happens due to an error in the playout of the stream which results in an incorrect dash manifest.
In the attachment I provided what one of these broken manifests looks like and for comparison a correct one.
Due to the playout error the manifest contains only the video AdaptionSet but none for the audio. It seems that the player currently does no check there but just assumes that at least two sets are included. We will fix the bug on the server side but I think the ExoPlayer should be able to handle the situation as well.
Broken Manifest mpd.txt
Correct Manifest mpd.txt
If you need more information just let us know.
Yup, understood. It's pretty difficult (and a lot of extra code) to validate all parts of all media for correctness, so we have a pretty broad try { ... } catch ( ... ) { propagate as playback failure } to handle unexpected cases without killing the process. There are however a few specific callbacks that aren't covered by this logic, one of which is the ManifestCallback.onLoad* callbacks.
We'll use this issue to track getting them covered correctly, after which the IndexOutOfBoundsException will be propagated out the front of the player as a playback failure, but will not cause process death.
Sounds good, thanks for your effort!
Thank you very much for the effort on this. We're looking forward to seeing this issue fixed. Could you please tell me if there is an ETA for the fix?
We do not have an ETA for this. It's preferable to fix this on the client side as a defensive measure. However if you're aware of your manifest server generating invalid manifests, you should really fix the problem on the server side at which point this becomes a non-issue. We have multiple large third party providers using ExoPlayer, who simply don't encounter this issue because their servers do the right thing.
馃憤
Most helpful comment
We do not have an ETA for this. It's preferable to fix this on the client side as a defensive measure. However if you're aware of your manifest server generating invalid manifests, you should really fix the problem on the server side at which point this becomes a non-issue. We have multiple large third party providers using ExoPlayer, who simply don't encounter this issue because their servers do the right thing.