Title: [277116] trunk/Source
Revision
277116
Author
[email protected]
Date
2021-05-06 13:49:28 -0700 (Thu, 06 May 2021)

Log Message

[GPUP] Reduce MediaPlayer polling frequency when possible
https://bugs.webkit.org/show_bug.cgi?id=225396
<rdar://problem/77562643>

Reviewed by Jer Noble.

Source/WebCore:

Add a currentTime changed callback to MediaPlayerPrivateInterface so a client
doens't have to poll for time changes.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::setCurrentTimeDidChangeCallback):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setCurrentTimeDidChangeCallback):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTimeDidChangeCallback):
(WebCore::MediaPlayerPrivateAVFoundationObjC::currentMediaTimeDidChange const):

Source/WebKit:

When the MediaPlayerPrivate supports the new "current time changed" callback, use it
know when currentTime changes instead of polling at a fixed frequency. Current time
changes much more frequently than the other state that needs to be pushed to the
web process periodically so split current time out of the "cached state" struct
and push it separately when it changes, which also allow us to reduce the polling
frequency significantly.

Some of the state we were updating every time the cached state timer fired only
changes at known times, so reduce the number of things updated every time state
is pushed.

* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::getConfiguration): Set the timeChanged callback.
(WebKit::RemoteMediaPlayerProxy::mediaPlayerNetworkStateChanged): Update cached
readyState and networkState since they aren't updated by updateCachedState.
(WebKit::RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged): Ditto.
(WebKit::RemoteMediaPlayerProxy::mediaPlayerDurationChanged): Update cached duration.
(WebKit::RemoteMediaPlayerProxy::mediaPlayerCharacteristicChanged): Update hasAudio
and hasVideo.
(WebKit::RemoteMediaPlayerProxy::startUpdateCachedStateMessageTimer): Decrease the
time frequency to 200ms when the player supports the time change callback. Decrease
it to 250ms even when it doesn't because we interpolate time in the WP anyway.
(WebKit::RemoteMediaPlayerProxy::currentTimeChanged): Send the time change.
(WebKit::RemoteMediaPlayerProxy::updateCachedState): Send CurrentTimeChanged if
the player doesn't support the new callback. Don't update properties that change
at predictable times.
* GPUProcess/media/RemoteMediaPlayerProxy.h:

* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::pause): Use m_cachedMediaTime and m_cachedMediaTimeQueryTime
instead of m_cachedState.currentTime and m_cachedState.timestamp.
(WebKit::MediaPlayerPrivateRemote::currentMediaTime const): Ditto.
(WebKit::MediaPlayerPrivateRemote::playbackStateChanged): Ditto.
(WebKit::MediaPlayerPrivateRemote::currentTimeChanged): Update time instance variables.
(WebKit::MediaPlayerPrivateRemote::updateCachedState):
(WebKit::MediaPlayerPrivateRemote::performTaskAtMediaTime): Use m_cachedMediaTime
and m_cachedMediaTimeQueryTime instead of m_cachedState.currentTime and m_cachedState.timestamp.
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in:

* WebProcess/GPU/media/RemoteMediaPlayerState.h:
(WebKit::RemoteMediaPlayerState::encode const): Remove currentTime and timestamp.
(WebKit::RemoteMediaPlayerState::decode): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (277115 => 277116)


--- trunk/Source/WebCore/ChangeLog	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebCore/ChangeLog	2021-05-06 20:49:28 UTC (rev 277116)
@@ -1,3 +1,24 @@
+2021-05-06  Eric Carlson  <[email protected]>
+
+        [GPUP] Reduce MediaPlayer polling frequency when possible
+        https://bugs.webkit.org/show_bug.cgi?id=225396
+        <rdar://problem/77562643>
+
+        Reviewed by Jer Noble.
+
+        Add a currentTime changed callback to MediaPlayerPrivateInterface so a client
+        doens't have to poll for time changes.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::setCurrentTimeDidChangeCallback):
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::setCurrentTimeDidChangeCallback):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTimeDidChangeCallback):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::currentMediaTimeDidChange const):
+
 2021-05-06  Antoine Quint  <[email protected]>
 
         CSS custom properties on pseudo elements background gradients causes infinite layout and high CPU load

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (277115 => 277116)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2021-05-06 20:49:28 UTC (rev 277116)
@@ -713,6 +713,11 @@
     return m_private->currentMediaTime();
 }
 
+bool MediaPlayer::setCurrentTimeDidChangeCallback(CurrentTimeDidChangeCallback&& callback)
+{
+    return m_private->setCurrentTimeDidChangeCallback(WTFMove(callback));
+}
+
 MediaTime MediaPlayer::getStartDate() const
 {
     return m_private->getStartDate();

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (277115 => 277116)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2021-05-06 20:49:28 UTC (rev 277116)
@@ -396,6 +396,9 @@
     void seekWhenPossible(const MediaTime&);
     void seekWithTolerance(const MediaTime&, const MediaTime& negativeTolerance, const MediaTime& positiveTolerance);
 
+    using CurrentTimeDidChangeCallback = std::function<void(const MediaTime&)>;
+    bool setCurrentTimeDidChangeCallback(CurrentTimeDidChangeCallback&&);
+
     MediaTime startTime() const;
     MediaTime initialTime() const;
 

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (277115 => 277116)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2021-05-06 20:49:28 UTC (rev 277116)
@@ -106,6 +106,8 @@
     virtual double currentTimeDouble() const { return currentTime(); }
     virtual MediaTime currentMediaTime() const { return MediaTime::createWithDouble(currentTimeDouble()); }
 
+    virtual bool setCurrentTimeDidChangeCallback(MediaPlayer::CurrentTimeDidChangeCallback&&) { return false; }
+
     virtual MediaTime getStartDate() const { return MediaTime::createWithDouble(std::numeric_limits<double>::quiet_NaN()); }
 
     virtual void seek(float) { }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (277115 => 277116)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2021-05-06 20:49:28 UTC (rev 277116)
@@ -322,6 +322,7 @@
     void audioOutputDeviceChanged() final;
 
     void currentMediaTimeDidChange(MediaTime&&) const;
+    bool setCurrentTimeDidChangeCallback(MediaPlayer::CurrentTimeDidChangeCallback&&) final;
 
     RetainPtr<AVURLAsset> m_avAsset;
     RetainPtr<AVPlayer> m_avPlayer;
@@ -394,6 +395,7 @@
     RetainPtr<NSArray> m_currentMetaData;
     FloatSize m_cachedPresentationSize;
     MediaTime m_cachedDuration;
+    mutable MediaPlayer::CurrentTimeDidChangeCallback m_currentTimeDidChangeCallback;
     mutable MediaTime m_cachedCurrentMediaTime;
     mutable Optional<WallTime> m_wallClockAtCachedCurrentTime;
     mutable int m_timeControlStatusAtCachedCurrentTime { 0 };

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (277115 => 277116)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-05-06 20:49:28 UTC (rev 277116)
@@ -1453,12 +1453,21 @@
     return std::min(std::max(itemTime, MediaTime::zeroTime()), m_cachedDuration);
 }
 
-void MediaPlayerPrivateAVFoundationObjC::currentMediaTimeDidChange(WTF::MediaTime&& time) const
+bool MediaPlayerPrivateAVFoundationObjC::setCurrentTimeDidChangeCallback(MediaPlayer::CurrentTimeDidChangeCallback&& callback)
 {
-    m_cachedCurrentMediaTime = time;
+    m_currentTimeDidChangeCallback = WTFMove(callback);
+    return true;
+}
+
+void MediaPlayerPrivateAVFoundationObjC::currentMediaTimeDidChange(MediaTime&& time) const
+{
+    m_cachedCurrentMediaTime = WTFMove(time);
     m_wallClockAtCachedCurrentTime = WallTime::now();
     m_timeControlStatusAtCachedCurrentTime = m_cachedTimeControlStatus;
     m_requestedRateAtCachedCurrentTime = m_requestedRate;
+
+    if (m_currentTimeDidChangeCallback)
+        m_currentTimeDidChangeCallback(time.isFinite() ? m_cachedCurrentMediaTime : MediaTime::zeroTime());
 }
 
 void MediaPlayerPrivateAVFoundationObjC::seekToTime(const MediaTime& time, const MediaTime& negativeTolerance, const MediaTime& positiveTolerance)

Modified: trunk/Source/WebKit/ChangeLog (277115 => 277116)


--- trunk/Source/WebKit/ChangeLog	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/ChangeLog	2021-05-06 20:49:28 UTC (rev 277116)
@@ -1,3 +1,55 @@
+2021-05-06  Eric Carlson  <[email protected]>
+
+        [GPUP] Reduce MediaPlayer polling frequency when possible
+        https://bugs.webkit.org/show_bug.cgi?id=225396
+        <rdar://problem/77562643>
+
+        Reviewed by Jer Noble.
+
+        When the MediaPlayerPrivate supports the new "current time changed" callback, use it
+        know when currentTime changes instead of polling at a fixed frequency. Current time
+        changes much more frequently than the other state that needs to be pushed to the
+        web process periodically so split current time out of the "cached state" struct
+        and push it separately when it changes, which also allow us to reduce the polling
+        frequency significantly.
+
+        Some of the state we were updating every time the cached state timer fired only
+        changes at known times, so reduce the number of things updated every time state 
+        is pushed.
+
+        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+        (WebKit::RemoteMediaPlayerProxy::getConfiguration): Set the timeChanged callback.
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerNetworkStateChanged): Update cached 
+        readyState and networkState since they aren't updated by updateCachedState.
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged): Ditto.
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerDurationChanged): Update cached duration.
+        (WebKit::RemoteMediaPlayerProxy::mediaPlayerCharacteristicChanged): Update hasAudio
+        and hasVideo.
+        (WebKit::RemoteMediaPlayerProxy::startUpdateCachedStateMessageTimer): Decrease the
+        time frequency to 200ms when the player supports the time change callback. Decrease
+        it to 250ms even when it doesn't because we interpolate time in the WP anyway.
+        (WebKit::RemoteMediaPlayerProxy::currentTimeChanged): Send the time change.
+        (WebKit::RemoteMediaPlayerProxy::updateCachedState): Send CurrentTimeChanged if
+        the player doesn't support the new callback. Don't update properties that change
+        at predictable times.
+        * GPUProcess/media/RemoteMediaPlayerProxy.h:
+
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::pause): Use m_cachedMediaTime and m_cachedMediaTimeQueryTime
+        instead of m_cachedState.currentTime and m_cachedState.timestamp.
+        (WebKit::MediaPlayerPrivateRemote::currentMediaTime const): Ditto.
+        (WebKit::MediaPlayerPrivateRemote::playbackStateChanged): Ditto.
+        (WebKit::MediaPlayerPrivateRemote::currentTimeChanged): Update time instance variables.
+        (WebKit::MediaPlayerPrivateRemote::updateCachedState):
+        (WebKit::MediaPlayerPrivateRemote::performTaskAtMediaTime): Use m_cachedMediaTime 
+        and m_cachedMediaTimeQueryTime instead of m_cachedState.currentTime and m_cachedState.timestamp.
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in:
+
+        * WebProcess/GPU/media/RemoteMediaPlayerState.h:
+        (WebKit::RemoteMediaPlayerState::encode const): Remove currentTime and timestamp.
+        (WebKit::RemoteMediaPlayerState::decode): Ditto.
+
 2021-05-06  Alex Christensen  <[email protected]>
 
         Fix crash when WebsiteDataStore is destroyed with outstanding getNetworkProcessConnection request

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (277115 => 277116)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2021-05-06 20:49:28 UTC (rev 277116)
@@ -38,7 +38,6 @@
 #include "RemoteLegacyCDMSessionProxy.h"
 #include "RemoteMediaPlayerManagerProxy.h"
 #include "RemoteMediaPlayerProxyConfiguration.h"
-#include "RemoteMediaPlayerState.h"
 #include "RemoteMediaResource.h"
 #include "RemoteMediaResourceIdentifier.h"
 #include "RemoteMediaResourceLoader.h"
@@ -119,6 +118,13 @@
     configuration.canPlayToWirelessPlaybackTarget = m_player->canPlayToWirelessPlaybackTarget();
 #endif
     configuration.shouldIgnoreIntrinsicSize = m_player->shouldIgnoreIntrinsicSize();
+
+    m_observingTimeChanges = m_player->setCurrentTimeDidChangeCallback([this, weakThis = makeWeakPtr(this)] (auto currentTime) mutable {
+        if (!weakThis)
+            return;
+
+        currentTimeChanged(currentTime);
+    });
 }
 
 void RemoteMediaPlayerProxy::load(URL&& url, Optional<SandboxExtension::Handle>&& sandboxExtensionHandle, const ContentType& contentType, const String& keySystem, CompletionHandler<void(RemoteMediaPlayerConfiguration&&)>&& completionHandler)
@@ -331,7 +337,9 @@
 
 void RemoteMediaPlayerProxy::mediaPlayerNetworkStateChanged()
 {
-    updateCachedState();
+    updateCachedState(true);
+    m_cachedState.readyState = m_player->readyState();
+    m_cachedState.networkState = m_player->networkState();
     m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::NetworkStateChanged(m_cachedState), m_id);
 }
 
@@ -338,8 +346,12 @@
 void RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged()
 {
     updateCachedVideoMetrics();
-    updateCachedState();
+    updateCachedState(true);
+    m_cachedState.readyState = m_player->readyState();
+    m_cachedState.networkState = m_player->networkState();
+    m_cachedState.duration = m_player->duration();
 
+    m_cachedState.movieLoadType = m_player->movieLoadType();
     m_cachedState.minTimeSeekable = m_player->minTimeSeekable();
     m_cachedState.maxTimeSeekable = m_player->maxTimeSeekable();
     m_cachedState.startDate = m_player->getStartDate();
@@ -373,13 +385,15 @@
 
 void RemoteMediaPlayerProxy::mediaPlayerTimeChanged()
 {
-    updateCachedState();
+    updateCachedState(true);
+    m_cachedState.duration = m_player->duration();
     m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::TimeChanged(m_cachedState), m_id);
 }
 
 void RemoteMediaPlayerProxy::mediaPlayerDurationChanged()
 {
-    updateCachedState();
+    updateCachedState(true);
+    m_cachedState.duration = m_player->duration();
     m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::DurationChanged(m_cachedState), m_id);
 }
 
@@ -488,6 +502,8 @@
 {
     updateCachedVideoMetrics();
     updateCachedState();
+    m_cachedState.hasAudio = m_player->hasAudio();
+    m_cachedState.hasVideo = m_player->hasVideo();
     m_cachedState.hasClosedCaptions = m_player->hasClosedCaptions();
     m_cachedState.languageOfPrimaryAudioTrack = m_player->languageOfPrimaryAudioTrack();
 
@@ -810,12 +826,14 @@
 
 void RemoteMediaPlayerProxy::startUpdateCachedStateMessageTimer()
 {
-    static const Seconds maxTimeupdateEventFrequency { 100_ms };
+    static const Seconds lessFrequentTimeupdateEventFrequency { 2000_ms };
+    static const Seconds moreFrequentTimeupdateEventFrequency { 250_ms };
 
     if (m_updateCachedStateMessageTimer.isActive())
         return;
 
-    m_updateCachedStateMessageTimer.startRepeating(maxTimeupdateEventFrequency);
+    auto frequency = m_observingTimeChanges ? lessFrequentTimeupdateEventFrequency : moreFrequentTimeupdateEventFrequency;
+    m_updateCachedStateMessageTimer.startRepeating(frequency);
 }
 
 void RemoteMediaPlayerProxy::timerFired()
@@ -823,17 +841,17 @@
     sendCachedState();
 }
 
-void RemoteMediaPlayerProxy::updateCachedState()
+void RemoteMediaPlayerProxy::currentTimeChanged(const MediaTime& mediaTime)
 {
-    m_cachedState.timestamp = MonotonicTime::now();
-    m_cachedState.currentTime = m_player->currentTime();
-    m_cachedState.duration = m_player->duration();
-    m_cachedState.networkState = m_player->networkState();
-    m_cachedState.readyState = m_player->readyState();
-    m_cachedState.movieLoadType = m_player->movieLoadType();
+    m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::CurrentTimeChanged(mediaTime, MonotonicTime::now()), m_id);
+}
+
+void RemoteMediaPlayerProxy::updateCachedState(bool forceCurrentTimeUpdate)
+{
+    if (!m_observingTimeChanges || forceCurrentTimeUpdate)
+        currentTimeChanged(m_player->currentTime());
+
     m_cachedState.paused = m_player->paused();
-    m_cachedState.hasAudio = m_player->hasAudio();
-    m_cachedState.hasVideo = m_player->hasVideo();
     maybeUpdateCachedVideoMetrics();
     if (m_bufferedChanged) {
         m_bufferedChanged = false;

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (277115 => 277116)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2021-05-06 20:49:28 UTC (rev 277116)
@@ -281,7 +281,7 @@
     bool mediaPlayerShouldCheckHardwareSupport() const final;
 
     void startUpdateCachedStateMessageTimer();
-    void updateCachedState();
+    void updateCachedState(bool = false);
     void sendCachedState();
     void timerFired();
 
@@ -291,6 +291,8 @@
     void createAudioSourceProvider();
     void setShouldEnableAudioSourceProvider(bool);
 
+    void currentTimeChanged(const MediaTime&);
+
 #if PLATFORM(COCOA)
     void nativeImageForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
     void pixelBufferForCurrentTime(CompletionHandler<void(Optional<WTF::MachSendRight>&&)>&&);
@@ -347,6 +349,8 @@
 #endif
     ScopedRenderingResourcesRequest m_renderingResourcesRequest;
 
+    bool m_observingTimeChanges { false };
+
 #if !RELEASE_LOG_DISABLED
     const Logger& m_logger;
 #endif

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (277115 => 277116)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2021-05-06 20:49:28 UTC (rev 277116)
@@ -204,8 +204,8 @@
 {
     m_cachedState.paused = true;
     auto now = MonotonicTime::now();
-    m_cachedState.currentTime += MediaTime::createWithDouble(m_rate * (now - m_cachedState.timestamp).value());
-    m_cachedState.timestamp = now;
+    m_cachedMediaTime += MediaTime::createWithDouble(m_rate * (now - m_cachedMediaTimeQueryTime).value());
+    m_cachedMediaTimeQueryTime = now;
     connection().send(Messages::RemoteMediaPlayerProxy::Pause(), m_id);
 }
 
@@ -251,10 +251,10 @@
 
 MediaTime MediaPlayerPrivateRemote::currentMediaTime() const
 {
-    if (m_cachedState.paused || !m_cachedState.currentTime)
-        return m_cachedState.currentTime;
+    if (m_cachedState.paused || !m_cachedMediaTime)
+        return m_cachedMediaTime;
 
-    return m_cachedState.currentTime + MediaTime::createWithDouble(m_rate * (MonotonicTime::now() - m_cachedState.timestamp).seconds());
+    return m_cachedMediaTime + MediaTime::createWithDouble(m_rate * (MonotonicTime::now() - m_cachedMediaTimeQueryTime).seconds());
 }
 
 void MediaPlayerPrivateRemote::seek(const MediaTime& time)
@@ -351,8 +351,8 @@
 void MediaPlayerPrivateRemote::playbackStateChanged(bool paused, MediaTime&& mediaTime, MonotonicTime&& wallTime)
 {
     m_cachedState.paused = paused;
-    m_cachedState.currentTime = mediaTime;
-    m_cachedState.timestamp = wallTime;
+    m_cachedMediaTime = mediaTime;
+    m_cachedMediaTimeQueryTime = wallTime;
     m_player->playbackStateChanged();
 }
 
@@ -374,6 +374,12 @@
     m_player->sizeChanged();
 }
 
+void MediaPlayerPrivateRemote::currentTimeChanged(const MediaTime& mediaTime, const MonotonicTime& queryTime)
+{
+    m_cachedMediaTime = mediaTime;
+    m_cachedMediaTimeQueryTime = queryTime;
+}
+
 void MediaPlayerPrivateRemote::firstVideoFrameAvailable()
 {
     INFO_LOG(LOGIDENTIFIER);
@@ -427,8 +433,6 @@
 {
     const Seconds playbackQualityMetricsTimeout = 30_s;
 
-    m_cachedState.timestamp = state.timestamp;
-    m_cachedState.currentTime = state.currentTime;
     m_cachedState.duration = state.duration;
     m_cachedState.minTimeSeekable = state.minTimeSeekable;
     m_cachedState.maxTimeSeekable = state.maxTimeSeekable;
@@ -1220,12 +1224,12 @@
 
 bool MediaPlayerPrivateRemote::performTaskAtMediaTime(WTF::Function<void()>&& completionHandler, const MediaTime& mediaTime)
 {
-    auto asyncReplyHandler = [weakThis = makeWeakPtr(*this), this, completionHandler = WTFMove(completionHandler)](Optional<MediaTime> currentTime, Optional<MonotonicTime> wallTime) mutable {
-        if (!weakThis || !currentTime || !wallTime)
+    auto asyncReplyHandler = [weakThis = makeWeakPtr(*this), this, completionHandler = WTFMove(completionHandler)](Optional<MediaTime> currentTime, Optional<MonotonicTime> queryTime) mutable {
+        if (!weakThis || !currentTime || !queryTime)
             return;
 
-        m_cachedState.currentTime = *currentTime;
-        m_cachedState.timestamp = *wallTime;
+        m_cachedMediaTime = *currentTime;
+        m_cachedMediaTimeQueryTime = *queryTime;
         completionHandler();
     };
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (277115 => 277116)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2021-05-06 20:49:28 UTC (rev 277116)
@@ -110,6 +110,8 @@
     void setVideoInlineSizeFenced(const WebCore::IntSize&, const WTF::MachSendRight&);
 #endif
 
+    void currentTimeChanged(const MediaTime&, const MonotonicTime&);
+
     void addRemoteAudioTrack(TrackPrivateRemoteIdentifier, TrackPrivateRemoteConfiguration&&);
     void removeRemoteAudioTrack(TrackPrivateRemoteIdentifier);
     void remoteAudioTrackConfigurationChanged(TrackPrivateRemoteIdentifier, TrackPrivateRemoteConfiguration&&);
@@ -415,6 +417,9 @@
     WebCore::SecurityOriginData m_documentSecurityOrigin;
     mutable HashMap<WebCore::SecurityOriginData, Optional<bool>> m_wouldTaintOriginCache;
 
+    MediaTime m_cachedMediaTime;
+    MonotonicTime m_cachedMediaTimeQueryTime;
+
     MonotonicTime m_lastPlaybackQualityMetricsQueryTime;
     Seconds m_videoPlaybackMetricsUpdateInterval;
     double m_volume { 1 };

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in (277115 => 277116)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in	2021-05-06 20:49:28 UTC (rev 277116)
@@ -39,6 +39,8 @@
     SizeChanged(WebCore::FloatSize naturalSize)
     RenderingModeChanged()
 
+    CurrentTimeChanged(MediaTime mediaTime, MonotonicTime wallTime)
+
     AddRemoteAudioTrack(WebKit::TrackPrivateRemoteIdentifier trackID, struct WebKit::TrackPrivateRemoteConfiguration configuration)
     RemoveRemoteAudioTrack(WebKit::TrackPrivateRemoteIdentifier trackID)
     RemoteAudioTrackConfigurationChanged(WebKit::TrackPrivateRemoteIdentifier trackID, struct WebKit::TrackPrivateRemoteConfiguration configuration)

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerState.h (277115 => 277116)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerState.h	2021-05-06 20:42:42 UTC (rev 277115)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerState.h	2021-05-06 20:49:28 UTC (rev 277116)
@@ -37,8 +37,6 @@
 namespace WebKit {
 
 struct RemoteMediaPlayerState {
-    MonotonicTime timestamp;
-    MediaTime currentTime;
     MediaTime duration;
     MediaTime minTimeSeekable;
     MediaTime maxTimeSeekable;
@@ -72,8 +70,6 @@
     template<class Encoder>
     void encode(Encoder& encoder) const
     {
-        encoder << timestamp;
-        encoder << currentTime;
         encoder << duration;
         encoder << minTimeSeekable;
         encoder << maxTimeSeekable;
@@ -108,16 +104,6 @@
     template <class Decoder>
     static Optional<RemoteMediaPlayerState> decode(Decoder& decoder)
     {
-        Optional<MonotonicTime> timestamp;
-        decoder >> timestamp;
-        if (!timestamp)
-            return WTF::nullopt;
-
-        Optional<MediaTime> currentTime;
-        decoder >> currentTime;
-        if (!currentTime)
-            return WTF::nullopt;
-
         Optional<MediaTime> duration;
         decoder >> duration;
         if (!duration)
@@ -260,8 +246,6 @@
             return WTF::nullopt;
 
         return {{
-            WTFMove(*timestamp),
-            WTFMove(*currentTime),
             WTFMove(*duration),
             WTFMove(*minTimeSeekable),
             WTFMove(*maxTimeSeekable),
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to