Title: [234981] trunk/Source/WebKit

Diff

Modified: trunk/Source/WebKit/ChangeLog (234980 => 234981)


--- trunk/Source/WebKit/ChangeLog	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/ChangeLog	2018-08-17 13:15:42 UTC (rev 234981)
@@ -1,3 +1,16 @@
+2018-08-17  Michael Catanzaro  <[email protected]>
+
+        Unreviewed, rolling out r234259.
+
+        Caused excessive CPU usage
+
+        Reverted changeset:
+
+        "[GTK][WPE] Improve the way request displayRefresh
+        notifications"
+        https://bugs.webkit.org/show_bug.cgi?id=188005
+        https://trac.webkit.org/changeset/234259
+
 2018-08-16  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r234958.

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (234980 => 234981)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp	2018-08-17 13:15:42 UTC (rev 234981)
@@ -45,18 +45,18 @@
 namespace WebKit {
 using namespace WebCore;
 
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, ThreadedDisplayRefreshMonitor::Client& displayRefreshMonitorClient, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
 {
-    return adoptRef(*new ThreadedCompositor(client, displayRefreshMonitorClient, displayID, viewportSize, scaleFactor, doFrameSync, paintFlags));
+    return adoptRef(*new ThreadedCompositor(client, displayID, viewportSize, scaleFactor, doFrameSync, paintFlags));
 }
 
-ThreadedCompositor::ThreadedCompositor(Client& client, ThreadedDisplayRefreshMonitor::Client& displayRefreshMonitorClient, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+ThreadedCompositor::ThreadedCompositor(Client& client, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
     : m_client(client)
     , m_doFrameSync(doFrameSync)
     , m_paintFlags(paintFlags)
     , m_compositingRunLoop(std::make_unique<CompositingRunLoop>([this] { renderLayerTree(); }))
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
-    , m_displayRefreshMonitor(ThreadedDisplayRefreshMonitor::create(displayID, displayRefreshMonitorClient))
+    , m_displayRefreshMonitor(ThreadedDisplayRefreshMonitor::create(displayID, *this))
 #endif
 {
     {
@@ -304,8 +304,23 @@
     return m_displayRefreshMonitor.copyRef();
 }
 
-void ThreadedCompositor::handleDisplayRefreshMonitorUpdate()
+void ThreadedCompositor::requestDisplayRefreshMonitorUpdate()
 {
+    // This is invoked by ThreadedDisplayRefreshMonitor when a fresh update is required.
+
+    LockHolder stateLocker(m_compositingRunLoop->stateLock());
+    {
+        // coordinateUpdateCompletionWithClient is set to true in order to delay the scene update
+        // completion until the DisplayRefreshMonitor is fired on the main thread after the composition
+        // is completed.
+        LockHolder locker(m_attributes.lock);
+        m_attributes.coordinateUpdateCompletionWithClient = true;
+    }
+    m_compositingRunLoop->scheduleUpdate(stateLocker);
+}
+
+void ThreadedCompositor::handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled)
+{
     // Retrieve coordinateUpdateCompletionWithClient.
     bool coordinateUpdateCompletionWithClient { false };
     {
@@ -313,6 +328,12 @@
         coordinateUpdateCompletionWithClient = std::exchange(m_attributes.coordinateUpdateCompletionWithClient, false);
     }
 
+    // The client is finally notified about the scene update nearing completion. The client will use this
+    // opportunity to clean up resources as appropriate. It can also perform any layer flush that was
+    // requested during the composition, or by any DisplayRefreshMonitor notifications that have been
+    // handled at this point.
+    m_client.renderNextFrame();
+
     LockHolder stateLocker(m_compositingRunLoop->stateLock());
 
     // If required, mark the current scene update as completed. CompositingRunLoop will take care of
@@ -320,6 +341,16 @@
     // or DisplayRefreshMonitor notifications.
     if (coordinateUpdateCompletionWithClient)
         m_compositingRunLoop->updateCompleted(stateLocker);
+
+    // If the DisplayRefreshMonitor was scheduled again, we immediately demand the update completion
+    // coordination (like we do in requestDisplayRefreshMonitorUpdate()) and request an update.
+    if (hasBeenRescheduled) {
+        {
+            LockHolder locker(m_attributes.lock);
+            m_attributes.coordinateUpdateCompletionWithClient = true;
+        }
+        m_compositingRunLoop->scheduleUpdate(stateLocker);
+    }
 }
 #endif
 

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h (234980 => 234981)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h	2018-08-17 13:15:42 UTC (rev 234981)
@@ -39,7 +39,7 @@
 #include <wtf/ThreadSafeRefCounted.h>
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
-#include "ThreadedDisplayRefreshMonitor.h"
+#include <WebCore/DisplayRefreshMonitor.h>
 #endif
 
 namespace WebKit {
@@ -46,6 +46,7 @@
 
 class CoordinatedGraphicsScene;
 class CoordinatedGraphicsSceneClient;
+class ThreadedDisplayRefreshMonitor;
 
 class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
     WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
@@ -53,6 +54,8 @@
 public:
     class Client {
     public:
+        virtual void renderNextFrame() = 0;
+
         virtual uint64_t nativeSurfaceHandleForCompositing() = 0;
         virtual void didDestroyGLContext() = 0;
 
@@ -62,7 +65,7 @@
 
     enum class ShouldDoFrameSync { No, Yes };
 
-    static Ref<ThreadedCompositor> create(Client&, ThreadedDisplayRefreshMonitor::Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
+    static Ref<ThreadedCompositor> create(Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
     virtual ~ThreadedCompositor();
 
     void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -79,13 +82,14 @@
 
 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     RefPtr<WebCore::DisplayRefreshMonitor> displayRefreshMonitor(WebCore::PlatformDisplayID);
-    void handleDisplayRefreshMonitorUpdate();
+    void requestDisplayRefreshMonitorUpdate();
+    void handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled);
 #endif
 
     void frameComplete();
 
 private:
-    ThreadedCompositor(Client&, ThreadedDisplayRefreshMonitor::Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
+    ThreadedCompositor(Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
 
     // CoordinatedGraphicsSceneClient
     void updateViewport() override;

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp (234980 => 234981)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp	2018-08-17 13:15:42 UTC (rev 234981)
@@ -37,10 +37,10 @@
 
 namespace WebKit {
 
-ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID displayID, Client& client)
+ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID displayID, ThreadedCompositor& compositor)
     : WebCore::DisplayRefreshMonitor(displayID)
     , m_displayRefreshTimer(RunLoop::main(), this, &ThreadedDisplayRefreshMonitor::displayRefreshCallback)
-    , m_client(&client)
+    , m_compositor(&compositor)
 {
 #if USE(GLIB_EVENT_LOOP)
     m_displayRefreshTimer.setPriority(RunLoopSourcePriority::DisplayRefreshMonitorTimer);
@@ -50,7 +50,7 @@
 
 bool ThreadedDisplayRefreshMonitor::requestRefreshCallback()
 {
-    if (!m_client)
+    if (!m_compositor)
         return false;
 
     bool previousFrameDone { false };
@@ -64,7 +64,7 @@
     // refresh notifications under ThreadedDisplayRefreshMonitor::displayRefreshCallback().
     // Any such schedule request is handled in that method after the notifications.
     if (previousFrameDone)
-        m_client->requestDisplayRefreshMonitorUpdate();
+        m_compositor->requestDisplayRefreshMonitorUpdate();
 
     return true;
 }
@@ -77,7 +77,7 @@
 
 void ThreadedDisplayRefreshMonitor::dispatchDisplayRefreshCallback()
 {
-    if (!m_client)
+    if (!m_compositor)
         return;
     m_displayRefreshTimer.startOneShot(0_s);
 }
@@ -85,7 +85,7 @@
 void ThreadedDisplayRefreshMonitor::invalidate()
 {
     m_displayRefreshTimer.stop();
-    m_client = nullptr;
+    m_compositor = nullptr;
 }
 
 void ThreadedDisplayRefreshMonitor::displayRefreshCallback()
@@ -111,8 +111,8 @@
     // Notify the compositor about the completed DisplayRefreshMonitor update, passing
     // along information about any schedule request that might have occurred during
     // the notification handling.
-    if (m_client)
-        m_client->handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
+    if (m_compositor)
+        m_compositor->handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h (234980 => 234981)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h	2018-08-17 13:15:42 UTC (rev 234981)
@@ -36,15 +36,9 @@
 
 class ThreadedDisplayRefreshMonitor : public WebCore::DisplayRefreshMonitor {
 public:
-    class Client {
-    public:
-        virtual void requestDisplayRefreshMonitorUpdate() = 0;
-        virtual void handleDisplayRefreshMonitorUpdate(bool) = 0;
-    };
-
-    static Ref<ThreadedDisplayRefreshMonitor> create(WebCore::PlatformDisplayID displayID, Client& client)
+    static Ref<ThreadedDisplayRefreshMonitor> create(WebCore::PlatformDisplayID displayID, ThreadedCompositor& compositor)
     {
-        return adoptRef(*new ThreadedDisplayRefreshMonitor(displayID, client));
+        return adoptRef(*new ThreadedDisplayRefreshMonitor(displayID, compositor));
     }
     virtual ~ThreadedDisplayRefreshMonitor() = default;
 
@@ -55,11 +49,11 @@
     void invalidate();
 
 private:
-    ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID, Client&);
+    ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID, ThreadedCompositor&);
 
     void displayRefreshCallback();
     RunLoop::Timer<ThreadedDisplayRefreshMonitor> m_displayRefreshTimer;
-    Client* m_client;
+    ThreadedCompositor* m_compositor;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (234980 => 234981)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2018-08-17 13:15:42 UTC (rev 234981)
@@ -145,7 +145,7 @@
     scheduleLayerFlush();
 }
 
-void CoordinatedLayerTreeHost::renderNextFrame(bool forceRepaint)
+void CoordinatedLayerTreeHost::renderNextFrame()
 {
     m_isWaitingForRenderer = false;
     bool scheduledWhileWaitingForRenderer = std::exchange(m_scheduledWhileWaitingForRenderer, false);
@@ -167,10 +167,8 @@
         m_forceRepaintAsync.needsFreshFlush = false;
     }
 
-    if (scheduledWhileWaitingForRenderer || m_layerFlushTimer.isActive() || forceRepaint) {
+    if (scheduledWhileWaitingForRenderer || m_layerFlushTimer.isActive()) {
         m_layerFlushTimer.stop();
-        if (forceRepaint)
-            m_coordinator.forceFrameSync();
         layerFlushTimerFired();
     }
 }
@@ -211,15 +209,6 @@
     m_isWaitingForRenderer = true;
 }
 
-void CoordinatedLayerTreeHost::flushLayersAndForceRepaint()
-{
-    if (m_layerFlushTimer.isActive())
-        m_layerFlushTimer.stop();
-
-    m_coordinator.forceFrameSync();
-    layerFlushTimerFired();
-}
-
 void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
 {
     m_coordinator.deviceOrPageScaleFactorChanged();

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (234980 => 234981)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h	2018-08-17 13:15:42 UTC (rev 234981)
@@ -58,7 +58,7 @@
     void pageBackgroundTransparencyChanged() override;
 
     void setVisibleContentsRect(const WebCore::FloatRect&);
-    void renderNextFrame(bool);
+    void renderNextFrame();
 
     WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
 
@@ -71,8 +71,6 @@
     void notifyFlushRequired() override { scheduleLayerFlush(); };
     void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
 
-    void flushLayersAndForceRepaint();
-
 private:
     void layerFlushTimerFired();
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (234980 => 234981)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp	2018-08-17 13:15:42 UTC (rev 234981)
@@ -77,10 +77,10 @@
         if (m_surface->shouldPaintMirrored())
             paintFlags |= TextureMapper::PaintingMirrored;
 
-        m_compositor = ThreadedCompositor::create(m_compositorClient, m_compositorClient, compositingDisplayID, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, compositingDisplayID, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
         m_layerTreeContext.contextID = m_surface->surfaceID();
     } else
-        m_compositor = ThreadedCompositor::create(m_compositorClient, m_compositorClient, compositingDisplayID, scaledSize, scaleFactor);
+        m_compositor = ThreadedCompositor::create(m_compositorClient, compositingDisplayID, scaledSize, scaleFactor);
 
     m_webPage.windowScreenDidChange(compositingDisplayID);
 
@@ -105,22 +105,6 @@
     m_compositor->frameComplete();
 }
 
-void ThreadedCoordinatedLayerTreeHost::requestDisplayRefreshMonitorUpdate()
-{
-    // Flush layers to cause a repaint. If m_isWaitingForRenderer was true at this point, the layer
-    // flush won't do anything, but that means there's a painting ongoing that will send the
-    // display refresh notification when it's done.
-    flushLayersAndForceRepaint();
-}
-
-void ThreadedCoordinatedLayerTreeHost::handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled)
-{
-    // Call renderNextFrame. If hasBeenRescheduled is true, the layer flush will force a repaint
-    // that will cause the display refresh notification to come.
-    renderNextFrame(hasBeenRescheduled);
-    m_compositor->handleDisplayRefreshMonitorUpdate();
-}
-
 uint64_t ThreadedCoordinatedLayerTreeHost::nativeSurfaceHandleForCompositing()
 {
     if (!m_surface)

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h (234980 => 234981)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h	2018-08-17 13:04:17 UTC (rev 234980)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h	2018-08-17 13:15:42 UTC (rev 234981)
@@ -33,7 +33,6 @@
 #include "CoordinatedLayerTreeHost.h"
 #include "SimpleViewportController.h"
 #include "ThreadedCompositor.h"
-#include "ThreadedDisplayRefreshMonitor.h"
 #include <wtf/OptionSet.h>
 
 namespace WebCore {
@@ -72,7 +71,7 @@
     void setNativeSurfaceHandleForCompositing(uint64_t) override;
 #endif
 
-    class CompositorClient final : public ThreadedCompositor::Client, public ThreadedDisplayRefreshMonitor::Client  {
+    class CompositorClient final : public ThreadedCompositor::Client {
         WTF_MAKE_NONCOPYABLE(CompositorClient);
     public:
         CompositorClient(ThreadedCoordinatedLayerTreeHost& layerTreeHost)
@@ -81,6 +80,11 @@
         }
 
     private:
+        void renderNextFrame() override
+        {
+            m_layerTreeHost.renderNextFrame();
+        }
+
         uint64_t nativeSurfaceHandleForCompositing() override
         {
             return m_layerTreeHost.nativeSurfaceHandleForCompositing();
@@ -101,16 +105,6 @@
             m_layerTreeHost.didRenderFrame();
         }
 
-        void requestDisplayRefreshMonitorUpdate() override
-        {
-            m_layerTreeHost.requestDisplayRefreshMonitorUpdate();
-        }
-
-        void handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled)
-        {
-            m_layerTreeHost.handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
-        }
-
         ThreadedCoordinatedLayerTreeHost& m_layerTreeHost;
     };
 
@@ -131,8 +125,6 @@
     void didDestroyGLContext();
     void willRenderFrame();
     void didRenderFrame();
-    void requestDisplayRefreshMonitorUpdate();
-    void handleDisplayRefreshMonitorUpdate(bool);
 
     enum class DiscardableSyncActions {
         UpdateSize = 1 << 1,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to