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: ignore buffered content less than 1e-4s #6802

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

gkatsev
Copy link
Contributor

@gkatsev gkatsev commented Jun 11, 2024

On Firefox, in some cases after a period ends, seeking shortly after will cause playback to fail or stall.
This occurs when the next period has small gaps and we're seeking to after the gap. Seeking to before the gap succeeds. Even though the seek requests the soure buffers to be fully cleared, Firefox actually keeps around less than 1e-4s of content and won't let us forcibly remove this content. Trying to call flush causes in infinite loop.
This leftover content makes shaka think that the buffer end in where we used to be even though the presentation time reflects where we seeked to. This means that playback doesn't continue. The buffer contitues getting filled and playback will either fail when the SourcBuffer is filled and triggers a QuotaExceededError or contiue when the buffer will reach the presentationTime.

On Firefox, in some cases after a period ends, seeking shortly after
will cause playback to fail or stall.
This occurs when the next period has small gaps and we're seeking to
after the gap. Seeking to before the gap succeeds.
Even though the seek requests the soure buffers to be fully cleared,
Firefox actually keeps around less than 1e-4s of content and won't let
us forcibly remove this content. Trying to call flush causes in infinite
loop.
This leftover content makes shaka think that the buffer end in where we
used to be even though the presentation time reflects where we seeked
to. This means that playback doesn't continue. The buffer contitues
getting filled and playback will either fail when the SourcBuffer is
filled and triggers a QuotaExceededError or contiue when the buffer will
reach the presentationTime.
@shaka-bot
Copy link
Collaborator

Incremental code coverage: 100.00%

@avelad avelad added type: bug Something isn't working correctly priority: P2 Smaller impact or easy workaround browser: Firefox Issues affecting Firefox or Gecko derivatives labels Jun 12, 2024
@avelad avelad added this to the v4.10 milestone Jun 12, 2024
@avelad avelad requested a review from theodab June 12, 2024 05:18
@@ -23,7 +23,8 @@ shaka.media.TimeRangesUtils = class {
return null;
}
// Workaround Safari bug: https://bit.ly/2trx6O8
if (b.length == 1 && b.end(0) - b.start(0) < 1e-6) {
// Firefox may leave <1e-4s of data in buffer after clearing all content
if (b.length == 1 && b.end(0) - b.start(0) < 1e-4) {
Copy link
Member

Choose a reason for hiding this comment

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

There are lots of those checks... Maybe move it to some util function so in the future we will not be forced to change the same value all over the place?

Copy link
Member

@avelad avelad Jun 12, 2024

Choose a reason for hiding this comment

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

Yes, I agree, please move the check to a helper function or at least move the value to a constant. Thanks!

@@ -23,7 +23,8 @@ shaka.media.TimeRangesUtils = class {
return null;
}
// Workaround Safari bug: https://bit.ly/2trx6O8
if (b.length == 1 && b.end(0) - b.start(0) < 1e-6) {
// Firefox may leave <1e-4s of data in buffer after clearing all content
if (b.length == 1 && b.end(0) - b.start(0) < 1e-4) {
Copy link
Member

@avelad avelad Jun 12, 2024

Choose a reason for hiding this comment

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

Yes, I agree, please move the check to a helper function or at least move the value to a constant. Thanks!

@gkatsev gkatsev requested a review from avelad June 12, 2024 15:26
@joeyparrish joeyparrish merged commit d6fcf66 into shaka-project:main Jun 12, 2024
15 of 16 checks passed
@gkatsev gkatsev deleted the firefox-buffer-fix branch June 12, 2024 19:15
avelad pushed a commit that referenced this pull request Jun 14, 2024
On Firefox, in some cases after a period ends, seeking shortly after
will cause playback to fail or stall.
This occurs when the next period has small gaps and we're seeking to
after the gap. Seeking to before the gap succeeds. Even though the seek
requests the soure buffers to be fully cleared, Firefox actually keeps
around less than 1e-4s of content and won't let us forcibly remove this
content. Trying to call flush causes in infinite loop.
This leftover content makes shaka think that the buffer end in where we
used to be even though the presentation time reflects where we seeked
to. This means that playback doesn't continue. The buffer contitues
getting filled and playback will either fail when the SourcBuffer is
filled and triggers a QuotaExceededError or contiue when the buffer will
reach the presentationTime.
avelad pushed a commit that referenced this pull request Jun 14, 2024
On Firefox, in some cases after a period ends, seeking shortly after
will cause playback to fail or stall.
This occurs when the next period has small gaps and we're seeking to
after the gap. Seeking to before the gap succeeds. Even though the seek
requests the soure buffers to be fully cleared, Firefox actually keeps
around less than 1e-4s of content and won't let us forcibly remove this
content. Trying to call flush causes in infinite loop.
This leftover content makes shaka think that the buffer end in where we
used to be even though the presentation time reflects where we seeked
to. This means that playback doesn't continue. The buffer contitues
getting filled and playback will either fail when the SourcBuffer is
filled and triggers a QuotaExceededError or contiue when the buffer will
reach the presentationTime.
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Aug 11, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives priority: P2 Smaller impact or easy workaround 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.

5 participants