Title: [274390] trunk
Revision
274390
Author
[email protected]
Date
2021-03-13 11:08:22 -0800 (Sat, 13 Mar 2021)

Log Message

[GPUP][MSE] MediaSource::buffered and MediaSource::activeSourceBuffers do not update in the same run loop as MediaSource::endOfStream()
https://bugs.webkit.org/show_bug.cgi?id=221293

Reviewed by Jer Noble.

Source/WebCore:

Currently, both `SourceBuffer` and `SourceBufferPrivate` own an `m_buffered`
and we need to synchronize them with a callback. When we run `SourceBufferPrivate`
in the GPU process, the synchronization might be delayed, e.g., function
`SourceBuffer::readyStateChanged()` will trigger an update to `m_buffered`
but its new value won't be available for the Web process in the same
run loop.

To fix this issue, this patch removes `SourceBuffer::m_buffered` as well
the callback to synchronize it. When we run `SourceBufferPrivate` in the GPU
process, `SourceBufferPrivateRemote` synchronizes its `m_buffered` with
`SourceBufferPrivate` through a synchronous IPC message.

No new tests. Fix a test failure:
- imported/w3c/web-platform-tests/media-source/mediasource-buffered.html

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::SourceBuffer):
(WebCore::SourceBuffer::buffered const):
(WebCore::SourceBuffer::sourceBufferPrivateBufferedRangesChanged): Deleted.
* Modules/mediasource/SourceBuffer.h:
* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::setBufferedRanges):
(WebCore::SourceBufferPrivate::updateBufferedFromTrackBuffers):
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::buffered const):
* platform/graphics/SourceBufferPrivateClient.h:

Source/WebKit:

When a Web process needs to "pull" the latest value of `m_buffered` from the
GPU process (`updateBufferedFromTrackBuffers`), we need to use a synchronous
IPC message.

When the GPU process needs to "push" the latest value of `m_buffered` to
a Web process, we can use an asynchronous message, e.g, `RemoveCodedFrames`
and `SourceBufferPrivateAppendComplete`.

* GPUProcess/media/RemoteSourceBufferProxy.cpp:
(WebKit::RemoteSourceBufferProxy::sourceBufferPrivateAppendComplete):
(WebKit::RemoteSourceBufferProxy::updateBufferedFromTrackBuffers):
(WebKit::RemoteSourceBufferProxy::removeCodedFrames):
(WebKit::RemoteSourceBufferProxy::sourceBufferPrivateBufferedRangesChanged): Deleted.
* GPUProcess/media/RemoteSourceBufferProxy.h:
* GPUProcess/media/RemoteSourceBufferProxy.messages.in:

* WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::updateBufferedFromTrackBuffers):
(WebKit::SourceBufferPrivateRemote::removeCodedFrames):
(WebKit::SourceBufferPrivateRemote::sourceBufferPrivateAppendComplete):
(WebKit::SourceBufferPrivateRemote::sourceBufferPrivateBufferedRangesChanged): Deleted.
* WebProcess/GPU/media/SourceBufferPrivateRemote.h:
* WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in:

LayoutTests:

* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274389 => 274390)


--- trunk/LayoutTests/ChangeLog	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/LayoutTests/ChangeLog	2021-03-13 19:08:22 UTC (rev 274390)
@@ -1,3 +1,12 @@
+2021-03-13  Peng Liu  <[email protected]>
+
+        [GPUP][MSE] MediaSource::buffered and MediaSource::activeSourceBuffers do not update in the same run loop as MediaSource::endOfStream()
+        https://bugs.webkit.org/show_bug.cgi?id=221293
+
+        Reviewed by Jer Noble.
+
+        * platform/mac/TestExpectations:
+
 2021-03-13  Rob Buis  <[email protected]>
 
         [css-flexbox] Fix incorrect relative path

Modified: trunk/LayoutTests/platform/mac/TestExpectations (274389 => 274390)


--- trunk/LayoutTests/platform/mac/TestExpectations	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2021-03-13 19:08:22 UTC (rev 274390)
@@ -865,7 +865,6 @@
 webkit.org/b/214166 imported/w3c/web-platform-tests/media-source/idlharness.window.html [ Skip ]
 
 # webkit.org/b/221686
-imported/w3c/web-platform-tests/media-source/mediasource-buffered.html [ Failure ]
 imported/w3c/web-platform-tests/media-source/mediasource-changetype.html [ Failure ]
 imported/w3c/web-platform-tests/media-source/mediasource-duration-boundaryconditions.html [ Failure ]
 imported/w3c/web-platform-tests/media-source/mediasource-remove.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (274389 => 274390)


--- trunk/Source/WebCore/ChangeLog	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebCore/ChangeLog	2021-03-13 19:08:22 UTC (rev 274390)
@@ -1,3 +1,37 @@
+2021-03-13  Peng Liu  <[email protected]>
+
+        [GPUP][MSE] MediaSource::buffered and MediaSource::activeSourceBuffers do not update in the same run loop as MediaSource::endOfStream()
+        https://bugs.webkit.org/show_bug.cgi?id=221293
+
+        Reviewed by Jer Noble.
+
+        Currently, both `SourceBuffer` and `SourceBufferPrivate` own an `m_buffered`
+        and we need to synchronize them with a callback. When we run `SourceBufferPrivate`
+        in the GPU process, the synchronization might be delayed, e.g., function
+        `SourceBuffer::readyStateChanged()` will trigger an update to `m_buffered`
+        but its new value won't be available for the Web process in the same
+        run loop.
+
+        To fix this issue, this patch removes `SourceBuffer::m_buffered` as well
+        the callback to synchronize it. When we run `SourceBufferPrivate` in the GPU
+        process, `SourceBufferPrivateRemote` synchronizes its `m_buffered` with
+        `SourceBufferPrivate` through a synchronous IPC message.
+
+        No new tests. Fix a test failure:
+        - imported/w3c/web-platform-tests/media-source/mediasource-buffered.html
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::SourceBuffer):
+        (WebCore::SourceBuffer::buffered const):
+        (WebCore::SourceBuffer::sourceBufferPrivateBufferedRangesChanged): Deleted.
+        * Modules/mediasource/SourceBuffer.h:
+        * platform/graphics/SourceBufferPrivate.cpp:
+        (WebCore::SourceBufferPrivate::setBufferedRanges):
+        (WebCore::SourceBufferPrivate::updateBufferedFromTrackBuffers):
+        * platform/graphics/SourceBufferPrivate.h:
+        (WebCore::SourceBufferPrivate::buffered const):
+        * platform/graphics/SourceBufferPrivateClient.h:
+
 2021-03-13  Zalan Bujtas  <[email protected]>
 
         Mark the line dirty when list marker goes from inline to block

Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (274389 => 274390)


--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2021-03-13 19:08:22 UTC (rev 274390)
@@ -81,7 +81,6 @@
     , m_appendWindowEnd(MediaTime::positiveInfiniteTime())
     , m_appendState(WaitingForSegment)
     , m_timeOfBufferingMonitor(MonotonicTime::now())
-    , m_buffered(TimeRanges::create())
     , m_pendingRemoveStart(MediaTime::invalidTime())
     , m_pendingRemoveEnd(MediaTime::invalidTime())
     , m_removeTimer(*this, &SourceBuffer::removeTimerFired)
@@ -116,7 +115,7 @@
         return Exception { InvalidStateError };
 
     // 2. Return a new static normalized TimeRanges object for the media segments buffered.
-    return m_buffered->copy();
+    return m_private->buffered()->copy();
 }
 
 double SourceBuffer::timestampOffset() const
@@ -1294,11 +1293,6 @@
     m_bufferedDirty = flag;
 }
 
-void SourceBuffer::sourceBufferPrivateBufferedRangesChanged(const PlatformTimeRanges& timeRanges)
-{
-    m_buffered->ranges() = timeRanges;
-}
-
 bool SourceBuffer::isBufferedDirty() const
 {
     return m_bufferedDirty;

Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (274389 => 274390)


--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h	2021-03-13 19:08:22 UTC (rev 274390)
@@ -96,7 +96,7 @@
     ExceptionOr<void> remove(const MediaTime&, const MediaTime&);
     ExceptionOr<void> changeType(const String&);
 
-    const TimeRanges& bufferedInternal() const { ASSERT(m_buffered); return *m_buffered; }
+    const TimeRanges& bufferedInternal() const { ASSERT(m_private->buffered()); return *m_private->buffered(); }
 
     void abortIfUpdating();
     void removedFromMediaSource();
@@ -157,7 +157,6 @@
     void sourceBufferPrivateDidParseSample(double sampleDuration) final;
     void sourceBufferPrivateDidDropSample() final;
     void sourceBufferPrivateBufferedDirtyChanged(bool) final;
-    void sourceBufferPrivateBufferedRangesChanged(const PlatformTimeRanges&) final;
     void sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode) final;
     void sourceBufferPrivateReportExtraMemoryCost(uint64_t) final;
 
@@ -234,7 +233,6 @@
     double m_bufferedSinceLastMonitor { 0 };
     double m_averageBufferRate { 0 };
     bool m_bufferedDirty { true };
-    RefPtr<TimeRanges> m_buffered;
 
     uint64_t m_reportedExtraMemoryCost { 0 };
 

Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (274389 => 274390)


--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp	2021-03-13 19:08:22 UTC (rev 274390)
@@ -113,8 +113,7 @@
 void SourceBufferPrivate::setBufferedRanges(const PlatformTimeRanges& timeRanges)
 {
     m_buffered->ranges() = timeRanges;
-    if (m_client)
-        m_client->sourceBufferPrivateBufferedRangesChanged(m_buffered->ranges());
+    setBufferedDirty(true);
 }
 
 void SourceBufferPrivate::updateBufferedFromTrackBuffers(bool sourceIsEnded)
@@ -159,7 +158,6 @@
     // 5. If intersection ranges does not contain the exact same range information as the current value of this attribute,
     //    then update the current value of this attribute to intersection ranges.
     setBufferedRanges(intersectionRanges);
-    setBufferedDirty(true);
 }
 
 void SourceBufferPrivate::appendCompleted(bool parsingSucceeded, bool isEnded)

Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h (274389 => 274390)


--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.h	2021-03-13 19:08:22 UTC (rev 274390)
@@ -99,6 +99,8 @@
     void setClient(SourceBufferPrivateClient* client) { m_client = client; }
     void setIsAttached(bool flag) { m_isAttached = flag; }
 
+    const TimeRanges* buffered() const { return m_buffered.get(); }
+
     bool bufferFull() const { return m_bufferFull; }
 
     // Methods used by MediaSourcePrivate
@@ -162,6 +164,7 @@
     void reenqueSamples(const AtomString& trackID);
     WEBCORE_EXPORT void didReceiveInitializationSegment(SourceBufferPrivateClient::InitializationSegment&&, CompletionHandler<void()>&&);
     WEBCORE_EXPORT void didReceiveSample(Ref<MediaSample>&&);
+    WEBCORE_EXPORT void setBufferedRanges(const PlatformTimeRanges&);
     void provideMediaData(const AtomString& trackID);
     uint64_t totalTrackBufferSizeInBytes() const;
 
@@ -173,7 +176,6 @@
     void reenqueueMediaForTime(TrackBuffer&, const AtomString& trackID, const MediaTime&);
     bool validateInitializationSegment(const SourceBufferPrivateClient::InitializationSegment&);
     void provideMediaData(TrackBuffer&, const AtomString& trackID);
-    void setBufferedRanges(const PlatformTimeRanges&);
     void setBufferedDirty(bool);
     void trySignalAllSamplesInTrackEnqueued(TrackBuffer&, const AtomString& trackID);
 

Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h (274389 => 274390)


--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h	2021-03-13 19:08:22 UTC (rev 274390)
@@ -78,7 +78,6 @@
     virtual void sourceBufferPrivateDidParseSample(double frameDuration) = 0;
     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;
 };

Modified: trunk/Source/WebKit/ChangeLog (274389 => 274390)


--- trunk/Source/WebKit/ChangeLog	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/ChangeLog	2021-03-13 19:08:22 UTC (rev 274390)
@@ -1,3 +1,34 @@
+2021-03-13  Peng Liu  <[email protected]>
+
+        [GPUP][MSE] MediaSource::buffered and MediaSource::activeSourceBuffers do not update in the same run loop as MediaSource::endOfStream()
+        https://bugs.webkit.org/show_bug.cgi?id=221293
+
+        Reviewed by Jer Noble.
+
+        When a Web process needs to "pull" the latest value of `m_buffered` from the
+        GPU process (`updateBufferedFromTrackBuffers`), we need to use a synchronous
+        IPC message.
+
+        When the GPU process needs to "push" the latest value of `m_buffered` to
+        a Web process, we can use an asynchronous message, e.g, `RemoveCodedFrames`
+        and `SourceBufferPrivateAppendComplete`.
+
+        * GPUProcess/media/RemoteSourceBufferProxy.cpp:
+        (WebKit::RemoteSourceBufferProxy::sourceBufferPrivateAppendComplete):
+        (WebKit::RemoteSourceBufferProxy::updateBufferedFromTrackBuffers):
+        (WebKit::RemoteSourceBufferProxy::removeCodedFrames):
+        (WebKit::RemoteSourceBufferProxy::sourceBufferPrivateBufferedRangesChanged): Deleted.
+        * GPUProcess/media/RemoteSourceBufferProxy.h:
+        * GPUProcess/media/RemoteSourceBufferProxy.messages.in:
+
+        * WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
+        (WebKit::SourceBufferPrivateRemote::updateBufferedFromTrackBuffers):
+        (WebKit::SourceBufferPrivateRemote::removeCodedFrames):
+        (WebKit::SourceBufferPrivateRemote::sourceBufferPrivateAppendComplete):
+        (WebKit::SourceBufferPrivateRemote::sourceBufferPrivateBufferedRangesChanged): Deleted.
+        * WebProcess/GPU/media/SourceBufferPrivateRemote.h:
+        * WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in:
+
 2021-03-13  Philippe Normand  <[email protected]>
 
         Unreviewed, fix build warnings after r273204 and r274323

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp (274389 => 274390)


--- trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp	2021-03-13 19:08:22 UTC (rev 274390)
@@ -163,7 +163,8 @@
     if (!m_connectionToWebProcess)
         return;
 
-    m_connectionToWebProcess->connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateAppendComplete(appendResult), m_identifier);
+    auto buffered = m_sourceBufferPrivate->buffered()->ranges();
+    m_connectionToWebProcess->connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateAppendComplete(appendResult, WTFMove(buffered)), m_identifier);
 }
 
 void RemoteSourceBufferProxy::sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode)
@@ -190,14 +191,6 @@
     m_connectionToWebProcess->connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateBufferedDirtyChanged(flag), m_identifier);
 }
 
-void RemoteSourceBufferProxy::sourceBufferPrivateBufferedRangesChanged(const PlatformTimeRanges& timeRanges)
-{
-    if (!m_connectionToWebProcess)
-        return;
-
-    m_connectionToWebProcess->connection().send(Messages::SourceBufferPrivateRemote::SourceBufferPrivateBufferedRangesChanged(timeRanges), m_identifier);
-}
-
 void RemoteSourceBufferProxy::append(const IPC::DataReference& data)
 {
     m_sourceBufferPrivate->append(data.vector());
@@ -243,14 +236,19 @@
     m_sourceBufferPrivate->startChangingType();
 }
 
-void RemoteSourceBufferProxy::updateBufferedFromTrackBuffers(bool sourceIsEnded)
+void RemoteSourceBufferProxy::updateBufferedFromTrackBuffers(bool sourceIsEnded, CompletionHandler<void(WebCore::PlatformTimeRanges&&)>&& completionHandler)
 {
     m_sourceBufferPrivate->updateBufferedFromTrackBuffers(sourceIsEnded);
+    auto buffered = m_sourceBufferPrivate->buffered()->ranges();
+    completionHandler(WTFMove(buffered));
 }
 
-void RemoteSourceBufferProxy::removeCodedFrames(const MediaTime& start, const MediaTime& end, const MediaTime& currentTime, bool isEnded, CompletionHandler<void()>&& completionHandler)
+void RemoteSourceBufferProxy::removeCodedFrames(const MediaTime& start, const MediaTime& end, const MediaTime& currentTime, bool isEnded, CompletionHandler<void(PlatformTimeRanges&&)>&& completionHandler)
 {
-    m_sourceBufferPrivate->removeCodedFrames(start, end, currentTime, isEnded, WTFMove(completionHandler));
+    m_sourceBufferPrivate->removeCodedFrames(start, end, currentTime, isEnded, [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
+        auto buffered = m_sourceBufferPrivate->buffered()->ranges();
+        completionHandler(WTFMove(buffered));
+    });
 }
 
 void RemoteSourceBufferProxy::evictCodedFrames(uint64_t newDataSize, uint64_t pendingAppendDataCapacity, uint64_t maximumBufferSize, const MediaTime& currentTime, const MediaTime& duration, bool isEnded)

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h (274389 => 274390)


--- trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h	2021-03-13 19:08:22 UTC (rev 274390)
@@ -75,13 +75,12 @@
     void sourceBufferPrivateDidParseSample(double sampleDuration) final;
     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;
-    // bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) final;
+    bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) final;
 
     void setActive(bool);
     void setMode(WebCore::SourceBufferAppendMode);
@@ -92,8 +91,8 @@
     void setMediaSourceEnded(bool);
     void setReadyState(WebCore::MediaPlayer::ReadyState);
     void startChangingType();
-    void updateBufferedFromTrackBuffers(bool sourceIsEnded);
-    void removeCodedFrames(const MediaTime& start, const MediaTime& end, const MediaTime& currentTime, bool isEnded, CompletionHandler<void()>&&);
+    void updateBufferedFromTrackBuffers(bool sourceIsEnded, CompletionHandler<void(WebCore::PlatformTimeRanges&&)>&&);
+    void removeCodedFrames(const MediaTime& start, const MediaTime& end, const MediaTime& currentTime, bool isEnded, CompletionHandler<void(WebCore::PlatformTimeRanges&&)>&&);
     void evictCodedFrames(uint64_t newDataSize, uint64_t pendingAppendDataCapacity, uint64_t maximumBufferSize, const MediaTime& currentTime, const MediaTime& duration, bool isEnded);
     void addTrackBuffer(TrackPrivateRemoteIdentifier);
     void resetTrackBuffers();

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.messages.in (274389 => 274390)


--- trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.messages.in	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.messages.in	2021-03-13 19:08:22 UTC (rev 274390)
@@ -35,12 +35,12 @@
     SetMediaSourceEnded(bool isEnded)
     SetReadyState(WebCore::MediaPlayer::ReadyState state)
     StartChangingType()
-    UpdateBufferedFromTrackBuffers(bool sourceIsEnded)
+    UpdateBufferedFromTrackBuffers(bool sourceIsEnded) -> (WebCore::PlatformTimeRanges buffered) Synchronous
     AddTrackBuffer(WebKit::TrackPrivateRemoteIdentifier remoteIdentifier)
     ResetTrackBuffers()
     ClearTrackBuffers()
     SetAllTrackBuffersNeedRandomAccess()
-    RemoveCodedFrames(MediaTime start, MediaTime end, MediaTime currentTime, bool isEnded) -> () Async
+    RemoveCodedFrames(MediaTime start, MediaTime end, MediaTime currentTime, bool isEnded) -> (WebCore::PlatformTimeRanges buffered) Async
     EvictCodedFrames(uint64_t newDataSize, uint64_t pendingAppendDataCapacity, uint64_t maximumBufferSize, MediaTime currentTime, MediaTime duration, bool isEnded)
     ReenqueueMediaIfNeeded(MediaTime currentMediaTime, uint64_t pendingAppendDataCapacity, uint64_t maximumBufferSize)
     SetGroupStartTimestamp(MediaTime timestamp)

Modified: trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp (274389 => 274390)


--- trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp	2021-03-13 19:08:22 UTC (rev 274390)
@@ -169,7 +169,11 @@
     if (!m_gpuProcessConnection)
         return;
 
-    m_gpuProcessConnection->connection().send(Messages::RemoteSourceBufferProxy::UpdateBufferedFromTrackBuffers(sourceIsEnded), m_remoteSourceBufferIdentifier);
+    PlatformTimeRanges buffered;
+    if (!m_gpuProcessConnection->connection().sendSync(Messages::RemoteSourceBufferProxy::UpdateBufferedFromTrackBuffers(sourceIsEnded), Messages::RemoteSourceBufferProxy::UpdateBufferedFromTrackBuffers::Reply(buffered), m_remoteSourceBufferIdentifier))
+        return;
+
+    setBufferedRanges(buffered);
 }
 
 void SourceBufferPrivateRemote::removeCodedFrames(const MediaTime& start, const MediaTime& end, const MediaTime& currentMediaTime, bool isEnded, CompletionHandler<void()>&& completionHandler)
@@ -177,7 +181,10 @@
     if (!m_gpuProcessConnection)
         return;
 
-    m_gpuProcessConnection->connection().sendWithAsyncReply(Messages::RemoteSourceBufferProxy::RemoveCodedFrames(start, end, currentMediaTime, isEnded), WTFMove(completionHandler), m_remoteSourceBufferIdentifier);
+    m_gpuProcessConnection->connection().sendWithAsyncReply(Messages::RemoteSourceBufferProxy::RemoveCodedFrames(start, end, currentMediaTime, isEnded), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](auto&& buffered) mutable {
+        setBufferedRanges(buffered);
+        completionHandler();
+    }, m_remoteSourceBufferIdentifier);
 }
 
 void SourceBufferPrivateRemote::evictCodedFrames(uint64_t newDataSize, uint64_t pendingAppendDataCapacity, uint64_t maximumBufferSize, const MediaTime& currentTime, const MediaTime& duration, bool isEnded)
@@ -380,8 +387,9 @@
         m_client->sourceBufferPrivateAppendError(decodeError);
 }
 
-void SourceBufferPrivateRemote::sourceBufferPrivateAppendComplete(SourceBufferPrivateClient::AppendResult appendResult)
+void SourceBufferPrivateRemote::sourceBufferPrivateAppendComplete(SourceBufferPrivateClient::AppendResult appendResult, const PlatformTimeRanges& buffered)
 {
+    setBufferedRanges(buffered);
     if (m_client)
         m_client->sourceBufferPrivateAppendComplete(appendResult);
 }
@@ -416,12 +424,6 @@
         m_client->sourceBufferPrivateBufferedDirtyChanged(dirty);
 }
 
-void SourceBufferPrivateRemote::sourceBufferPrivateBufferedRangesChanged(const WebCore::PlatformTimeRanges& timeRanges)
-{
-    if (m_client)
-        m_client->sourceBufferPrivateBufferedRangesChanged(timeRanges);
-}
-
 void SourceBufferPrivateRemote::sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode)
 {
     if (m_client)

Modified: trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h (274389 => 274390)


--- trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h	2021-03-13 19:08:22 UTC (rev 274390)
@@ -109,7 +109,7 @@
     void sourceBufferPrivateDidReceiveInitializationSegment(InitializationSegmentInfo&&, CompletionHandler<void()>&&);
     void sourceBufferPrivateStreamEndedWithDecodeError();
     void sourceBufferPrivateAppendError(bool decodeError);
-    void sourceBufferPrivateAppendComplete(WebCore::SourceBufferPrivateClient::AppendResult);
+    void sourceBufferPrivateAppendComplete(WebCore::SourceBufferPrivateClient::AppendResult, const WebCore::PlatformTimeRanges& buffered);
     void sourceBufferPrivateHighestPresentationTimestampChanged(const MediaTime&);
     void sourceBufferPrivateDurationChanged(const MediaTime&);
     void sourceBufferPrivateDidParseSample(double sampleDuration);
@@ -116,7 +116,6 @@
     void sourceBufferPrivateDidDropSample();
     void sourceBufferPrivateDidReceiveRenderingError(int64_t errorCode);
     void sourceBufferPrivateBufferedDirtyChanged(bool dirty);
-    void sourceBufferPrivateBufferedRangesChanged(const WebCore::PlatformTimeRanges&);
     void sourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory);
 
     WeakPtr<GPUProcessConnection> m_gpuProcessConnection;

Modified: trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in (274389 => 274390)


--- trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in	2021-03-13 16:26:21 UTC (rev 274389)
+++ trunk/Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in	2021-03-13 19:08:22 UTC (rev 274390)
@@ -29,13 +29,12 @@
     SourceBufferPrivateDidReceiveInitializationSegment(struct WebKit::InitializationSegmentInfo segmentConfiguration) -> () Async
     SourceBufferPrivateStreamEndedWithDecodeError()
     SourceBufferPrivateAppendError(bool decodeError)
-    SourceBufferPrivateAppendComplete(WebCore::SourceBufferPrivateClient::AppendResult appendResult)
+    SourceBufferPrivateAppendComplete(WebCore::SourceBufferPrivateClient::AppendResult appendResult, WebCore::PlatformTimeRanges buffered)
     SourceBufferPrivateHighestPresentationTimestampChanged(MediaTime timestamp)
     SourceBufferPrivateDurationChanged(MediaTime duration)
     SourceBufferPrivateDidParseSample(double sampleDuration)
     SourceBufferPrivateDidDropSample()
     SourceBufferPrivateBufferedDirtyChanged(bool dirty)
-    SourceBufferPrivateBufferedRangesChanged(WebCore::PlatformTimeRanges timeRanges)
     SourceBufferPrivateDidReceiveRenderingError(int64_t errorCode)
     SourceBufferPrivateReportExtraMemoryCost(uint64_t extraMemory)
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to