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

fix(hls): Fixed buffering issue with live HLS #4002

Merged
merged 2 commits into from Feb 24, 2022

Conversation

theodab
Copy link
Collaborator

@theodab theodab commented Feb 24, 2022

HLS now appends segments in sequence mode. In order to handle seeks,
we set the timestampOffset property on SourceBuffer to the startTime of
the segment. This is done after every seek, or on startup.

For non-sequence-mode content (DASH), we normally set timestampOffset
based on the Period structure. This should be suppressed in sequence
mode, though, where only the reference startTime matters.

The buffering issue was caused by two things in combination:

  1. The HLS parser set meaningless timestampOffset values that would
    change when a playlist was updated
  2. We would use those timestampOffset values in setStreamProperties,
    even though this should be skipped in sequence mode

These two things in combination would lead MediaSourceEngine to start
inserting segments near the start of the presentation, rather than at
the live edge.

This changes MediaSourceEngine so that in sequence mode, timestampOffset
is ignored in setStreamProperties. This also cleans up the HLS parser
to set each reference's timestampOffset to 0, since they should be
ignored anyway.

@theodab theodab added type: bug Something isn't working correctly component: HLS The issue involves Apple's HLS manifest format labels Feb 24, 2022
HLS now appends segments in sequence mode. In order to handle seeks,
we use the timestampOffset property to inform MediaSource where the
new segment should go.
However, we were still setting timestampOffset when the manifest was
updated, which caused issues in live HLS; suddenly, MediaSource would
start inserting segments near the start of the presentation, rather than
at the live edge.
This changes MediaSourceEngine to not apply timestampOffset during
initialization when in sequence mode, to fix that problem.
@joeyparrish
Copy link
Member

However, we were still setting timestampOffset when the manifest was updated, which caused issues in live HLS; suddenly, MediaSource would start inserting segments near the start of the presentation, rather than at the live edge.

I don't think I understand this part. Can you elaborate?

I don't doubt your fix, but I think we need to find a better way to explain why it's the right one.

@joeyparrish
Copy link
Member

Updated PR description to reflect our discussion of the issue and the fix. Please add a commit or amend to remove the timestampOffset parameter in HlsParser's createSegmentReference_, and to hard-code timestampOffset to 0 there instead.

When in sequence mode, we no longer use the timestamp offset of
segment references. So, in the HLS parser, there's no reason to
set it anymore.
Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is awesome.

@theodab theodab merged commit c438e85 into shaka-project:master Feb 24, 2022
@avelad avelad added this to the v4.0 milestone May 4, 2022
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
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 status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants