Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 55c079f8c2adf5e171ab48b59e39054d3ab18fe4
https://github.com/WebKit/WebKit/commit/55c079f8c2adf5e171ab48b59e39054d3ab18fe4
Author: Chris Dumez <[email protected]>
Date: 2026-06-04 (Thu, 04 Jun 2026)
Changed paths:
M Source/WebCore/platform/graphics/PlatformTimeRanges.cpp
M Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp
Log Message:
-----------
PlatformTimeRanges::containWithEpsilon checks the wrong delta for inter-range
gaps
https://bugs.webkit.org/show_bug.cgi?id=316185
Reviewed by Jean-Yves Avenard.
When the buffered ranges have more than one segment after intersection
with the requested range, containWithEpsilon() walks the segments to
verify each gap is smaller than the supplied epsilon. The check is
written as:
```
if (bufferedRanges.end(i) - bufferedRanges.start(i - 1) > epsilon)
return false;
```
`end(i) - start(i-1)` is the total span across both segments (segment i-1
duration + gap + segment i duration), not the gap, so the check compares
the wrong quantity against epsilon. The intended computation is
`start(i) - end(i-1)`.
In practice the existing MSE callers do not hit this: TrackBuffer merges
any gap smaller than MediaSourcePrivate::timeFudgeFactor() (2002/24000 ~=
83.4ms) before the ranges reach containWithEpsilon, and the requested
interval is always a short single segment, so the loop's multi-segment
branch is rarely entered with a sub-epsilon gap. The bug is still a
latent correctness issue (e.g. if SourceBuffer.remove() were ever called
with a sub-epsilon interval, or for any future caller that does not go
through TrackBuffer's coalescing), so switch to the correct subtraction
and add an API test that pins the multi-segment behavior.
Test: TimeRanges.ContainWithEpsilon_TolerantOfSmallGap
* Source/WebCore/platform/graphics/PlatformTimeRanges.cpp:
(WebCore::PlatformTimeRanges::containWithEpsilon const):
* Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp:
(TestWebKitAPI::TEST(TimeRanges, ContainWithEpsilon_TolerantOfSmallGap)):
Canonical link: https://commits.webkit.org/314592@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications