Title: [293216] trunk/Source/WebCore
- Revision
- 293216
- Author
- [email protected]
- Date
- 2022-04-22 04:40:59 -0700 (Fri, 22 Apr 2022)
Log Message
[MSE] Improve SourceBuffer memory cost reporting
https://bugs.webkit.org/show_bug.cgi?id=238948
Reviewed by Xabier Rodriguez-Calvar.
Properly implementing the memoryCost() API in SourceBuffer would improve memory
awareness when garbage collecting.
This patch extends the SourceBuffer interface with the ReportExtraMemoryCost
attribute, implements memoryCost() method for the interface and fixes
calculations for removed buffers. It distinguishes the amount of memory
increases reported (extraMemoryCostDelta, what was reported until now, can
only grow) from the total amount of memory reported (can grow and shrink).
This patch is co-authored by Andrzej Surdej (https://github.com/asurdej-comcast)
See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/827
* Modules/mediasource/SourceBuffer.cpp: Implement memoryCost() interface and hold the absolute memory consumed as m_extraMemoryCost, keeping the original m_reportedExtraMemoryCost behaviour.
* Modules/mediasource/SourceBuffer.h: Added memoryCost() and m_extraMemoryCost.
* Modules/mediasource/SourceBuffer.idl: Require the ReportExtraMemoryCost feature.
* platform/graphics/SourceBufferPrivate.cpp: Also report the memory change to SourceBuffer when evicting frames (memory reduction).
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (293215 => 293216)
--- trunk/Source/WebCore/ChangeLog 2022-04-22 11:08:58 UTC (rev 293215)
+++ trunk/Source/WebCore/ChangeLog 2022-04-22 11:40:59 UTC (rev 293216)
@@ -1,3 +1,27 @@
+2022-04-22 Enrique Ocaña González <[email protected]>
+
+ [MSE] Improve SourceBuffer memory cost reporting
+ https://bugs.webkit.org/show_bug.cgi?id=238948
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ Properly implementing the memoryCost() API in SourceBuffer would improve memory
+ awareness when garbage collecting.
+
+ This patch extends the SourceBuffer interface with the ReportExtraMemoryCost
+ attribute, implements memoryCost() method for the interface and fixes
+ calculations for removed buffers. It distinguishes the amount of memory
+ increases reported (extraMemoryCostDelta, what was reported until now, can
+ only grow) from the total amount of memory reported (can grow and shrink).
+
+ This patch is co-authored by Andrzej Surdej (https://github.com/asurdej-comcast)
+ See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/827
+
+ * Modules/mediasource/SourceBuffer.cpp: Implement memoryCost() interface and hold the absolute memory consumed as m_extraMemoryCost, keeping the original m_reportedExtraMemoryCost behaviour.
+ * Modules/mediasource/SourceBuffer.h: Added memoryCost() and m_extraMemoryCost.
+ * Modules/mediasource/SourceBuffer.idl: Require the ReportExtraMemoryCost feature.
+ * platform/graphics/SourceBufferPrivate.cpp: Also report the memory change to SourceBuffer when evicting frames (memory reduction).
+
2022-04-22 Tyler Wilcock <[email protected]>
AX: The isolated tree is not updated after role changes in AccessibilityRenderObject::updateRoleAfterChildrenCreation()
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (293215 => 293216)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2022-04-22 11:08:58 UTC (rev 293215)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2022-04-22 11:40:59 UTC (rev 293216)
@@ -1246,6 +1246,8 @@
if (m_pendingAppendData)
extraMemoryCost += m_pendingAppendData->size();
+ m_extraMemoryCost = extraMemoryCost;
+
if (extraMemoryCost <= m_reportedExtraMemoryCost)
return;
@@ -1355,6 +1357,11 @@
m_private->setMediaSourceEnded(isEnded);
}
+size_t SourceBuffer::memoryCost() const
+{
+ return sizeof(SourceBuffer) + m_extraMemoryCost;
+}
+
#if !RELEASE_LOG_DISABLED
WTFLogChannel& SourceBuffer::logChannel() const
{
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (293215 => 293216)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h 2022-04-22 11:08:58 UTC (rev 293215)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h 2022-04-22 11:40:59 UTC (rev 293216)
@@ -130,6 +130,8 @@
MediaTime highestPresentationTimestamp() const;
void readyStateChanged();
+ size_t memoryCost() const;
+
void setMediaSourceEnded(bool isEnded);
#if !RELEASE_LOG_DISABLED
@@ -245,7 +247,10 @@
double m_averageBufferRate { 0 };
bool m_bufferedDirty { true };
+ // Can only grow.
uint64_t m_reportedExtraMemoryCost { 0 };
+ // Can grow and shrink.
+ uint64_t m_extraMemoryCost { 0 };
MediaTime m_pendingRemoveStart;
MediaTime m_pendingRemoveEnd;
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl (293215 => 293216)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl 2022-04-22 11:08:58 UTC (rev 293215)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.idl 2022-04-22 11:40:59 UTC (rev 293216)
@@ -39,7 +39,8 @@
EnabledBySetting=MediaSourceEnabled,
ExportMacro=WEBCORE_EXPORT,
GenerateAddOpaqueRoot,
- Exposed=Window
+ Exposed=Window,
+ ReportExtraMemoryCost
] interface SourceBuffer : EventTarget {
attribute AppendMode mode;
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (293215 => 293216)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2022-04-22 11:08:58 UTC (rev 293215)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2022-04-22 11:40:59 UTC (rev 293216)
@@ -640,6 +640,8 @@
LOG(Media, "SourceBuffer::removeCodedFrames(%p) - buffered = %s", this, toString(m_buffered->ranges()).utf8().data());
+ m_client->sourceBufferPrivateReportExtraMemoryCost(totalTrackBufferSizeInBytes());
+
completionHandler();
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes