Diff
Modified: trunk/Source/WebKit/ChangeLog (235110 => 235111)
--- trunk/Source/WebKit/ChangeLog 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/ChangeLog 2018-08-21 13:10:54 UTC (rev 235111)
@@ -1,3 +1,17 @@
+2018-08-21 Commit Queue <[email protected]>
+
+ Unreviewed, rolling out r234981.
+ https://bugs.webkit.org/show_bug.cgi?id=188793
+
+ It was not the main cause of the high CPU usage in the end
+ (Requested by KaL on #webkit).
+
+ Reverted changeset:
+
+ "Unreviewed, rolling out r234259."
+ https://bugs.webkit.org/show_bug.cgi?id=188005
+ https://trac.webkit.org/changeset/234981
+
2018-08-20 Michael Catanzaro <[email protected]>
Use unified build for NetworkProcess
Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp (235110 => 235111)
--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp 2018-08-21 13:10:54 UTC (rev 235111)
@@ -45,18 +45,18 @@
namespace WebKit {
using namespace WebCore;
-Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+Ref<ThreadedCompositor> ThreadedCompositor::create(Client& client, ThreadedDisplayRefreshMonitor::Client& displayRefreshMonitorClient, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
{
- return adoptRef(*new ThreadedCompositor(client, displayID, viewportSize, scaleFactor, doFrameSync, paintFlags));
+ return adoptRef(*new ThreadedCompositor(client, displayRefreshMonitorClient, displayID, viewportSize, scaleFactor, doFrameSync, paintFlags));
}
-ThreadedCompositor::ThreadedCompositor(Client& client, PlatformDisplayID displayID, const IntSize& viewportSize, float scaleFactor, ShouldDoFrameSync doFrameSync, TextureMapper::PaintFlags paintFlags)
+ThreadedCompositor::ThreadedCompositor(Client& client, ThreadedDisplayRefreshMonitor::Client& displayRefreshMonitorClient, 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, *this))
+ , m_displayRefreshMonitor(ThreadedDisplayRefreshMonitor::create(displayID, displayRefreshMonitorClient))
#endif
{
{
@@ -304,23 +304,8 @@
return m_displayRefreshMonitor.copyRef();
}
-void ThreadedCompositor::requestDisplayRefreshMonitorUpdate()
+void ThreadedCompositor::handleDisplayRefreshMonitorUpdate()
{
- // 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 };
{
@@ -328,12 +313,6 @@
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
@@ -341,16 +320,6 @@
// 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 (235110 => 235111)
--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h 2018-08-21 13:10:54 UTC (rev 235111)
@@ -39,7 +39,7 @@
#include <wtf/ThreadSafeRefCounted.h>
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
-#include <WebCore/DisplayRefreshMonitor.h>
+#include "ThreadedDisplayRefreshMonitor.h"
#endif
namespace WebKit {
@@ -46,7 +46,6 @@
class CoordinatedGraphicsScene;
class CoordinatedGraphicsSceneClient;
-class ThreadedDisplayRefreshMonitor;
class ThreadedCompositor : public CoordinatedGraphicsSceneClient, public ThreadSafeRefCounted<ThreadedCompositor> {
WTF_MAKE_NONCOPYABLE(ThreadedCompositor);
@@ -54,8 +53,6 @@
public:
class Client {
public:
- virtual void renderNextFrame() = 0;
-
virtual uint64_t nativeSurfaceHandleForCompositing() = 0;
virtual void didDestroyGLContext() = 0;
@@ -65,7 +62,7 @@
enum class ShouldDoFrameSync { No, Yes };
- static Ref<ThreadedCompositor> create(Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
+ static Ref<ThreadedCompositor> create(Client&, ThreadedDisplayRefreshMonitor::Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync = ShouldDoFrameSync::Yes, WebCore::TextureMapper::PaintFlags = 0);
virtual ~ThreadedCompositor();
void setNativeSurfaceHandleForCompositing(uint64_t);
@@ -82,14 +79,13 @@
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
RefPtr<WebCore::DisplayRefreshMonitor> displayRefreshMonitor(WebCore::PlatformDisplayID);
- void requestDisplayRefreshMonitorUpdate();
- void handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled);
+ void handleDisplayRefreshMonitorUpdate();
#endif
void frameComplete();
private:
- ThreadedCompositor(Client&, WebCore::PlatformDisplayID, const WebCore::IntSize&, float scaleFactor, ShouldDoFrameSync, WebCore::TextureMapper::PaintFlags);
+ ThreadedCompositor(Client&, ThreadedDisplayRefreshMonitor::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 (235110 => 235111)
--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.cpp 2018-08-21 13:10:54 UTC (rev 235111)
@@ -37,10 +37,10 @@
namespace WebKit {
-ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID displayID, ThreadedCompositor& compositor)
+ThreadedDisplayRefreshMonitor::ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID displayID, Client& client)
: WebCore::DisplayRefreshMonitor(displayID)
, m_displayRefreshTimer(RunLoop::main(), this, &ThreadedDisplayRefreshMonitor::displayRefreshCallback)
- , m_compositor(&compositor)
+ , m_client(&client)
{
#if USE(GLIB_EVENT_LOOP)
m_displayRefreshTimer.setPriority(RunLoopSourcePriority::DisplayRefreshMonitorTimer);
@@ -50,7 +50,7 @@
bool ThreadedDisplayRefreshMonitor::requestRefreshCallback()
{
- if (!m_compositor)
+ if (!m_client)
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_compositor->requestDisplayRefreshMonitorUpdate();
+ m_client->requestDisplayRefreshMonitorUpdate();
return true;
}
@@ -77,7 +77,7 @@
void ThreadedDisplayRefreshMonitor::dispatchDisplayRefreshCallback()
{
- if (!m_compositor)
+ if (!m_client)
return;
m_displayRefreshTimer.startOneShot(0_s);
}
@@ -85,7 +85,7 @@
void ThreadedDisplayRefreshMonitor::invalidate()
{
m_displayRefreshTimer.stop();
- m_compositor = nullptr;
+ m_client = 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_compositor)
- m_compositor->handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
+ if (m_client)
+ m_client->handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
}
} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h (235110 => 235111)
--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedDisplayRefreshMonitor.h 2018-08-21 13:10:54 UTC (rev 235111)
@@ -36,9 +36,15 @@
class ThreadedDisplayRefreshMonitor : public WebCore::DisplayRefreshMonitor {
public:
- static Ref<ThreadedDisplayRefreshMonitor> create(WebCore::PlatformDisplayID displayID, ThreadedCompositor& compositor)
+ class Client {
+ public:
+ virtual void requestDisplayRefreshMonitorUpdate() = 0;
+ virtual void handleDisplayRefreshMonitorUpdate(bool) = 0;
+ };
+
+ static Ref<ThreadedDisplayRefreshMonitor> create(WebCore::PlatformDisplayID displayID, Client& client)
{
- return adoptRef(*new ThreadedDisplayRefreshMonitor(displayID, compositor));
+ return adoptRef(*new ThreadedDisplayRefreshMonitor(displayID, client));
}
virtual ~ThreadedDisplayRefreshMonitor() = default;
@@ -49,11 +55,11 @@
void invalidate();
private:
- ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID, ThreadedCompositor&);
+ ThreadedDisplayRefreshMonitor(WebCore::PlatformDisplayID, Client&);
void displayRefreshCallback();
RunLoop::Timer<ThreadedDisplayRefreshMonitor> m_displayRefreshTimer;
- ThreadedCompositor* m_compositor;
+ Client* m_client;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (235110 => 235111)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2018-08-21 13:10:54 UTC (rev 235111)
@@ -145,7 +145,7 @@
scheduleLayerFlush();
}
-void CoordinatedLayerTreeHost::renderNextFrame()
+void CoordinatedLayerTreeHost::renderNextFrame(bool forceRepaint)
{
m_isWaitingForRenderer = false;
bool scheduledWhileWaitingForRenderer = std::exchange(m_scheduledWhileWaitingForRenderer, false);
@@ -167,8 +167,10 @@
m_forceRepaintAsync.needsFreshFlush = false;
}
- if (scheduledWhileWaitingForRenderer || m_layerFlushTimer.isActive()) {
+ if (scheduledWhileWaitingForRenderer || m_layerFlushTimer.isActive() || forceRepaint) {
m_layerFlushTimer.stop();
+ if (forceRepaint)
+ m_coordinator.forceFrameSync();
layerFlushTimerFired();
}
}
@@ -209,6 +211,15 @@
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 (235110 => 235111)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2018-08-21 13:10:54 UTC (rev 235111)
@@ -58,7 +58,7 @@
void pageBackgroundTransparencyChanged() override;
void setVisibleContentsRect(const WebCore::FloatRect&);
- void renderNextFrame();
+ void renderNextFrame(bool);
WebCore::GraphicsLayerFactory* graphicsLayerFactory() override;
@@ -71,6 +71,8 @@
void notifyFlushRequired() override { scheduleLayerFlush(); };
void commitSceneState(const WebCore::CoordinatedGraphicsState&) override;
+ void flushLayersAndForceRepaint();
+
private:
void layerFlushTimerFired();
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp (235110 => 235111)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp 2018-08-21 13:10:54 UTC (rev 235111)
@@ -77,10 +77,10 @@
if (m_surface->shouldPaintMirrored())
paintFlags |= TextureMapper::PaintingMirrored;
- m_compositor = ThreadedCompositor::create(m_compositorClient, compositingDisplayID, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
+ m_compositor = ThreadedCompositor::create(m_compositorClient, m_compositorClient, compositingDisplayID, scaledSize, scaleFactor, ThreadedCompositor::ShouldDoFrameSync::Yes, paintFlags);
m_layerTreeContext.contextID = m_surface->surfaceID();
} else
- m_compositor = ThreadedCompositor::create(m_compositorClient, compositingDisplayID, scaledSize, scaleFactor);
+ m_compositor = ThreadedCompositor::create(m_compositorClient, m_compositorClient, compositingDisplayID, scaledSize, scaleFactor);
m_webPage.windowScreenDidChange(compositingDisplayID);
@@ -105,6 +105,22 @@
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 (235110 => 235111)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h 2018-08-21 09:07:33 UTC (rev 235110)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h 2018-08-21 13:10:54 UTC (rev 235111)
@@ -33,6 +33,7 @@
#include "CoordinatedLayerTreeHost.h"
#include "SimpleViewportController.h"
#include "ThreadedCompositor.h"
+#include "ThreadedDisplayRefreshMonitor.h"
#include <wtf/OptionSet.h>
namespace WebCore {
@@ -71,7 +72,7 @@
void setNativeSurfaceHandleForCompositing(uint64_t) override;
#endif
- class CompositorClient final : public ThreadedCompositor::Client {
+ class CompositorClient final : public ThreadedCompositor::Client, public ThreadedDisplayRefreshMonitor::Client {
WTF_MAKE_NONCOPYABLE(CompositorClient);
public:
CompositorClient(ThreadedCoordinatedLayerTreeHost& layerTreeHost)
@@ -80,11 +81,6 @@
}
private:
- void renderNextFrame() override
- {
- m_layerTreeHost.renderNextFrame();
- }
-
uint64_t nativeSurfaceHandleForCompositing() override
{
return m_layerTreeHost.nativeSurfaceHandleForCompositing();
@@ -105,6 +101,16 @@
m_layerTreeHost.didRenderFrame();
}
+ void requestDisplayRefreshMonitorUpdate() override
+ {
+ m_layerTreeHost.requestDisplayRefreshMonitorUpdate();
+ }
+
+ void handleDisplayRefreshMonitorUpdate(bool hasBeenRescheduled)
+ {
+ m_layerTreeHost.handleDisplayRefreshMonitorUpdate(hasBeenRescheduled);
+ }
+
ThreadedCoordinatedLayerTreeHost& m_layerTreeHost;
};
@@ -125,6 +131,8 @@
void didDestroyGLContext();
void willRenderFrame();
void didRenderFrame();
+ void requestDisplayRefreshMonitorUpdate();
+ void handleDisplayRefreshMonitorUpdate(bool);
enum class DiscardableSyncActions {
UpdateSize = 1 << 1,