Bug 265023

Summary: [MSE] Change canPlayThroughRange to check buffered data at the current position
Product: WebKit Reporter: Enrique Ocaña <eocanha>
Component: MediaAssignee: Enrique Ocaña <eocanha>
Status: RESOLVED FIXED    
Severity: Normal CC: jer.noble, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=270050

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.