Title: [282945] branches/safari-612-branch/Source
Revision
282945
Author
repst...@apple.com
Date
2021-09-22 22:14:36 -0700 (Wed, 22 Sep 2021)

Log Message

Cherry-pick r282789. rdar://problem/83429661

    [Cocoa] Videos sometimes don't render when loaded in the GPU process
    https://bugs.webkit.org/show_bug.cgi?id=230495
    rdar://83205407

    Reviewed by Jer Noble.

    The media players choose what type of video output to create based on whether
    or not the renderer can support accelerated rendering. We were only pushing
    this state to the GPU process when the renderer changed to require backing, but
    that state was lost if that transition happened before the AVFoundation-backed
    media player was created. Change this to push the current state from the web process
    when a remote media player is created, and again whenever its readyState changes.

    We haven't figured out how to reliably reproduce this, so https://webkit.org/b/230500
    tracks figuring that out and creating a test.

    * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
    (WebKit::RemoteMediaPlayerProxy::RemoteMediaPlayerProxy): Set m_renderingCanBeAccelerated
    from the configuration.
    (WebKit::RemoteMediaPlayerProxy::prepareToPlay): Add logging.
    (WebKit::RemoteMediaPlayerProxy::prepareForRendering): Ditto.
    (WebKit::RemoteMediaPlayerProxy::setPageIsVisible): Ditto.
    (WebKit::RemoteMediaPlayerProxy::acceleratedRenderingStateChanged): Ditto.
    (WebKit::RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged): Ditto.

    * GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h: Add renderingCanBeAccelerated.
    (WebKit::RemoteMediaPlayerProxyConfiguration::encode const):
    (WebKit::RemoteMediaPlayerProxyConfiguration::decode): Decode it.

    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
    (WebKit::MediaPlayerPrivateRemote::readyStateChanged): Call acceleratedRenderingStateChanged
    if the state has changed.
    (WebKit::MediaPlayerPrivateRemote::acceleratedRenderingStateChanged): Remember
    the state.
    * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:

    * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
    (WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer): Pass the accelerated
    rendering state with the configuration.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282789 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/platform/graphics/MediaPlayerEnums.h (282944 => 282945)


--- branches/safari-612-branch/Source/WebCore/platform/graphics/MediaPlayerEnums.h	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebCore/platform/graphics/MediaPlayerEnums.h	2021-09-23 05:14:36 UTC (rev 282945)
@@ -113,7 +113,7 @@
     };
 };
 
-String convertEnumerationToString(MediaPlayerEnums::ReadyState);
+WEBCORE_EXPORT String convertEnumerationToString(MediaPlayerEnums::ReadyState);
 String convertEnumerationToString(MediaPlayerEnums::NetworkState);
 String convertEnumerationToString(MediaPlayerEnums::Preload);
 String convertEnumerationToString(MediaPlayerEnums::SupportsType);

Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (282944 => 282945)


--- branches/safari-612-branch/Source/WebKit/ChangeLog	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog	2021-09-23 05:14:36 UTC (rev 282945)
@@ -1,5 +1,94 @@
 2021-09-22  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r282789. rdar://problem/83429661
+
+    [Cocoa] Videos sometimes don't render when loaded in the GPU process
+    https://bugs.webkit.org/show_bug.cgi?id=230495
+    rdar://83205407
+    
+    Reviewed by Jer Noble.
+    
+    The media players choose what type of video output to create based on whether
+    or not the renderer can support accelerated rendering. We were only pushing
+    this state to the GPU process when the renderer changed to require backing, but
+    that state was lost if that transition happened before the AVFoundation-backed
+    media player was created. Change this to push the current state from the web process
+    when a remote media player is created, and again whenever its readyState changes.
+    
+    We haven't figured out how to reliably reproduce this, so https://webkit.org/b/230500
+    tracks figuring that out and creating a test.
+    
+    * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+    (WebKit::RemoteMediaPlayerProxy::RemoteMediaPlayerProxy): Set m_renderingCanBeAccelerated
+    from the configuration.
+    (WebKit::RemoteMediaPlayerProxy::prepareToPlay): Add logging.
+    (WebKit::RemoteMediaPlayerProxy::prepareForRendering): Ditto.
+    (WebKit::RemoteMediaPlayerProxy::setPageIsVisible): Ditto.
+    (WebKit::RemoteMediaPlayerProxy::acceleratedRenderingStateChanged): Ditto.
+    (WebKit::RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged): Ditto.
+    
+    * GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h: Add renderingCanBeAccelerated.
+    (WebKit::RemoteMediaPlayerProxyConfiguration::encode const):
+    (WebKit::RemoteMediaPlayerProxyConfiguration::decode): Decode it.
+    
+    * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+    (WebKit::MediaPlayerPrivateRemote::readyStateChanged): Call acceleratedRenderingStateChanged
+    if the state has changed.
+    (WebKit::MediaPlayerPrivateRemote::acceleratedRenderingStateChanged): Remember
+    the state.
+    * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+    
+    * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
+    (WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer): Pass the accelerated
+    rendering state with the configuration.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282789 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-20  Eric Carlson  <eric.carl...@apple.com>
+
+            [Cocoa] Videos sometimes don't render when loaded in the GPU process
+            https://bugs.webkit.org/show_bug.cgi?id=230495
+            rdar://83205407
+
+            Reviewed by Jer Noble.
+
+            The media players choose what type of video output to create based on whether
+            or not the renderer can support accelerated rendering. We were only pushing
+            this state to the GPU process when the renderer changed to require backing, but
+            that state was lost if that transition happened before the AVFoundation-backed
+            media player was created. Change this to push the current state from the web process
+            when a remote media player is created, and again whenever its readyState changes.
+
+            We haven't figured out how to reliably reproduce this, so https://webkit.org/b/230500
+            tracks figuring that out and creating a test.
+
+            * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+            (WebKit::RemoteMediaPlayerProxy::RemoteMediaPlayerProxy): Set m_renderingCanBeAccelerated
+            from the configuration.
+            (WebKit::RemoteMediaPlayerProxy::prepareToPlay): Add logging.
+            (WebKit::RemoteMediaPlayerProxy::prepareForRendering): Ditto.
+            (WebKit::RemoteMediaPlayerProxy::setPageIsVisible): Ditto.
+            (WebKit::RemoteMediaPlayerProxy::acceleratedRenderingStateChanged): Ditto.
+            (WebKit::RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged): Ditto.
+
+            * GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h: Add renderingCanBeAccelerated.
+            (WebKit::RemoteMediaPlayerProxyConfiguration::encode const):
+            (WebKit::RemoteMediaPlayerProxyConfiguration::decode): Decode it.
+
+            * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+            (WebKit::MediaPlayerPrivateRemote::readyStateChanged): Call acceleratedRenderingStateChanged
+            if the state has changed.
+            (WebKit::MediaPlayerPrivateRemote::acceleratedRenderingStateChanged): Remember
+            the state.
+            * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+
+            * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
+            (WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer): Pass the accelerated
+            rendering state with the configuration.
+
+2021-09-22  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r282698. rdar://problem/83429561
 
     Unreviewed build fix.

Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (282944 => 282945)


--- branches/safari-612-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2021-09-23 05:14:36 UTC (rev 282945)
@@ -84,6 +84,7 @@
 #endif
 {
     m_typesRequiringHardwareSupport = m_configuration.mediaContentTypesRequiringHardwareSupport;
+    m_renderingCanBeAccelerated = m_configuration.renderingCanBeAccelerated;
     m_player = MediaPlayer::create(*this, m_engineIdentifier);
 }
 
@@ -172,6 +173,7 @@
 
 void RemoteMediaPlayerProxy::prepareToPlay()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     m_player->prepareToPlay();
 }
 
@@ -233,11 +235,13 @@
 
 void RemoteMediaPlayerProxy::prepareForRendering()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     m_player->prepareForRendering();
 }
 
 void RemoteMediaPlayerProxy::setPageIsVisible(bool visible)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, visible);
     m_player->setPageIsVisible(visible);
 }
 
@@ -255,6 +259,7 @@
 
 void RemoteMediaPlayerProxy::acceleratedRenderingStateChanged(bool renderingCanBeAccelerated)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, renderingCanBeAccelerated);
     m_renderingCanBeAccelerated = renderingCanBeAccelerated;
     m_player->acceleratedRenderingStateChanged();
 }
@@ -348,9 +353,11 @@
 
 void RemoteMediaPlayerProxy::mediaPlayerReadyStateChanged()
 {
+    auto newReadyState = m_player->readyState();
+    ALWAYS_LOG(LOGIDENTIFIER, newReadyState);
     updateCachedVideoMetrics();
     updateCachedState(true);
-    m_cachedState.readyState = m_player->readyState();
+    m_cachedState.readyState = newReadyState;
     m_cachedState.networkState = m_player->networkState();
     m_cachedState.duration = m_player->duration();
 

Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h (282944 => 282945)


--- branches/safari-612-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h	2021-09-23 05:14:36 UTC (rev 282945)
@@ -47,7 +47,8 @@
     WebCore::SecurityOriginData documentSecurityOrigin;
     uint64_t logIdentifier { 0 };
     bool shouldUsePersistentCache { false };
-    bool isVideo { 0 };
+    bool isVideo { false };
+    bool renderingCanBeAccelerated { false };
 
     template<class Encoder>
     void encode(Encoder& encoder) const
@@ -65,6 +66,7 @@
         encoder << logIdentifier;
         encoder << shouldUsePersistentCache;
         encoder << isVideo;
+        encoder << renderingCanBeAccelerated;
     }
 
     template <class Decoder>
@@ -127,6 +129,11 @@
         if (!isVideo)
             return std::nullopt;
 
+        std::optional<bool> renderingCanBeAccelerated;
+        decoder >> renderingCanBeAccelerated;
+        if (!renderingCanBeAccelerated)
+            return std::nullopt;
+
         return {{
             WTFMove(*referrer),
             WTFMove(*userAgent),
@@ -141,6 +148,7 @@
             *logIdentifier,
             *shouldUsePersistentCache,
             *isVideo,
+            *renderingCanBeAccelerated,
         }};
     }
 };

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (282944 => 282945)


--- branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2021-09-23 05:14:36 UTC (rev 282945)
@@ -351,8 +351,12 @@
 void MediaPlayerPrivateRemote::readyStateChanged(RemoteMediaPlayerState&& state)
 {
     updateCachedState(WTFMove(state));
-    if (auto player = makeRefPtr(m_player.get()))
+    if (auto player = makeRefPtr(m_player.get())) {
         player->readyStateChanged();
+        bool renderingCanBeAccelerated = player->renderingCanBeAccelerated();
+        if (m_renderingCanBeAccelerated != renderingCanBeAccelerated)
+            acceleratedRenderingStateChanged();
+    }
 }
 
 void MediaPlayerPrivateRemote::volumeChanged(double volume)
@@ -469,8 +473,10 @@
 
 void MediaPlayerPrivateRemote::acceleratedRenderingStateChanged()
 {
-    if (auto player = makeRefPtr(m_player.get()))
-        connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(player->renderingCanBeAccelerated()), m_id);
+    if (auto player = makeRefPtr(m_player.get())) {
+        m_renderingCanBeAccelerated = player->renderingCanBeAccelerated();
+        connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(m_renderingCanBeAccelerated), m_id);
+    }
 }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (282944 => 282945)


--- branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2021-09-23 05:14:36 UTC (rev 282945)
@@ -444,6 +444,7 @@
     bool m_invalid { false };
     bool m_waitingForKey { false };
     bool m_timeIsProgressing { false };
+    bool m_renderingCanBeAccelerated { false };
 };
 
 } // namespace WebKit

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp (282944 => 282945)


--- branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp	2021-09-23 05:14:32 UTC (rev 282944)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp	2021-09-23 05:14:36 UTC (rev 282945)
@@ -150,6 +150,7 @@
     proxyConfiguration.networkInterfaceName = player->mediaPlayerNetworkInterfaceName();
 #endif
     proxyConfiguration.mediaContentTypesRequiringHardwareSupport = player->mediaContentTypesRequiringHardwareSupport();
+    proxyConfiguration.renderingCanBeAccelerated = player->renderingCanBeAccelerated();
     proxyConfiguration.preferredAudioCharacteristics = player->preferredAudioCharacteristics();
 #if !RELEASE_LOG_DISABLED
     proxyConfiguration.logIdentifier = reinterpret_cast<uint64_t>(player->mediaPlayerLogIdentifier());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to