Unexpected runtime error (When Chunks have different playlist urls)
See original GitHub issueHi, I have caught an unexpected runtime error when I use HLS and codecNeedsSetOutputSurfaceWorkaround = true. For example, A xiaomi device like MiBox4 returns true, because it was established in the parent class - MediaCodecVideoRenderer.
When I change the configuration of a mobile phone or hide an app - ExoPlayer passes a nullable Surface to clear/release codec inside MediaCodecVideoRenderer. The error happens when chunks have differents playlists, for instance, I dived to the source code and found out that ExoPlayer has this kind of a code’s snippet like:
HlsMediaChunk.java 139 line - Where ExoPlayer checks playlist between the last and current chunk:
playlistUrl.equals(previousChunk.playlistUrl) // so, They are not equal.
then, 144 line:
boolean canContinueWithoutSplice =
isFollowingChunk || (isIndependent && segmentStartTimeInPeriodUs >= previousChunk.endTimeUs);
shouldSpliceIn = !canContinueWithoutSplice;
as, isFollowingChunk is false and the right block too, I have shouldSpliceIn true
and the end of all, when ExoPlayer checkes state with Assertions.class in 319 line it converts true expression to false and checks state. For example:
public int getFirstSampleIndex(int sampleQueueIndex) {
Assertions.checkState(!shouldSpliceIn); // convert true to false
public static void checkState(boolean expression) {
if (ExoPlayerLibraryInfo.ASSERTIONS_ENABLED && !expression) {
throw new IllegalStateException();
}
}
How to replay the issue:
- You have to return true inside codecNeedsSetOutputSurfaceWorkaround method (It does not matter that you have emulators or real devices)
- Start playing with HLS (adaptive streaming)
- a little wait when player changes playlists between chunks (I use Charles to intercept these one’s)
- hide or rotate an app
In conclusion, the error happens, when the method codecNeedsSetOutputSurfaceWorkaround returns true and the render has chunks with different playlist urls inside. I consider that it’s normal behaviour to have different urls in a queue. Full error stack:
Caused by: java.lang.IllegalStateException
at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:86)
at com.google.android.exoplayer2.source.hls.HlsMediaChunk.getFirstSampleIndex(HlsMediaChunk.java:319)
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.skipData(HlsSampleStreamWrapper.java:638)
at com.google.android.exoplayer2.source.hls.HlsSampleStream.skipData(HlsSampleStream.java:86)
at com.google.android.exoplayer2.BaseRenderer.skipSource(BaseRenderer.java:427)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:829)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:948)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top GitHub Comments
Issue should be fixed by the two commits above.
@tonihei Thanks for the feedback!