Diff
Modified: trunk/Source/WebCore/ChangeLog (270730 => 270731)
--- trunk/Source/WebCore/ChangeLog 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebCore/ChangeLog 2020-12-12 06:56:28 UTC (rev 270731)
@@ -1,3 +1,30 @@
+2020-12-11 Peng Liu <[email protected]>
+
+ [Media in GPU Process][MSE] Implement SourceBuffer::reportExtraMemoryAllocated()
+ https://bugs.webkit.org/show_bug.cgi?id=219812
+
+ Reviewed by Eric Carlson.
+
+ Refactor the implementation of `SourceBuffer::reportExtraMemoryAllocated()` to let
+ `SourceBufferPrivate` calculate the extra memory cost and report the value to
+ `SourceBuffer` when necessary. This approach is better than the current one when
+ `SourceBufferPrivate` runs in the GPU process because track buffer management
+ has been moved to `SourceBufferPrivate` in r270435.
+
+ * Modules/mediasource/SourceBuffer.cpp:
+ (WebCore::SourceBuffer::appendBufferInternal):
+ (WebCore::SourceBuffer::sourceBufferPrivateAppendComplete):
+ (WebCore::SourceBuffer::sourceBufferPrivateReportExtraMemoryCost):
+ (WebCore::SourceBuffer::reportExtraMemoryAllocated):
+ (WebCore::SourceBuffer::extraMemoryCost const): Deleted.
+ * Modules/mediasource/SourceBuffer.h:
+ * platform/graphics/SourceBufferPrivate.cpp:
+ (WebCore::SourceBufferPrivate::appendCompleted):
+ (WebCore::SourceBufferPrivate::evictCodedFrames):
+ * platform/graphics/SourceBufferPrivateClient.h:
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+ (WebCore::SourceBufferPrivateAVFObjC::append):
+
2020-12-11 Jiewen Tan <[email protected]>
[WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (270730 => 270731)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2020-12-12 06:56:28 UTC (rev 270731)
@@ -512,8 +512,6 @@
// 6. Asynchronously run the buffer append algorithm.
m_appendBufferTimer.startOneShot(0_s);
- reportExtraMemoryAllocated();
-
return { };
}
@@ -585,8 +583,6 @@
m_source->monitorSourceBuffers();
m_private->reenqueueMediaIfNeeded(m_source->currentTime(), m_pendingAppendData.capacity(), maximumBufferSize());
- reportExtraMemoryAllocated();
-
DEBUG_LOG(LOGIDENTIFIER);
}
@@ -1195,17 +1191,14 @@
return unbufferedTime.toDouble() / m_averageBufferRate < timeRemaining.toDouble();
}
-uint64_t SourceBuffer::extraMemoryCost() const
+void SourceBuffer::sourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory)
{
- uint64_t extraMemoryCost = m_pendingAppendData.capacity();
- extraMemoryCost += m_private->totalTrackBufferSizeInBytes();
-
- return extraMemoryCost;
+ reportExtraMemoryAllocated(extraMemory);
}
-void SourceBuffer::reportExtraMemoryAllocated()
+void SourceBuffer::reportExtraMemoryAllocated(uint64_t extraMemory)
{
- uint64_t extraMemoryCost = this->extraMemoryCost();
+ uint64_t extraMemoryCost = m_pendingAppendData.capacity() + extraMemory;
if (extraMemoryCost <= m_reportedExtraMemoryCost)
return;
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (270730 => 270731)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h 2020-12-12 06:56:28 UTC (rev 270731)
@@ -158,6 +158,7 @@
void sourceBufferPrivateBufferedDirtyChanged(bool) final;
void sourceBufferPrivateBufferedRangesChanged(const PlatformTimeRanges&) final;
void sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode) final;
+ void sourceBufferPrivateReportExtraMemoryCost(uint64_t) final;
// AudioTrackClient
void audioTrackEnabledChanged(AudioTrack&) final;
@@ -191,8 +192,7 @@
void removeTimerFired();
- uint64_t extraMemoryCost() const;
- void reportExtraMemoryAllocated();
+ void reportExtraMemoryAllocated(uint64_t extraMemory);
void appendError(bool);
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (270730 => 270731)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2020-12-12 06:56:28 UTC (rev 270731)
@@ -162,8 +162,10 @@
// into the SourceBuffer's buffered ranges
updateBufferedFromTrackBuffers(isEnded);
- if (m_client)
+ if (m_client) {
m_client->sourceBufferPrivateAppendComplete(parsingSucceeded ? SourceBufferPrivateClient::AppendResult::AppendSucceeded : SourceBufferPrivateClient::AppendResult::ParsingFailed);
+ m_client->sourceBufferPrivateReportExtraMemoryCost(totalTrackBufferSizeInBytes());
+ }
}
void SourceBufferPrivate::reenqueSamples(const AtomString& trackID)
@@ -617,9 +619,9 @@
MediaTime thirtySeconds = MediaTime(30, 1);
MediaTime maximumRangeEnd = currentTime - thirtySeconds;
-#if !RELEASE_LOG_DISABLED && false
- DEBUG_LOG(LOGIDENTIFIER, "currentTime = ", currentTime, ", require ", extraMemoryCost() + newDataSize, " bytes, maximum buffer size is ", maximumBufferSize);
- uint64_t initialBufferedSize = extraMemoryCost();
+#if !RELEASE_LOG_DISABLED
+ uint64_t initialBufferedSize = totalTrackBufferSizeInBytes();
+ DEBUG_LOG(LOGIDENTIFIER, "currentTime = ", currentTime, ", require ", initialBufferedSize + newDataSize, " bytes, maximum buffer size is ", maximumBufferSize);
#endif
MediaTime rangeStart = MediaTime::zeroTime();
@@ -638,8 +640,8 @@
}
if (!m_bufferFull) {
-#if !RELEASE_LOG_DISABLED && false
- DEBUG_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - extraMemoryCost());
+#if !RELEASE_LOG_DISABLED
+ DEBUG_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - totalTrackBufferSizeInBytes());
#endif
return;
}
@@ -650,8 +652,8 @@
auto buffered = m_buffered->ranges();
uint64_t currentTimeRange = buffered.find(currentTime);
if (currentTimeRange == buffered.length() - 1) {
-#if !RELEASE_LOG_DISABLED && false
- ERROR_LOG(LOGIDENTIFIER, "FAILED to free enough after evicting ", initialBufferedSize - extraMemoryCost());
+#if !RELEASE_LOG_DISABLED
+ ERROR_LOG(LOGIDENTIFIER, "FAILED to free enough after evicting ", initialBufferedSize - totalTrackBufferSizeInBytes());
#endif
return;
}
@@ -691,11 +693,11 @@
rangeEnd -= thirtySeconds;
}
-#if !RELEASE_LOG_DISABLED && false
+#if !RELEASE_LOG_DISABLED
if (m_bufferFull)
- ERROR_LOG(LOGIDENTIFIER, "FAILED to free enough after evicting ", initialBufferedSize - extraMemoryCost());
+ ERROR_LOG(LOGIDENTIFIER, "FAILED to free enough after evicting ", initialBufferedSize - totalTrackBufferSizeInBytes());
else
- DEBUG_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - extraMemoryCost());
+ DEBUG_LOG(LOGIDENTIFIER, "evicted ", initialBufferedSize - totalTrackBufferSizeInBytes());
#endif
}
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h (270730 => 270731)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h 2020-12-12 06:56:28 UTC (rev 270731)
@@ -66,7 +66,6 @@
};
virtual void sourceBufferPrivateDidReceiveInitializationSegment(InitializationSegment&&, CompletionHandler<void()>&&) = 0;
virtual void sourceBufferPrivateStreamEndedWithDecodeError() = 0;
-
virtual void sourceBufferPrivateAppendError(bool decodeError) = 0;
enum class AppendResult : uint8_t {
AppendSucceeded,
@@ -79,8 +78,8 @@
virtual void sourceBufferPrivateDidDropSample() = 0;
virtual void sourceBufferPrivateBufferedDirtyChanged(bool) = 0;
virtual void sourceBufferPrivateBufferedRangesChanged(const PlatformTimeRanges&) = 0;
-
virtual void sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode) = 0;
+ virtual void sourceBufferPrivateReportExtraMemoryCost(uint64_t) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (270730 => 270731)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2020-12-12 06:56:28 UTC (rev 270731)
@@ -515,6 +515,9 @@
ASSERT(!m_hasSessionSemaphore);
ASSERT(!m_abortSemaphore);
+ if (m_client)
+ m_client->sourceBufferPrivateReportExtraMemoryCost(totalTrackBufferSizeInBytes());
+
m_abortSemaphore = Box<Semaphore>::create(0);
m_parser->setWillProvideContentKeyRequestInitializationDataForTrackIDCallback([weakThis = makeWeakPtr(this), abortSemaphore = m_abortSemaphore] (uint64_t trackID) mutable {
// We must call synchronously to the main thread, as the AVStreamSession must be associated
Modified: trunk/Source/WebKit/ChangeLog (270730 => 270731)
--- trunk/Source/WebKit/ChangeLog 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebKit/ChangeLog 2020-12-12 06:56:28 UTC (rev 270731)
@@ -1,3 +1,21 @@
+2020-12-11 Peng Liu <[email protected]>
+
+ [Media in GPU Process][MSE] Implement SourceBuffer::reportExtraMemoryAllocated()
+ https://bugs.webkit.org/show_bug.cgi?id=219812
+
+ Reviewed by Eric Carlson.
+
+ Add a new IPC message `SourceBufferPrivateReportExtraMemoryCost` to forward the callback
+ to the web process.
+
+ * GPUProcess/media/RemoteSourceBufferProxy.cpp:
+ (WebKit::RemoteSourceBufferProxy::sourceBufferPrivateReportExtraMemoryCost):
+ * GPUProcess/media/RemoteSourceBufferProxy.h:
+ * WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
+ (WebKit::SourceBufferPrivateRemote::sourceBufferPrivateReportExtraMemoryCost):
+ * WebProcess/GPU/media/SourceBufferPrivateRemote.h:
+ * WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in:
+
2020-12-11 Jiewen Tan <[email protected]>
[WebAuthn] Adopt new UI for the Platform Authenticator getAssertion flow
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp (270730 => 270731)
--- trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp 2020-12-12 06:56:28 UTC (rev 270731)
@@ -138,6 +138,11 @@
m_connectionToWebProcess.connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateDidReceiveRenderingError(errorCode), m_identifier);
}
+void RemoteSourceBufferProxy::sourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory)
+{
+ m_connectionToWebProcess.connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateReportExtraMemoryCost(extraMemory), m_identifier);
+}
+
void RemoteSourceBufferProxy::sourceBufferPrivateBufferedDirtyChanged(bool flag)
{
m_connectionToWebProcess.connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateBufferedDirtyChanged(flag), m_identifier);
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h (270730 => 270731)
--- trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h 2020-12-12 06:56:28 UTC (rev 270731)
@@ -75,8 +75,8 @@
void sourceBufferPrivateDidDropSample() final;
void sourceBufferPrivateBufferedDirtyChanged(bool) final;
void sourceBufferPrivateBufferedRangesChanged(const WebCore::PlatformTimeRanges&) final;
-
void sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode) final;
+ void sourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory) final;
// IPC::MessageReceiver
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
Modified: trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp (270730 => 270731)
--- trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp 2020-12-12 06:56:28 UTC (rev 270731)
@@ -247,6 +247,12 @@
m_client->sourceBufferPrivateDidReceiveRenderingError(errorCode);
}
+void SourceBufferPrivateRemote::sourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory)
+{
+ if (m_client)
+ m_client->sourceBufferPrivateReportExtraMemoryCost(extraMemory);
+}
+
#if !RELEASE_LOG_DISABLED
WTFLogChannel& SourceBufferPrivateRemote::logChannel() const
{
Modified: trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h (270730 => 270731)
--- trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h 2020-12-12 06:56:28 UTC (rev 270731)
@@ -100,6 +100,7 @@
void sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode);
void sourceBufferPrivateBufferedDirtyChanged(bool dirty);
void sourceBufferPrivateBufferedRangesChanged(const WebCore::PlatformTimeRanges&);
+ void sourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory);
GPUProcessConnection& m_gpuProcessConnection;
RemoteSourceBufferIdentifier m_remoteSourceBufferIdentifier;
Modified: trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in (270730 => 270731)
--- trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in 2020-12-12 05:19:32 UTC (rev 270730)
+++ trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in 2020-12-12 06:56:28 UTC (rev 270731)
@@ -36,6 +36,7 @@
SourceBufferPrivateBufferedDirtyChanged(bool dirty)
SourceBufferPrivateBufferedRangesChanged(WebCore::PlatformTimeRanges timeRanges)
SourceBufferPrivateDidReceiveRenderingError(int64_t errorCode)
+ SourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory)
}
#endif