Skip to content
Browse files
[MSE] Round SourceBuffer removal range

Reviewed by Xabier Rodriguez-Calvar.

Representation of removal times as double in SourceBuffer::remove() can cause
problems in HBOMax due to precision/rounding problems.

In some problematic cases an unintended frame would be marked for removal because
of the very small overlap that could come from precision lost. For instance,
HBOMax uses the PTS of the next sample as removal 'end' and unexpectedly removes
the next segment (as it's a sync frame) sometimes.

Rounding the double removal range delimiters to nanoseconds would help to avoid
those problematic cases.

Original author: Andrzej Surdej <>
See: WebPlatformForEmbedded/WPEWebKit#921

* Source/WebCore/Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::remove): Round the removal range start/end values to millisecond precision.

Canonical link:
  • Loading branch information
eocanha committed Sep 14, 2022
1 parent 0c40ba6 commit 2fc32818fdd29c1ec7d7570727a5d68d057c446f
Showing 1 changed file with 3 additions and 1 deletion.
@@ -282,7 +282,9 @@ ExceptionOr<void> SourceBuffer::abort()

ExceptionOr<void> SourceBuffer::remove(double start, double end)
return remove(MediaTime::createWithDouble(start), MediaTime::createWithDouble(end));
// Limit timescale to 1/1000 of microsecond so samples won't accidentally overlap with removal range by precision lost (e.g. by 0.000000000000X [sec]).
static const uint32_t timescale = 1000000000;
return remove(MediaTime::createWithDouble(start, timescale), MediaTime::createWithDouble(end, timescale));

ExceptionOr<void> SourceBuffer::remove(const MediaTime& start, const MediaTime& end)

0 comments on commit 2fc3281

Please sign in to comment.