Log Message
[MSE][SourceBuffer] Fix removal of paddings from buffered range https://bugs.webkit.org/show_bug.cgi?id=237780
Reviewed by Jer Noble. Source/WebCore: When removing a range ending up in a sample S2 which overlaps slightly with a previous one S1 but still extends beyond the removal range, the buffered range computing algorithm can become confused removing the range paddings and completely skip the S2 sample (instead of accounting it as part of the still buffered ranges). The sample S2 is leaked and becomes unnoticed in the buffered ranges. This patch changes the way in which buffered ranges boundaries are computed in such cases. This patch is authored by Eugene Mutavchi <ievgen_mutav...@comcast.com> See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/797#discussion_r818973424 Test: media/media-source/media-source-remove-overlapped.html * platform/graphics/SourceBufferPrivate.cpp: End the additionalErasedRanges iterator in removeSamplesFromTrackBuffer() in a sample starting after erasedStart, instead of starting on or after erasedEnd. LayoutTests: This tests that overlapped samples in the boundaries of removal ranges aren't leaked. This patch is authored by Eugene Mutavchi <ievgen_mutav...@comcast.com> See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/797 * media/media-source/media-source-remove-overlapped-expected.txt: Added. * media/media-source/media-source-remove-overlapped.html: Added.
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (291224 => 291225)
--- trunk/LayoutTests/ChangeLog 2022-03-14 12:45:36 UTC (rev 291224)
+++ trunk/LayoutTests/ChangeLog 2022-03-14 13:21:44 UTC (rev 291225)
@@ -1,3 +1,18 @@
+2022-03-14 Enrique Ocaña González <eoca...@igalia.com>
+
+ [MSE][SourceBuffer] Fix removal of paddings from buffered range
+ https://bugs.webkit.org/show_bug.cgi?id=237780
+
+ Reviewed by Jer Noble.
+
+ This tests that overlapped samples in the boundaries of removal ranges aren't leaked.
+
+ This patch is authored by Eugene Mutavchi <ievgen_mutav...@comcast.com>
+ See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/797
+
+ * media/media-source/media-source-remove-overlapped-expected.txt: Added.
+ * media/media-source/media-source-remove-overlapped.html: Added.
+
2022-03-14 Youenn Fablet <you...@apple.com>
[ MacOS ] imported/w3c/web-platform-tests/webrtc-extensions/transfer-datachannel.html is a flaky failure
Added: trunk/LayoutTests/media/media-source/media-source-remove-overlapped-expected.txt (0 => 291225)
--- trunk/LayoutTests/media/media-source/media-source-remove-overlapped-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-remove-overlapped-expected.txt 2022-03-14 13:21:44 UTC (rev 291225)
@@ -0,0 +1,22 @@
+This tests that overlapped samples in the boundaries of removal ranges aren't leaked.
+
+RUN(video.src = ""
+EVENT(sourceopen)
+RUN(sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock"))
+RUN(sourceBuffer.appendBuffer(initSegment))
+EVENT(updateend)
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+RUN(sourceBuffer.abort())
+RUN(sourceBuffer.appendBuffer(initSegment))
+EVENT(updateend)
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+RUN(sourceBuffer.remove(sourceBuffer.buffered.start(0), 3.96))
+EVENT(updateend)
+EXPECTED (sourceBuffer.buffered.start(0) <= '4') OK
+RUN(sourceBuffer.remove(sourceBuffer.buffered.start(0), 5))
+EVENT(updateend)
+EXPECTED (sourceBuffer.buffered.length == '0') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/media-source/media-source-remove-overlapped.html (0 => 291225)
--- trunk/LayoutTests/media/media-source/media-source-remove-overlapped.html (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-remove-overlapped.html 2022-03-14 13:21:44 UTC (rev 291225)
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>mock-media-source</title>
+ <script src=""
+ <script src=""
+ <script>
+ var source;
+ var sourceBuffer;
+ var initSegment;
+
+ if (window.internals)
+ internals.initializeMockMediaSource();
+
+ function runTest() {
+ findMediaElement();
+
+ source = new MediaSource();
+ waitForEventOn(source, 'sourceopen', sourceOpen);
+ run('video.src = ""
+ }
+
+ function sourceOpen() {
+ run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
+ waitForEventOn(sourceBuffer, 'updateend', loadSamples1, false, true);
+ initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+ run('sourceBuffer.appendBuffer(initSegment)');
+ }
+
+ function loadSamples1() {
+ // Adding buffered ranges [0, 4].
+ samples = concatenateSamples([
+ makeASample( 0, 0, 1000, 1000, 1, SAMPLE_FLAG.SYNC),
+ makeASample(1000, 1000, 1000, 1000, 1, SAMPLE_FLAG.NONE),
+ makeASample(2000, 2000, 1000, 1000, 1, SAMPLE_FLAG.NONE),
+ makeASample(3000, 3000, 1000, 1000, 1, SAMPLE_FLAG.NONE),
+ ]);
+ waitForEventOn(sourceBuffer, 'updateend', parserReset, false, true);
+ run('sourceBuffer.appendBuffer(samples)');
+ }
+
+ function parserReset() {
+ waitForEventOn(sourceBuffer, 'updateend', loadSamples2, false, true);
+ run('sourceBuffer.abort()');
+ initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+ run('sourceBuffer.appendBuffer(initSegment)');
+ }
+
+ function loadSamples2() {
+ // Adding buffered ranges [3.96, 5.28]. The first sample overlaps with the last [3, 4] one from loadSamples1(),
+ // but the fudge factor allows the insertion without truncating [3, 4]. Those samples are slightly overlapped.
+ samples = concatenateSamples([
+ makeASample(3960, 3960, 330, 1000, 1, SAMPLE_FLAG.SYNC),
+ makeASample(4290, 4290, 330, 1000, 1, SAMPLE_FLAG.NONE),
+ makeASample(4620, 4620, 330, 1000, 1, SAMPLE_FLAG.NONE),
+ makeASample(4950, 4950, 330, 1000, 1, SAMPLE_FLAG.NONE),
+ ]);
+ waitForEventOn(sourceBuffer, 'updateend', remove, false, true);
+ run('sourceBuffer.appendBuffer(samples)');
+ }
+
+ function remove() {
+ waitForEventOn(sourceBuffer, 'updateend', checkRemoved, false, true);
+ run('sourceBuffer.remove(sourceBuffer.buffered.start(0), 3.96)');
+ // This doesn't remove sample [3.96, 4.29], just [0, 4], so the buffered range should remain [4, 5.28].
+ // It's wrong that it remains [4.29, 5.28].
+ }
+
+ function checkRemoved() {
+ testExpected('sourceBuffer.buffered.start(0)', 4, '<=');
+ waitForEventOn(sourceBuffer, 'updateend', checkRemoved2, false, true);
+ run('sourceBuffer.remove(sourceBuffer.buffered.start(0), 5)');
+ }
+
+ function checkRemoved2() {
+ testExpected('sourceBuffer.buffered.length', 0);
+ endTest();
+ }
+ </script>
+</head>
+<body _onload_="runTest()">
+ <div>This tests that overlapped samples in the boundaries of removal ranges aren't leaked.</div>
+ <video></video>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (291224 => 291225)
--- trunk/Source/WebCore/ChangeLog 2022-03-14 12:45:36 UTC (rev 291224)
+++ trunk/Source/WebCore/ChangeLog 2022-03-14 13:21:44 UTC (rev 291225)
@@ -1,3 +1,27 @@
+2022-03-14 Enrique Ocaña González <eoca...@igalia.com>
+
+ [MSE][SourceBuffer] Fix removal of paddings from buffered range
+ https://bugs.webkit.org/show_bug.cgi?id=237780
+
+ Reviewed by Jer Noble.
+
+ When removing a range ending up in a sample S2 which overlaps slightly with a
+ previous one S1 but still extends beyond the removal range, the buffered range
+ computing algorithm can become confused removing the range paddings and
+ completely skip the S2 sample (instead of accounting it as part of the still
+ buffered ranges). The sample S2 is leaked and becomes unnoticed in the buffered
+ ranges.
+
+ This patch changes the way in which buffered ranges boundaries are computed in
+ such cases.
+
+ This patch is authored by Eugene Mutavchi <ievgen_mutav...@comcast.com>
+ See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/797#discussion_r818973424
+
+ Test: media/media-source/media-source-remove-overlapped.html
+
+ * platform/graphics/SourceBufferPrivate.cpp: End the additionalErasedRanges iterator in removeSamplesFromTrackBuffer() in a sample starting after erasedStart, instead of starting on or after erasedEnd.
+
2022-03-14 Kimmo Kinnunen <kkinnu...@apple.com>
WebGL context should use discrete gpu if the context is created when the window is on external monitor, ANGLE Metal backend
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (291224 => 291225)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2022-03-14 12:45:36 UTC (rev 291224)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2022-03-14 13:21:44 UTC (rev 291225)
@@ -518,7 +518,7 @@
additionalErasedRanges.add(previousSample.presentationTime() + previousSample.duration(), erasedStart);
}
- auto endIterator = trackBuffer.samples.presentationOrder().findSampleStartingOnOrAfterPresentationTime(erasedEnd);
+ auto endIterator = trackBuffer.samples.presentationOrder().findSampleStartingAfterPresentationTime(erasedStart);
if (endIterator == trackBuffer.samples.presentationOrder().end())
additionalErasedRanges.add(erasedEnd, MediaTime::positiveInfiniteTime());
else {
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes