Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LL-HLS: Preload hinted fragments is played twice sometimes #4223

Closed
duggaraju opened this issue May 13, 2022 · 8 comments · Fixed by #4258 or #4235
Closed

LL-HLS: Preload hinted fragments is played twice sometimes #4223

duggaraju opened this issue May 13, 2022 · 8 comments · Fixed by #4258 or #4235
Assignees
Labels
component: HLS The issue involves Apple's HLS manifest format priority: P0 Broken for everyone; no workaround; urgent status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@duggaraju
Copy link
Contributor

Have you read the FAQ and checked for duplicate open issues?
yes

What version of Shaka Player are you using?
4.0.0

Can you reproduce the issue with our latest release version?
yes

Can you reproduce the issue with the latest code from main?
yes

Are you using the demo app or your own custom app?
both

If custom app, can you reproduce the issue using our demo app?
yes

What browser and OS are you using?
Chrome/Edge windwos

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

What are the manifest and license server URIs?

What configuration are you using? What is the output of player.getConfiguration()?

What did you do?

Just play a live LL-HLS URL which has preload hint for the latest part.

What did you expect to happen?
Playback works fine.

What actually happened?

You will occasionally see audio/video repeat and if you see the network trace, the same part is downloaded twice.

Since the preload hinted part has no duration (start/end time are the same) and then when it becomes a regular part sometimes instea of merging the part looks like we are adding twice and downloading twice.

@duggaraju duggaraju added the type: bug Something isn't working correctly label May 13, 2022
@github-actions github-actions bot added this to the v4.1 milestone May 13, 2022
@duggaraju
Copy link
Contributor Author

@joeyparrish joeyparrish added component: HLS The issue involves Apple's HLS manifest format priority: P1 Big impact or workaround impractical; resolve before feature release labels May 16, 2022
@joeyparrish
Copy link
Member

Do you get the same behavior for v3.3? Or was this introduced in v4.0?

@duggaraju
Copy link
Contributor Author

Yes it repros with Shaka 3.3.0 as well. You can clearly see the same video fragment being downloaded twice in the developer tools. I can see it more often with audio parts (but I guess it is more of a timing issue and could happen with video too. But audio being smaller and quicker to download more easier to hit).

@joeyparrish
Copy link
Member

Thank you for confirming!

@joeyparrish
Copy link
Member

From what I see, the merge logic is actually sound. The problem appears to be in how streaming and buffering operates on these segments. I expect it is caused by the reference having a 0-duration, but I need to spend a little more time debugging to be certain.

@joeyparrish
Copy link
Member

joeyparrish commented May 26, 2022

I can't get this to play with v3.3 at all. It seems that when we try to fetch the first segment to extract a timestamp, by the time we make the request, it has fallen out of the window and we get a 404. This doesn't happen in v4, since we don't extract timestamps any more.

I believe what is happening is that we would fetch the same partial segment twice, because StreamingEngine would try to look up the next segment to fetch based on the end time of the previous one. Since the last thing we fetched had an apparent duration of zero (according to SegmentReference), we would re-request the duration-having version of the same partial segment reference next.

I expect that if I could get v3.3 to play this at all, it would make duplicate requests, but otherwise play correctly.

In v4, I'm seeing an additional problem caused by this re-request, combined with sequence mode. The re-requested segment gets appended in sequence mode, and some content repeats. If a timing issue causes this to happen asymmetrically between audio and video, you then also get A/V desync.

I'm going to up the priority to P0, because at least for v4, this is quite bad.

@joeyparrish joeyparrish added priority: P0 Broken for everyone; no workaround; urgent and removed priority: P1 Big impact or workaround impractical; resolve before feature release labels May 26, 2022
@joeyparrish joeyparrish self-assigned this May 26, 2022
@joeyparrish
Copy link
Member

I am convinced that the zero-duration partial ref is to blame. On v3, this would result requesting the segment twice, but no other negative consequences, as it would overwrite the buffered frames of the first version. On v4, it also results in stuttering playback and possible A/V desync.

The way StreamingEngine processes a zero-duration reference is at the root of requesting the segment twice. Handling these refs specially in StreamingEngine would solve the issue for both branches, but it's a bit complicated. I have a working version of this here: joeyparrish@adf3b77

After working on that solution, I discovered that there is an attribute in LL-HLS which we are parsing, but not using to compute the hinted segment's duration: PART-TARGET. By using that, we have a simple solution that only touches the HLS parser, and all segment references will always have a duration. And it's a required attribute according to the spec. Here is what that fix looks like: joeyparrish@00a7ac8

I'm going to move forward with a PR for the PART-TARGET solution, but I would love to have feedback on this from @duggaraju and their colleagues before it is released.

joeyparrish added a commit that referenced this issue Jun 2, 2022
Because zero-duration references cause such chaos, ensure that the HLS
parser never produces these.  Preload-hinted segments should use the
target duration for partial segments, and if that required attribute
is missing from the playlist, then preload-hinted segments should be
skipped.

Closes #4223
joeyparrish added a commit that referenced this issue Jun 2, 2022
Because zero-duration references cause such chaos, ensure that the HLS
parser never produces these.  Preload-hinted segments should use the
target duration for partial segments, and if that required attribute
is missing from the playlist, then preload-hinted segments should be
skipped.

Closes #4223
joeyparrish added a commit that referenced this issue Jun 2, 2022
Because zero-duration references cause such chaos, ensure that the HLS
parser never produces these.  Preload-hinted segments should use the
target duration for partial segments, and if that required attribute
is missing from the playlist, then preload-hinted segments should be
skipped.

Closes #4223
joeyparrish added a commit that referenced this issue Jun 2, 2022
Because zero-duration references cause such chaos, ensure that the HLS
parser never produces these.  Preload-hinted segments should use the
target duration for partial segments, and if that required attribute
is missing from the playlist, then preload-hinted segments should be
skipped.

Closes #4223
theodab pushed a commit to theodab/shaka-player that referenced this issue Jun 3, 2022
Because zero-duration references cause such chaos, ensure that the HLS
parser never produces these.  Preload-hinted segments should use the
target duration for partial segments, and if that required attribute
is missing from the playlist, then preload-hinted segments should be
skipped.

Closes shaka-project#4223
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Aug 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: HLS The issue involves Apple's HLS manifest format priority: P0 Broken for everyone; no workaround; urgent status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
3 participants