Diff
Modified: trunk/Source/WebKit/ChangeLog (250716 => 250717)
--- trunk/Source/WebKit/ChangeLog 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/ChangeLog 2019-10-04 13:39:21 UTC (rev 250717)
@@ -1,5 +1,43 @@
2019-10-04 Carlos Garcia Campos <[email protected]>
+ [GTK] Crash in WebChromeClient::createDisplayRefreshMonitor
+ https://bugs.webkit.org/show_bug.cgi?id=202551
+
+ Reviewed by Žan Doberšek.
+
+ The crash happens when the drawing area is destroyed due to a page close. The layer tree host is invalidated
+ causing a layer flush that ends up trying to create a display refresh monitor, which requires the drawing
+ area. We need to null-check the drawing area in WebChromeClient::createDisplayRefreshMonitor() but we should
+ also ensure that layer flush is not performed after layer tree host is destroyed.
+
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::createDisplayRefreshMonitor const): Null-check drawing area before using it.
+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+ (WebKit::CompositingCoordinator::CompositingCoordinator): Receive a WebPage instead of a WebCore::Page and
+ create the root layer here.
+ (WebKit::CompositingCoordinator::~CompositingCoordinator): Do not purge backing stores again, invalidate should
+ always be called right before the object is destroyed.
+ (WebKit::CompositingCoordinator::flushPendingLayerChanges): Get WebCore::Page from WebPage.
+ (WebKit::CompositingCoordinator::timestamp const): Ditto.
+ (WebKit::CompositingCoordinator::syncDisplayState): Ditto.
+ (WebKit::CompositingCoordinator::notifyFlushRequired): Do not continue if m_rootLayer is nullptr.
+ (WebKit::CompositingCoordinator::deviceScaleFactor const): Get WebCore::Page from WebPage.
+ (WebKit::CompositingCoordinator::pageScaleFactor const): Ditto.
+ (WebKit::CompositingCoordinator::createGraphicsLayer): Call attachLayer() instead of duplicating the code.
+ (WebKit::CompositingCoordinator::setVisibleContentsRect): Get WebCore::Page from WebPage.
+ * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h:
+ * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
+ (WebKit::DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost): Do not call LayerTreeHost::invalidate()
+ that has been removed.
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
+ (WebKit::LayerTreeHost::LayerTreeHost): Construct the coordinator after the sceneIntegration.
+ (WebKit::LayerTreeHost::~LayerTreeHost): Invalidate everything here now. We don't really need invalidate()
+ method since LayerTreeHost is not refcounted and we always called invalidate right before deleting the object.
+ (WebKit::LayerTreeHost::layerFlushTimerFired): This can't happen on invalid state anymore.
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
+
+2019-10-04 Carlos Garcia Campos <[email protected]>
+
[GTK][WPE] REGRESSION(r250673): connection to network process is broken after r250673
https://bugs.webkit.org/show_bug.cgi?id=202575
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (250716 => 250717)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2019-10-04 13:39:21 UTC (rev 250717)
@@ -891,7 +891,9 @@
RefPtr<DisplayRefreshMonitor> WebChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
{
- return m_page.drawingArea()->createDisplayRefreshMonitor(displayID);
+ if (auto* drawingArea = m_page.drawingArea())
+ return drawingArea->createDisplayRefreshMonitor(displayID);
+ return nullptr;
}
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (250716 => 250717)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp 2019-10-04 13:39:21 UTC (rev 250717)
@@ -50,7 +50,7 @@
namespace WebKit {
using namespace WebCore;
-CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client& client)
+CompositingCoordinator::CompositingCoordinator(WebPage& page, CompositingCoordinator::Client& client)
: m_page(page)
, m_client(client)
, m_paintingEngine(Nicosia::PaintingEngine::create())
@@ -57,14 +57,19 @@
{
m_nicosia.scene = Nicosia::Scene::create();
m_state.nicosia.scene = m_nicosia.scene;
+
+ m_rootLayer = GraphicsLayer::create(this, *this);
+#ifndef NDEBUG
+ m_rootLayer->setName("CompositingCoordinator root layer");
+#endif
+ m_rootLayer->setDrawsContent(false);
+ m_rootLayer->setSize(m_page.size());
}
CompositingCoordinator::~CompositingCoordinator()
{
- m_isDestructing = true;
+ ASSERT(!m_rootLayer);
- purgeBackingStores();
-
for (auto& registeredLayer : m_registeredLayers.values())
registeredLayer->setCoordinator(nullptr);
}
@@ -119,7 +124,7 @@
if (m_overlayCompositingLayer)
m_overlayCompositingLayer->flushCompositingState(FloatRect(FloatPoint(), m_rootLayer->size()));
- bool didSync = m_page->mainFrame().view()->flushCompositingStateIncludingSubframes();
+ bool didSync = m_page.corePage()->mainFrame().view()->flushCompositingStateIncludingSubframes();
auto& coordinatedLayer = downcast<CoordinatedGraphicsLayer>(*m_rootLayer);
coordinatedLayer.updateContentBuffersIncludingSubLayers();
@@ -169,7 +174,7 @@
double CompositingCoordinator::timestamp() const
{
- auto* document = m_page->mainFrame().document();
+ auto* document = m_page.corePage()->mainFrame().document();
if (!document)
return 0;
return document->domWindow() ? document->domWindow()->nowTimestamp() : document->monotonicTimestamp();
@@ -177,7 +182,7 @@
void CompositingCoordinator::syncDisplayState()
{
- m_page->mainFrame().view()->updateLayoutAndStyleIfNeededRecursive();
+ m_page.corePage()->mainFrame().view()->updateLayoutAndStyleIfNeededRecursive();
}
double CompositingCoordinator::nextAnimationServiceTime() const
@@ -198,18 +203,6 @@
m_shouldSyncFrame = true;
}
-void CompositingCoordinator::createRootLayer(const IntSize& size)
-{
- ASSERT(!m_rootLayer);
- // Create a root layer.
- m_rootLayer = GraphicsLayer::create(this, *this);
-#ifndef NDEBUG
- m_rootLayer->setName("CompositingCoordinator root layer");
-#endif
- m_rootLayer->setDrawsContent(false);
- m_rootLayer->setSize(size);
-}
-
void CompositingCoordinator::syncLayerState()
{
m_shouldSyncFrame = true;
@@ -217,32 +210,24 @@
void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*)
{
- if (!m_isDestructing && !isFlushingLayerChanges())
+ if (m_rootLayer && !isFlushingLayerChanges())
m_client.notifyFlushRequired();
}
float CompositingCoordinator::deviceScaleFactor() const
{
- return m_page->deviceScaleFactor();
+ return m_page.corePage()->deviceScaleFactor();
}
float CompositingCoordinator::pageScaleFactor() const
{
- return m_page->pageScaleFactor();
+ return m_page.corePage()->pageScaleFactor();
}
Ref<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Type layerType, GraphicsLayerClient& client)
{
auto layer = adoptRef(*new CoordinatedGraphicsLayer(layerType, client));
- layer->setCoordinator(this);
- {
- auto& compositionLayer = layer->compositionLayer();
- m_nicosia.state.layers.add(compositionLayer);
- compositionLayer->setSceneIntegration(m_client.sceneIntegration());
- }
- m_registeredLayers.add(layer->id(), layer.ptr());
- layer->setNeedsVisibleRectAdjustment();
- notifyFlushRequired(layer.ptr());
+ attachLayer(layer.ptr());
return layer;
}
@@ -261,7 +246,7 @@
registeredLayer->setNeedsVisibleRectAdjustment();
}
- FrameView* view = m_page->mainFrame().view();
+ FrameView* view = m_page.corePage()->mainFrame().view();
if (view->useFixedLayout() && contentsRectDidChange) {
// Round the rect instead of enclosing it to make sure that its size stays
// the same while panning. This can have nasty effects on layout.
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h (250716 => 250717)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h 2019-10-04 13:39:21 UTC (rev 250717)
@@ -24,11 +24,11 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef CompositingCoordinator_h
-#define CompositingCoordinator_h
+#pragma once
#if USE(COORDINATED_GRAPHICS)
+#include "WebPage.h"
#include <WebCore/CoordinatedGraphicsLayer.h>
#include <WebCore/CoordinatedGraphicsState.h>
#include <WebCore/FloatPoint.h>
@@ -46,7 +46,6 @@
namespace WebCore {
class GraphicsContext;
class GraphicsLayer;
-class Page;
}
namespace WebKit {
@@ -64,7 +63,7 @@
virtual RefPtr<Nicosia::SceneIntegration> sceneIntegration() = 0;
};
- CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client&);
+ CompositingCoordinator(WebPage&, CompositingCoordinator::Client&);
virtual ~CompositingCoordinator();
void invalidate();
@@ -77,7 +76,6 @@
void setVisibleContentsRect(const WebCore::FloatRect&);
void renderNextFrame();
- void createRootLayer(const WebCore::IntSize&);
WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
WebCore::GraphicsLayer* rootCompositingLayer() const { return m_rootCompositingLayer; }
@@ -113,7 +111,7 @@
double timestamp() const;
- WebCore::Page* m_page;
+ WebPage& m_page;
CompositingCoordinator::Client& m_client;
RefPtr<WebCore::GraphicsLayer> m_rootLayer;
@@ -131,7 +129,6 @@
std::unique_ptr<Nicosia::PaintingEngine> m_paintingEngine;
// We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
- bool m_isDestructing { false };
bool m_isPurging { false };
bool m_isFlushingLayerChanges { false };
bool m_shouldSyncFrame { false };
@@ -145,5 +142,3 @@
}
#endif // namespace WebKit
-
-#endif // CompositingCoordinator_h
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (250716 => 250717)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp 2019-10-04 13:39:21 UTC (rev 250717)
@@ -79,12 +79,7 @@
#endif
}
-DrawingAreaCoordinatedGraphics::~DrawingAreaCoordinatedGraphics()
-{
- discardPreviousLayerTreeHost();
- if (m_layerTreeHost)
- m_layerTreeHost->invalidate();
-}
+DrawingAreaCoordinatedGraphics::~DrawingAreaCoordinatedGraphics() = default;
void DrawingAreaCoordinatedGraphics::setNeedsDisplay()
{
@@ -517,10 +512,6 @@
void DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost()
{
m_discardPreviousLayerTreeHostTimer.stop();
- if (!m_previousLayerTreeHost)
- return;
-
- m_previousLayerTreeHost->invalidate();
m_previousLayerTreeHost = nullptr;
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp (250716 => 250717)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp 2019-10-04 13:39:21 UTC (rev 250717)
@@ -48,18 +48,17 @@
LayerTreeHost::LayerTreeHost(WebPage& webPage)
: m_webPage(webPage)
- , m_coordinator(webPage.corePage(), *this)
, m_compositorClient(*this)
, m_surface(AcceleratedSurface::create(webPage, *this))
, m_viewportController(webPage.size())
, m_layerFlushTimer(RunLoop::main(), this, &LayerTreeHost::layerFlushTimerFired)
, m_sceneIntegration(Nicosia::SceneIntegration::create(*this))
+ , m_coordinator(webPage, *this)
{
#if USE(GLIB_EVENT_LOOP)
m_layerFlushTimer.setPriority(RunLoopSourcePriority::LayerFlushTimer);
m_layerFlushTimer.setName("[WebKit] LayerTreeHost");
#endif
- m_coordinator.createRootLayer(m_webPage.size());
scheduleLayerFlush();
if (FrameView* frameView = m_webPage.mainFrameView()) {
@@ -84,7 +83,12 @@
LayerTreeHost::~LayerTreeHost()
{
- ASSERT(!m_isValid);
+ cancelPendingLayerFlush();
+
+ m_sceneIntegration->invalidate();
+ m_coordinator.invalidate();
+ m_compositor->invalidate();
+ m_surface = nullptr;
}
void LayerTreeHost::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
@@ -137,7 +141,7 @@
m_webPage.updateRendering();
m_webPage.flushPendingEditorStateUpdate();
- if (!m_isValid || !m_coordinator.rootCompositingLayer())
+ if (!m_coordinator.rootCompositingLayer())
return;
// If a force-repaint callback was registered, we should force a 'frame sync' that
@@ -164,19 +168,6 @@
m_coordinator.setViewOverlayRootLayer(viewOverlayRootLayer);
}
-void LayerTreeHost::invalidate()
-{
- ASSERT(m_isValid);
- m_isValid = false;
-
- cancelPendingLayerFlush();
-
- m_sceneIntegration->invalidate();
- m_coordinator.invalidate();
- m_compositor->invalidate();
- m_surface = nullptr;
-}
-
void LayerTreeHost::scrollNonCompositedContents(const IntRect& rect)
{
auto* frameView = m_webPage.mainFrameView();
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h (250716 => 250717)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h 2019-10-04 10:57:43 UTC (rev 250716)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h 2019-10-04 13:39:21 UTC (rev 250717)
@@ -74,7 +74,6 @@
void cancelPendingLayerFlush();
void setRootCompositingLayer(WebCore::GraphicsLayer*);
void setViewOverlayRootLayer(WebCore::GraphicsLayer*);
- void invalidate();
void scrollNonCompositedContents(const WebCore::IntRect&);
void forceRepaint();
@@ -183,7 +182,6 @@
bool m_layerFlushSchedulingEnabled { true };
bool m_notifyAfterScheduledLayerFlush { false };
bool m_isSuspended { false };
- bool m_isValid { true };
bool m_isWaitingForRenderer { false };
bool m_scheduledWhileWaitingForRenderer { false };
float m_lastPageScaleFactor { 1 };
@@ -191,7 +189,6 @@
bool m_isDiscardable { false };
OptionSet<DiscardableSyncActions> m_discardableSyncActions;
WebCore::GraphicsLayer* m_viewOverlayRootLayer { nullptr };
- CompositingCoordinator m_coordinator;
CompositorClient m_compositorClient;
std::unique_ptr<AcceleratedSurface> m_surface;
RefPtr<ThreadedCompositor> m_compositor;
@@ -202,6 +199,7 @@
} m_forceRepaintAsync;
RunLoop::Timer<LayerTreeHost> m_layerFlushTimer;
Ref<Nicosia::SceneIntegration> m_sceneIntegration;
+ CompositingCoordinator m_coordinator;
#endif // USE(COORDINATED_GRAPHICS)
};