Skip to content

Commit

Permalink
REGRESSION(262572@main): [GTK] No contents renderer after process swa…
Browse files Browse the repository at this point in the history
…p for navigation

https://bugs.webkit.org/show_bug.cgi?id=255221

Reviewed by Žan Doberšek.

In case of process swap current drawing area is destroyed causing the AC
mode to be exited, and the new drawing area sends the enter AC message
before the UI process has switched drawing areas, so the message is just
ignored. To be able to enter AC mode from the DrawingArea constructor
this patch removes the enablePainting methods, since it's always called
right after the drawing area is crewated and only used by coordinated
graphics drawing area.

* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
(WebKit::DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics): Enter AC mode here when always compositing.
(WebKit::DrawingAreaCoordinatedGraphics::setNeedsDisplayInRect): Remove painting enabled check.
(WebKit::DrawingAreaCoordinatedGraphics::scroll): Ditto.
(WebKit::DrawingAreaCoordinatedGraphics::forceRepaint): Ditto.
(WebKit::DrawingAreaCoordinatedGraphics::updatePreferences): Update async scrolling enabled here.
(WebKit::DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode): Create the LayerTreeHost with the display ID
so that LayerTreeHost doesn't need to access the page drawing area that is being created.
(WebKit::DrawingAreaCoordinatedGraphics::sendEnterAcceleratedCompositingModeIfNeeded): Implement this.
(WebKit::DrawingAreaCoordinatedGraphics::enablePainting): Deleted.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::LayerTreeHost): Use the given display ID.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
* Source/WebKit/WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::enablePainting): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::reinitializeWebPage): Remove enablePainting calls.
* Source/WebKit/WebProcess/WebPage/gtk/AcceleratedSurfaceDMABuf.cpp:
(WebKit::AcceleratedSurfaceDMABuf::didCreateGLContext): Do not resize
here that is too early in some cases, wait for the first frame to do the
resize.

Canonical link: https://commits.webkit.org/262812@main
  • Loading branch information
carlosgcampos committed Apr 11, 2023
1 parent ec39b38 commit f938f81
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 43 deletions.
Expand Up @@ -57,7 +57,6 @@ DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics(WebPage& webPage,
: DrawingArea(DrawingAreaType::CoordinatedGraphics, parameters.drawingAreaIdentifier, webPage)
, m_exitCompositingTimer(RunLoop::main(), this, &DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode)
, m_discardPreviousLayerTreeHostTimer(RunLoop::main(), this, &DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost)
, m_supportsAsyncScrolling(parameters.store.getBoolValueForKey(WebPreferencesKey::threadedScrollingEnabledKey()))
, m_displayTimer(RunLoop::main(), this, &DrawingAreaCoordinatedGraphics::displayTimerFired)
{
#if USE(GLIB_EVENT_LOOP)
Expand All @@ -67,13 +66,13 @@ DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics(WebPage& webPage,
#endif
#endif

#if ENABLE(DEVELOPER_MODE)
if (m_supportsAsyncScrolling) {
auto* disableAsyncScrolling = getenv("WEBKIT_DISABLE_ASYNC_SCROLLING");
if (disableAsyncScrolling && strcmp(disableAsyncScrolling, "0"))
m_supportsAsyncScrolling = false;
updatePreferences(parameters.store);

if (m_alwaysUseCompositing) {
enterAcceleratedCompositingMode(nullptr);
if (!parameters.isProcessSwap)
sendEnterAcceleratedCompositingModeIfNeeded();
}
#endif
}

DrawingAreaCoordinatedGraphics::~DrawingAreaCoordinatedGraphics() = default;
Expand All @@ -98,9 +97,6 @@ void DrawingAreaCoordinatedGraphics::setNeedsDisplayInRect(const IntRect& rect)
return;
}

if (!m_isPaintingEnabled)
return;

IntRect dirtyRect = rect;
dirtyRect.intersect(m_webPage.bounds());
if (dirtyRect.isEmpty())
Expand All @@ -112,9 +108,6 @@ void DrawingAreaCoordinatedGraphics::setNeedsDisplayInRect(const IntRect& rect)

void DrawingAreaCoordinatedGraphics::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
{
if (!m_isPaintingEnabled)
return;

if (m_layerTreeHost) {
ASSERT(m_scrollRect.isEmpty());
ASSERT(m_scrollOffset.isEmpty());
Expand Down Expand Up @@ -180,10 +173,8 @@ void DrawingAreaCoordinatedGraphics::forceRepaint()

if (!m_layerTreeHost) {
m_isWaitingForDidUpdate = false;
if (m_isPaintingEnabled) {
m_dirtyRegion = m_webPage.bounds();
display();
}
m_dirtyRegion = m_webPage.bounds();
display();
return;
}

Expand Down Expand Up @@ -258,6 +249,15 @@ void DrawingAreaCoordinatedGraphics::updatePreferences(const WebPreferencesStore

m_alwaysUseCompositing = settings.acceleratedCompositingEnabled() && settings.forceCompositingMode();

m_supportsAsyncScrolling = store.getBoolValueForKey(WebPreferencesKey::threadedScrollingEnabledKey());
#if ENABLE(DEVELOPER_MODE)
if (m_supportsAsyncScrolling) {
auto* disableAsyncScrolling = getenv("WEBKIT_DISABLE_ASYNC_SCROLLING");
if (disableAsyncScrolling && strcmp(disableAsyncScrolling, "0"))
m_supportsAsyncScrolling = false;
}
#endif

// If async scrolling is disabled, we have to force-disable async frame and overflow scrolling
// to keep the non-async scrolling on those elements working.
if (!m_supportsAsyncScrolling) {
Expand All @@ -266,14 +266,6 @@ void DrawingAreaCoordinatedGraphics::updatePreferences(const WebPreferencesStore
}
}

void DrawingAreaCoordinatedGraphics::enablePainting()
{
m_isPaintingEnabled = true;

if (m_alwaysUseCompositing && !m_layerTreeHost)
enterAcceleratedCompositingMode(nullptr);
}

void DrawingAreaCoordinatedGraphics::mainFrameContentSizeChanged(const IntSize& size)
{
if (m_layerTreeHost)
Expand Down Expand Up @@ -659,13 +651,15 @@ void DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode(GraphicsLay
if (!m_layerTreeStateIsFrozen)
m_layerTreeHost->setLayerFlushSchedulingEnabled(true);
} else {
#if USE(COORDINATED_GRAPHICS) || USE(GRAPHICS_LAYER_TEXTURE_MAPPER)
#if USE(GRAPHICS_LAYER_TEXTURE_MAPPER)
m_layerTreeHost = makeUnique<LayerTreeHost>(m_webPage);
changeWindowScreen();
#elif USE(COORDINATED_GRAPHICS)
m_layerTreeHost = makeUnique<LayerTreeHost>(m_webPage, std::numeric_limits<uint32_t>::max() - m_identifier.toUInt64());
#else
m_layerTreeHost = nullptr;
return;
#endif
changeWindowScreen();
if (m_layerTreeStateIsFrozen)
m_layerTreeHost->setLayerFlushSchedulingEnabled(false);
if (m_isPaintingSuspended)
Expand All @@ -677,8 +671,8 @@ void DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode(GraphicsLay

m_layerTreeHost->setRootCompositingLayer(graphicsLayer);

send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
m_compositingAccordingToProxyMessages = true;
if (m_shouldSendEnterAcceleratedCompositingMode)
sendEnterAcceleratedCompositingModeIfNeeded();

// Non-composited content will now be handled exclusively by the layer tree host.
m_dirtyRegion = WebCore::Region();
Expand All @@ -688,6 +682,20 @@ void DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode(GraphicsLay
m_isWaitingForDidUpdate = false;
}

void DrawingAreaCoordinatedGraphics::sendEnterAcceleratedCompositingModeIfNeeded()
{
if (m_compositingAccordingToProxyMessages)
return;

if (!m_layerTreeHost) {
m_shouldSendEnterAcceleratedCompositingMode = true;
return;
}

send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
m_compositingAccordingToProxyMessages = true;
}

void DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode()
{
if (m_alwaysUseCompositing)
Expand Down
Expand Up @@ -57,8 +57,8 @@ class DrawingAreaCoordinatedGraphics final : public DrawingArea {
bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }

void updatePreferences(const WebPreferencesStore&) override;
void enablePainting() override;
void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
void sendEnterAcceleratedCompositingModeIfNeeded() override;

#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
void deviceOrPageScaleFactorChanged() override;
Expand Down Expand Up @@ -111,9 +111,6 @@ class DrawingAreaCoordinatedGraphics final : public DrawingArea {

uint64_t m_backingStoreStateID { 0 };

// Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
bool m_isPaintingEnabled { false };

// Whether we're currently processing an UpdateBackingStoreState message.
bool m_inUpdateBackingStoreState { false };

Expand Down Expand Up @@ -156,6 +153,7 @@ class DrawingAreaCoordinatedGraphics final : public DrawingArea {
bool m_alwaysUseCompositing { false };
bool m_supportsAsyncScrolling { true };
bool m_forceRepaintAfterBackingStoreStateUpdate { false };
bool m_shouldSendEnterAcceleratedCompositingMode { false };

RunLoop::Timer m_displayTimer;

Expand Down
Expand Up @@ -51,12 +51,13 @@
namespace WebKit {
using namespace WebCore;

LayerTreeHost::LayerTreeHost(WebPage& webPage)
LayerTreeHost::LayerTreeHost(WebPage& webPage, WebCore::PlatformDisplayID displayID)
: m_webPage(webPage)
, m_surface(AcceleratedSurface::create(webPage, *this))
, m_viewportController(webPage.size())
, m_layerFlushTimer(RunLoop::main(), this, &LayerTreeHost::layerFlushTimerFired)
, m_coordinator(webPage, *this)
, m_displayID(displayID)
{
#if USE(GLIB_EVENT_LOOP)
m_layerFlushTimer.setPriority(RunLoopSourcePriority::LayerFlushTimer);
Expand All @@ -78,8 +79,6 @@ LayerTreeHost::LayerTreeHost(WebPage& webPage)
if (m_surface->shouldPaintMirrored())
paintFlags |= TextureMapper::PaintingMirrored;

ASSERT(m_webPage.drawingArea());
m_displayID = std::numeric_limits<uint32_t>::max() - m_webPage.drawingArea()->identifier().toUInt64();
m_compositor = ThreadedCompositor::create(*this, *this, m_displayID, scaledSize, scaleFactor, paintFlags);
m_layerTreeContext.contextID = m_surface->surfaceID();

Expand Down
Expand Up @@ -65,7 +65,7 @@ class LayerTreeHost
{
WTF_MAKE_FAST_ALLOCATED;
public:
explicit LayerTreeHost(WebPage&);
LayerTreeHost(WebPage&, WebCore::PlatformDisplayID);
~LayerTreeHost();

const LayerTreeContext& layerTreeContext() const { return m_layerTreeContext; }
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/WebProcess/WebPage/DrawingArea.h
Expand Up @@ -96,7 +96,6 @@ class DrawingArea : public IPC::MessageReceiver, public WebCore::DisplayRefreshM
virtual bool layerTreeStateIsFrozen() const { return false; }

virtual void updatePreferences(const WebPreferencesStore&) { }
virtual void enablePainting() { }
virtual void mainFrameContentSizeChanged(const WebCore::IntSize&) { }

#if PLATFORM(COCOA)
Expand Down
3 changes: 0 additions & 3 deletions Source/WebKit/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -875,8 +875,6 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
if (!parameters.itemStates.isEmpty())
restoreSessionInternal(parameters.itemStates, parameters.itemStatesWereRestoredByAPIRequest ? WasRestoredByAPIRequest::Yes : WasRestoredByAPIRequest::No, WebBackForwardListProxy::OverwriteExistingItem::No);

m_drawingArea->enablePainting();

setMediaVolume(parameters.mediaVolume);

setMuted(parameters.muted, [] { });
Expand Down Expand Up @@ -1093,7 +1091,6 @@ void WebPage::reinitializeWebPage(WebPageCreationParameters&& parameters)
m_drawingArea = DrawingArea::create(*this, parameters);
m_drawingArea->setShouldScaleViewToFitDocument(parameters.shouldScaleViewToFitDocument);
m_drawingArea->updatePreferences(parameters.store);
m_drawingArea->enablePainting();

m_drawingArea->adoptLayersFromDrawingArea(*oldDrawingArea);
m_drawingArea->adoptDisplayRefreshMonitorsFromDrawingArea(*oldDrawingArea);
Expand Down
Expand Up @@ -58,8 +58,6 @@ void AcceleratedSurfaceDMABuf::didCreateGLContext()
{
glGenFramebuffers(1, &m_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);

clientResize(m_size);
}

void AcceleratedSurfaceDMABuf::willDestroyGLContext()
Expand Down

0 comments on commit f938f81

Please sign in to comment.