- Revision
- 273604
- Author
- [email protected]
- Date
- 2021-02-26 16:32:12 -0800 (Fri, 26 Feb 2021)
Log Message
Source/WebCore:
[MSE] WebContent/GPU process will hang when appending data under some circumstances.
https://bugs.webkit.org/show_bug.cgi?id=222462
Patch by Jean-Yves Avenard <[email protected]> on 2021-02-26
Reviewed by Jer Noble.
No new test, this is covered by one of the MSE WPT.
* platform/MediaSample.h:
Add an optional parameter to MediaSample::divide to use the buffer's end time
to determine where to divide it.
* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::didReceiveSample):
When attempting to split the MediaSample so none ends after the
appendWindowEnd attribute, use the MediaSample's end time as split point.
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::divide):
Expand the divide method to split the content according to the end time.
Side fix; use OutputPresentationTimeStamp thorough the devide method.
All time and duration comparisons made in the SourceBuffer are based on
the Output times, so to ensure consistency we use the output time when
looking on where to split.
* platform/graphics/gstreamer/MediaSampleGStreamer.h:
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
Update per new declaration. New argument is unused.
Tools:
[MSE] Ensure MediaSample is properly trimmed.
https://bugs.webkit.org/show_bug.cgi?id=222462
Patch by Jean-Yves Avenard <[email protected]> on 2021-02-26
Reviewed by Jer Noble.
* TestWebKitAPI/Tests/WebCore/SampleMap.cpp:
Update per new MediaSample::divide prototype.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (273603 => 273604)
--- trunk/Source/WebCore/ChangeLog 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/ChangeLog 2021-02-27 00:32:12 UTC (rev 273604)
@@ -1,3 +1,31 @@
+2021-02-26 Jean-Yves Avenard <[email protected]>
+
+ [MSE] WebContent/GPU process will hang when appending data under some circumstances.
+ https://bugs.webkit.org/show_bug.cgi?id=222462
+
+ Reviewed by Jer Noble.
+
+ No new test, this is covered by one of the MSE WPT.
+
+ * platform/MediaSample.h:
+ Add an optional parameter to MediaSample::divide to use the buffer's end time
+ to determine where to divide it.
+ * platform/graphics/SourceBufferPrivate.cpp:
+ (WebCore::SourceBufferPrivate::didReceiveSample):
+ When attempting to split the MediaSample so none ends after the
+ appendWindowEnd attribute, use the MediaSample's end time as split point.
+ * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
+ (WebCore::MediaSampleAVFObjC::divide):
+ Expand the divide method to split the content according to the end time.
+ Side fix; use OutputPresentationTimeStamp thorough the devide method.
+ All time and duration comparisons made in the SourceBuffer are based on
+ the Output times, so to ensure consistency we use the output time when
+ looking on where to split.
+ * platform/graphics/gstreamer/MediaSampleGStreamer.h:
+ * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+ Update per new declaration. New argument is unused.
+
2021-02-26 Antoine Quint <[email protected]>
Length blending should allow for a ValueRange parameter
Modified: trunk/Source/WebCore/platform/MediaSample.h (273603 => 273604)
--- trunk/Source/WebCore/platform/MediaSample.h 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/platform/MediaSample.h 2021-02-27 00:32:12 UTC (rev 273604)
@@ -73,7 +73,11 @@
virtual void setTimestamps(const MediaTime&, const MediaTime&) = 0;
virtual bool isDivisable() const = 0;
enum DivideFlags { BeforePresentationTime, AfterPresentationTime };
- virtual std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime) = 0;
+ enum class UseEndTime : bool {
+ DoNotUse,
+ Use,
+ };
+ virtual std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime, UseEndTime = UseEndTime::DoNotUse) = 0;
virtual Ref<MediaSample> createNonDisplayingCopy() const = 0;
virtual RefPtr<JSC::Uint8ClampedArray> getRGBAImageData() const { return nullptr; }
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (273603 => 273604)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2021-02-27 00:32:12 UTC (rev 273604)
@@ -1016,9 +1016,11 @@
if (sample->isDivisable()) {
std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> replacementSamples = sample->divide(m_appendWindowStart);
if (replacementSamples.second) {
- replacementSamples = replacementSamples.second->divide(m_appendWindowEnd);
+ ASSERT(replacementSamples.second->presentationTime() >= m_appendWindowStart);
+ replacementSamples = replacementSamples.second->divide(m_appendWindowEnd, MediaSample::UseEndTime::Use);
if (replacementSamples.first) {
sample = replacementSamples.first.releaseNonNull();
+ ASSERT(sample->presentationTime() >= m_appendWindowStart && sample->presentationTime() + sample->duration() <= m_appendWindowEnd);
if (m_appendMode != SourceBufferAppendMode::Sequence && trackBuffer.roundedTimestampOffset)
sample->offsetTimestampsBy(-trackBuffer.roundedTimestampOffset);
continue;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h (273603 => 273604)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.h 2021-02-27 00:32:12 UTC (rev 273604)
@@ -61,7 +61,7 @@
void offsetTimestampsBy(const MediaTime&) override;
void setTimestamps(const MediaTime&, const MediaTime&) override;
bool isDivisable() const override;
- std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime) override;
+ std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime, UseEndTime) override;
Ref<MediaSample> createNonDisplayingCopy() const override;
VideoRotation videoRotation() const override { return m_rotation; }
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm (273603 => 273604)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm 2021-02-27 00:32:12 UTC (rev 273604)
@@ -247,7 +247,7 @@
return true;
}
-std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> MediaSampleAVFObjC::divide(const MediaTime& presentationTime)
+std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> MediaSampleAVFObjC::divide(const MediaTime& presentationTime, UseEndTime useEndTime)
{
if (!isDivisable())
return { nullptr, nullptr };
@@ -255,7 +255,18 @@
CFIndex samplesBeforePresentationTime = 0;
CMSampleBufferCallBlockForEachSample(m_sample.get(), [&] (CMSampleBufferRef sampleBuffer, CMItemCount) -> OSStatus {
- if (PAL::toMediaTime(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) >= presentationTime)
+ auto timeStamp = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer);
+ if (CMTIME_IS_INVALID(timeStamp))
+ timeStamp = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
+
+ if (useEndTime == UseEndTime::Use) {
+ auto duration = CMSampleBufferGetOutputDuration(sampleBuffer);
+ if (CMTIME_IS_INVALID(duration))
+ duration = CMSampleBufferGetDuration(sampleBuffer);
+
+ if (PAL::toMediaTime(CMTimeAdd(timeStamp, duration)) > presentationTime)
+ return 1;
+ } else if (PAL::toMediaTime(timeStamp) >= presentationTime)
return 1;
++samplesBeforePresentationTime;
return noErr;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h (273603 => 273604)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h 2021-02-27 00:32:12 UTC (rev 273604)
@@ -50,7 +50,7 @@
void offsetTimestampsBy(const MediaTime&) override;
void setTimestamps(const MediaTime&, const MediaTime&) override { }
bool isDivisable() const override { return false; }
- std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime&) override { return { nullptr, nullptr }; }
+ std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime&, UseEndTime) override { return { nullptr, nullptr }; }
Ref<MediaSample> createNonDisplayingCopy() const override;
SampleFlags flags() const override { return m_flags; }
PlatformSample platformSample() override;
Modified: trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp (273603 => 273604)
--- trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp 2021-02-27 00:32:12 UTC (rev 273604)
@@ -68,7 +68,7 @@
void offsetTimestampsBy(const MediaTime& offset) override { m_box.offsetTimestampsBy(offset); }
void setTimestamps(const MediaTime& presentationTimestamp, const MediaTime& decodeTimestamp) override { m_box.setTimestamps(presentationTimestamp, decodeTimestamp); }
bool isDivisable() const override { return false; }
- std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime&) override { return {nullptr, nullptr}; }
+ std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime&, UseEndTime) override { return {nullptr, nullptr}; }
Ref<MediaSample> createNonDisplayingCopy() const override;
unsigned generation() const { return m_box.generation(); }
Modified: trunk/Tools/ChangeLog (273603 => 273604)
--- trunk/Tools/ChangeLog 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Tools/ChangeLog 2021-02-27 00:32:12 UTC (rev 273604)
@@ -1,3 +1,13 @@
+2021-02-26 Jean-Yves Avenard <[email protected]>
+
+ [MSE] Ensure MediaSample is properly trimmed.
+ https://bugs.webkit.org/show_bug.cgi?id=222462
+
+ Reviewed by Jer Noble.
+
+ * TestWebKitAPI/Tests/WebCore/SampleMap.cpp:
+ Update per new MediaSample::divide prototype.
+
2021-02-26 John Wilander <[email protected]>
Non-cookie website data not deleted after 7 days of browser use without user interaction
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/SampleMap.cpp (273603 => 273604)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SampleMap.cpp 2021-02-27 00:29:26 UTC (rev 273603)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SampleMap.cpp 2021-02-27 00:32:12 UTC (rev 273604)
@@ -66,7 +66,7 @@
m_decodeTime = decodeTime;
};
bool isDivisable() const final { return false; }
- std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime& presentationTime) final { return { }; }
+ std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> divide(const MediaTime&, UseEndTime) final { return { }; }
Ref<MediaSample> createNonDisplayingCopy() const final {
return create(m_presentationTime, m_decodeTime, m_duration, static_cast<SampleFlags>(m_flags | IsNonDisplaying));
}