question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected runtime error (When Chunks have different playlist urls)

See original GitHub issue

Hi, 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:

  1. You have to return true inside codecNeedsSetOutputSurfaceWorkaround method (It does not matter that you have emulators or real devices)
  2. Start playing with HLS (adaptive streaming)
  3. a little wait when player changes playlists between chunks (I use Charles to intercept these one’s)
  4. 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
toniheicommented, May 21, 2021

Issue should be fixed by the two commits above.

0reactions
KostyaLyapochkincommented, May 20, 2021

@tonihei Thanks for the feedback!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected runtime error (When Chunks have different playlist urls) -
Hi, I have caught an unexpected runtime error when I use HLS and codecNeedsSetOutputSurfaceWorkaround = true. For example, A xiaomi device like MiBox4 ......
Read more >
Next.js Unhandled Runtime Error "Failed to load script
I'm seeing the same thing. I tried adding the URL in the 'as' attribute of the Link component, but that did not help....
Read more >
GETHLSSTREAMINGSESSIONU...
GetHLSStreamingSessionURL returns an authenticated URL (that includes an encrypted session token) for the session's HLS master playlist (the root resource ...
Read more >
Implementing Code Splitting in React Native with Re.Pack
This code instructs ChunkManager how to resolve remote chunks – what the URL of the chunk is that will be downloaded and executed....
Read more >
Bug listing with status RESOLVED with resolution TEST ...
Error in sched.c line 961. ... Bug:76982 - "net-www/links-2.1_pre15 compile error with unicode USE flag" status:RESOLVED resolution:TEST-REQUEST severity: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found