Skip to content

Prevent overlapping appends on level switch - #8180

Open
rudemateo wants to merge 1 commit into
video-dev:masterfrom
pbs:bugfix/level-switch-overlapping-append
Open

rudemateo wants to merge 1 commit into
video-dev:masterfrom
pbs:bugfix/level-switch-overlapping-append

Conversation

@rudemateo

Copy link
Copy Markdown
Collaborator

This PR will...

Extend the existing next-fragment preference across level switches, in either direction and beyond the first fragment. The switch allowance remains Math.min(nextFragLookupTolerance, maxFragLookUpTolerance), with the existing 1/200s default.

Keep lookup tolerance enabled when waiting for level details resets startFragRequested but a previous fragment is still tracked.

Why is this Pull Request needed?

See #8179. After a level switch, the fragment that was just buffered is loaded again in the new level and appended over the buffered range, because the buffer ends a few microseconds before the end of that fragment.

Waiting for level details resets startFragRequested, which has disabled lookup tolerance on the next fragment selection since v1.6.0, including the 1/200s allowance from #6471. With the stream from #6441 and startLevel: 2:

version first segment loaded twice
1.5.9 yes
1.5.10 no
1.6.0 - 1.6.16 yes
1.7.0 - master no (buffer now ends past the 720p segment end)

With this change and the test stream from #8179 (network and CPU throttled), sn 1 and sn 2 are each loaded once.

Are there any points in the code the reviewer needs to double check?

  • The finder's arguments retain their existing meanings. The next-fragment preference validates the candidate being returned; the original fast-start workaround is preserved.
  • Initial lookup without a tracked previous fragment remains strict. Existing restrictions for paused playback, backward seeks, parts, and the playlist end remain, so the overlapping append still happens while paused.
  • The 1/200s limit applies to the next-fragment preference. Binary search still uses the general lookup tolerance.
  • A fragment can still be loaded twice when the buffer ends more than 1/200s before its end.

Resolves issues:

Resolves #8179

Related to #6441 and #6471.

Checklist

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

Prefer the next fragment on level switch when it starts within 1/200s of the end of the buffer.
Keep lookup tolerance when waiting for level details resets startFragRequested and a previous fragment is still tracked.

Fixes video-dev#8179
Related to video-dev#6441 and video-dev#6471

@robwalch robwalch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd prefer if this were based on playlist times aligning, or some yet to be determined signal in HLS that segment boundaries are aligned, rather than lookup tolerance.

I do not think this should be configurable such that playback only works when configured one way vs another.

Alternatively, once the overlapping segment is parsed can it be determined that it should not be appended and just move on to the next?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overlapping appends on level switch when the buffer ends within microseconds of the fragment end

2 participants