Diff
Modified: trunk/LayoutTests/ChangeLog (286484 => 286485)
--- trunk/LayoutTests/ChangeLog 2021-12-03 08:06:10 UTC (rev 286484)
+++ trunk/LayoutTests/ChangeLog 2021-12-03 08:25:14 UTC (rev 286485)
@@ -1,3 +1,13 @@
+2021-12-03 Alicia Boya García <ab...@igalia.com>
+
+ [MSE] Fix erase range to prevent accidental deletion in files with changing durations
+ https://bugs.webkit.org/show_bug.cgi?id=233528
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ * media/media-source/media-source-append-tiny-durations-expected.txt: Added.
+ * media/media-source/media-source-append-tiny-durations.html: Added.
+
2021-12-02 Chris Dumez <cdu...@apple.com>
html/semantics/forms/constraints/form-validation-validity-valid.html WPT test is failing
Added: trunk/LayoutTests/media/media-source/media-source-append-tiny-durations-expected.txt (0 => 286485)
--- trunk/LayoutTests/media/media-source/media-source-append-tiny-durations-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-append-tiny-durations-expected.txt 2021-12-03 08:25:14 UTC (rev 286485)
@@ -0,0 +1,27 @@
+This tests that an append of non-overlapping samples of varying durations, some of them under a millisecond, don't trigger accidental erasure.
+This is done in some MP4 files, where decode durations are manipulated to code media containing B-frames while maintaining a start PTS = 0.
+
+RUN(video.src = ""
+EVENT(sourceopen)
+RUN(sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock"))
+RUN(sourceBuffer.appendBuffer(initSegment))
+EVENT(updateend)
+RUN(sourceBuffer.appendBuffer(makeSamples(1)))
+EVENT(updateend)
+EXPECTED (bufferedSamples.length == '5') OK
+{PTS({0/10000 = 0.000000}), DTS({0/10000 = 0.000000}), duration({1/10000 = 0.000100}), flags(1), generation(1)}
+{PTS({2000/10000 = 0.200000}), DTS({1/10000 = 0.000100}), duration({999/10000 = 0.099900}), flags(0), generation(1)}
+{PTS({1000/10000 = 0.100000}), DTS({1000/10000 = 0.100000}), duration({1/10000 = 0.000100}), flags(0), generation(1)}
+{PTS({4000/10000 = 0.400000}), DTS({1001/10000 = 0.100100}), duration({999/10000 = 0.099900}), flags(0), generation(1)}
+{PTS({3000/10000 = 0.300000}), DTS({2000/10000 = 0.200000}), duration({1000/10000 = 0.100000}), flags(0), generation(1)}
+Testing the behavior is consistent when re-appending.
+RUN(sourceBuffer.appendBuffer(makeSamples(2)))
+EVENT(updateend)
+EXPECTED (bufferedSamples.length == '5') OK
+{PTS({0/10000 = 0.000000}), DTS({0/10000 = 0.000000}), duration({1/10000 = 0.000100}), flags(1), generation(2)}
+{PTS({2000/10000 = 0.200000}), DTS({1/10000 = 0.000100}), duration({999/10000 = 0.099900}), flags(0), generation(2)}
+{PTS({1000/10000 = 0.100000}), DTS({1000/10000 = 0.100000}), duration({1/10000 = 0.000100}), flags(0), generation(2)}
+{PTS({4000/10000 = 0.400000}), DTS({1001/10000 = 0.100100}), duration({999/10000 = 0.099900}), flags(0), generation(2)}
+{PTS({3000/10000 = 0.300000}), DTS({2000/10000 = 0.200000}), duration({1000/10000 = 0.100000}), flags(0), generation(2)}
+END OF TEST
+
Added: trunk/LayoutTests/media/media-source/media-source-append-tiny-durations.html (0 => 286485)
--- trunk/LayoutTests/media/media-source/media-source-append-tiny-durations.html (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-append-tiny-durations.html 2021-12-03 08:25:14 UTC (rev 286485)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>media-source-append-tiny-durations</title>
+ <script src=""
+ <script src=""
+ <script>
+ var source;
+ var sourceBuffer;
+ var initSegment;
+
+ if (window.internals)
+ internals.initializeMockMediaSource();
+
+ function makeSamples(generation) {
+ return concatenateSamples([
+ // pts, dts, dur, scale
+ makeASample( 0, 0, 1, 10000, 1, SAMPLE_FLAG.SYNC, generation),
+ makeASample(2000, 1, 999, 10000, 1, SAMPLE_FLAG.NONE, generation),
+ makeASample(1000, 1000, 1, 10000, 1, SAMPLE_FLAG.NONE, generation),
+ makeASample(4000, 1001, 999, 10000, 1, SAMPLE_FLAG.NONE, generation),
+ makeASample(3000, 2000, 1000, 10000, 1, SAMPLE_FLAG.NONE, generation),
+ ]);
+ }
+
+ window.addEventListener('load', async event => {
+
+ findMediaElement();
+
+ source = new MediaSource();
+ run('video.src = ""
+ await waitFor(source, 'sourceopen');
+
+ run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
+ initSegment = makeAInit(4, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+ run('sourceBuffer.appendBuffer(initSegment)');
+
+ await waitFor(sourceBuffer, 'updateend');
+
+ run('sourceBuffer.appendBuffer(makeSamples(1))');
+ await waitFor(sourceBuffer, 'updateend');
+ bufferedSamples = await internals.bufferedSamplesForTrackId(sourceBuffer, 1);
+ testExpected("bufferedSamples.length", 5);
+ bufferedSamples.forEach(consoleWrite);
+
+ consoleWrite("Testing the behavior is consistent when re-appending.")
+ run('sourceBuffer.appendBuffer(makeSamples(2))');
+ await waitFor(sourceBuffer, 'updateend');
+ bufferedSamples = await internals.bufferedSamplesForTrackId(sourceBuffer, 1);
+ testExpected("bufferedSamples.length", 5);
+ bufferedSamples.forEach(consoleWrite);
+
+ endTest();
+
+ }, {once: true});
+ </script>
+</head>
+<body>
+ <div>This tests that an append of non-overlapping samples of varying durations, some of them under a millisecond, don't trigger accidental erasure.
+ <br>This is done in some MP4 files, where decode durations are manipulated to code media containing B-frames while maintaining a start PTS = 0.</div>
+ <video></video>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (286484 => 286485)
--- trunk/Source/WebCore/ChangeLog 2021-12-03 08:06:10 UTC (rev 286484)
+++ trunk/Source/WebCore/ChangeLog 2021-12-03 08:25:14 UTC (rev 286485)
@@ -1,3 +1,22 @@
+2021-12-03 Alicia Boya García <ab...@igalia.com>
+
+ [MSE] Fix erase range to prevent accidental deletion in files with changing durations
+ https://bugs.webkit.org/show_bug.cgi?id=233528
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ In didReceiveSample(), eraseBeginTime was being set to
+ highestPresentationTimestamp minus a tolerance. The tolerance is not
+ needed since highestPresentationTimestamp is loaded from exact frame
+ timestamps, and can cause accidental frame erasure in situations where
+ there are frames with frames smaller than the tolerance, which is the
+ case for certain MP4 files.
+
+ Test: media/media-source/media-source-append-tiny-durations.html
+
+ * platform/graphics/SourceBufferPrivate.cpp:
+ (WebCore::SourceBufferPrivate::didReceiveSample):
+
2021-12-03 Kimmo Kinnunen <kkinnu...@apple.com>
Network process does not seem to initialize logging
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (286484 => 286485)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2021-12-03 08:06:10 UTC (rev 286484)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2021-12-03 08:25:14 UTC (rev 286485)
@@ -1169,7 +1169,7 @@
break;
MediaTime highestBufferedTime = trackBuffer.buffered.maximumBufferedTime();
- MediaTime eraseBeginTime = trackBuffer.highestPresentationTimestamp - contiguousFrameTolerance;
+ MediaTime eraseBeginTime = trackBuffer.highestPresentationTimestamp;
MediaTime eraseEndTime = frameEndTimestamp - contiguousFrameTolerance;
PresentationOrderSampleMap::iterator_range range;