Bug 265023 - [MSE] Change canPlayThroughRange to check buffered data at the current position
Summary: [MSE] Change canPlayThroughRange to check buffered data at the current position
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Enrique Ocaña
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-11-17 05:02 PST by Enrique Ocaña
Modified: 2024-02-25 07:54 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enrique Ocaña 2023-11-17 05:02:35 PST
The current SourceBuffer::canPlayThroughRange() implementation is based on average buffering rate. While this approach makes sense in a context of continuous playback, where the JS app is always trying to append data, this isn't always the case in some real life apps. For instance, an app may append a lot of data on page load (enough for sustained playback), then decide to wait for whatever reason, and then start playback. In those circumstances, wait would cause the average buffering rate to be artificially low. There are more examples of the kind of problems that a time-based/average buffering rate-based approach may cause.

See: https://github.com/WebPlatformForEmbedded/WPEWebKit/issues/928

One solution would be to use Firefox strategy to this problem[1]: if the ranges to be checked have 3 seconds or more buffered after the current position, we consider that  sustained playback is possible. This solves the issues seen in some real world apps.

If this approach causes any problems on non-WPE/WebKitGTK ports, a possible improvement might be to let the platform implementation decide the desired strategy in some way. For the mentioned platforms it's important to get rid of the problems that the time-based implementation causes.

[1] https://github.com/mozilla/gecko-dev/blob/master/dom/media/mediasource/MediaSourceDecoder.cpp#L320
Comment 1 Enrique Ocaña 2023-11-17 05:31:24 PST
Pull request: https://github.com/WebKit/WebKit/pull/20663
Comment 2 Radar WebKit Bug Importer 2023-11-24 05:03:18 PST
<rdar://problem/118770174>
Comment 3 EWS 2024-01-08 07:49:19 PST
Committed 272762@main (c55cda1034c1): <https://commits.webkit.org/272762@main>

Reviewed commits have been landed. Closing PR #20663 and removing active labels.