Skip to content
Permalink
Browse files
REGRESSION(r177075): WebProcess crashes when entering accelerating co…
…mpositing mode before the WebView is realized

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

Reviewed by Žan Doberšek.

The problem is that the texture mapper and native window handler
are initialized when the LayerTreeHost is initialized, assuming
the UI process has already sent the native window handler to the
web process, but that doesn't always happen since we moved the
redirected window creation to realize in r177075.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::nativeSurfaceHandleForCompositing): Deleted.
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode): Call
LayerTreeHost::setNativeSurfaceHandleForCompositing if we
already have a native window handle at this point.
(WebKit::DrawingAreaImpl::setNativeSurfaceHandleForCompositing):
Call LayerTreeHost::setNativeSurfaceHandleForCompositing also when
not using threaded compositing.
* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::makeContextCurrent): Helper function to
ensure a context and making it current.
(WebKit::LayerTreeHostGtk::ensureTextureMapper): Ensure a texture
is created for the current context.
(WebKit::LayerTreeHostGtk::initialize): Use makeContextCurrent()
and ensureTextureMapper(), and remove the LayerTreeContext
initialization since that's is now always initialized in
setNativeSurfaceHandleForCompositing().
(WebKit::LayerTreeHostGtk::compositeLayersToContext): Use
makeContextCurrent() helper function and also call
ensureTextureMapper() just in case the texture could not be
created during initialization because the native window handle was
not yet available.
(WebKit::LayerTreeHostGtk::flushAndRenderLayers): Use makeContextCurrent().
(WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing):
Initialize the LayerTreeContext.
(WebKit::LayerTreeHostGtk::glContext): Deleted.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:

Canonical link: https://commits.webkit.org/160255@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Mar 3, 2015
1 parent cacae24 commit 93454d190b56046e88d69de196bb80be8bc9b0c2
@@ -1,3 +1,46 @@
2015-03-03 Carlos Garcia Campos <cgarcia@igalia.com>

REGRESSION(r177075): WebProcess crashes when entering accelerating compositing mode before the WebView is realized
https://bugs.webkit.org/show_bug.cgi?id=142079

Reviewed by Žan Doberšek.

The problem is that the texture mapper and native window handler
are initialized when the LayerTreeHost is initialized, assuming
the UI process has already sent the native window handler to the
web process, but that doesn't always happen since we moved the
redirected window creation to realize in r177075.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::nativeSurfaceHandleForCompositing): Deleted.
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::enterAcceleratedCompositingMode): Call
LayerTreeHost::setNativeSurfaceHandleForCompositing if we
already have a native window handle at this point.
(WebKit::DrawingAreaImpl::setNativeSurfaceHandleForCompositing):
Call LayerTreeHost::setNativeSurfaceHandleForCompositing also when
not using threaded compositing.
* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::makeContextCurrent): Helper function to
ensure a context and making it current.
(WebKit::LayerTreeHostGtk::ensureTextureMapper): Ensure a texture
is created for the current context.
(WebKit::LayerTreeHostGtk::initialize): Use makeContextCurrent()
and ensureTextureMapper(), and remove the LayerTreeContext
initialization since that's is now always initialized in
setNativeSurfaceHandleForCompositing().
(WebKit::LayerTreeHostGtk::compositeLayersToContext): Use
makeContextCurrent() helper function and also call
ensureTextureMapper() just in case the texture could not be
created during initialization because the native window handle was
not yet available.
(WebKit::LayerTreeHostGtk::flushAndRenderLayers): Use makeContextCurrent().
(WebKit::LayerTreeHostGtk::setNativeSurfaceHandleForCompositing):
Initialize the LayerTreeContext.
(WebKit::LayerTreeHostGtk::glContext): Deleted.
* WebProcess/WebPage/gtk/LayerTreeHostGtk.h:

2015-03-02 Gyuyoung Kim <gyuyoung.kim@samsung.com>

[WK2] Remove unnecessary create() factory functions.
@@ -124,10 +124,6 @@ class DrawingArea : public IPC::MessageReceiver {

virtual void attachViewOverlayGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) { }

#if USE(TEXTURE_MAPPER_GL) && PLATFORM(GTK)
uint64_t nativeSurfaceHandleForCompositing() { return m_nativeSurfaceHandleForCompositing; }
#endif

protected:
DrawingArea(DrawingAreaType, WebPage&);

@@ -456,6 +456,8 @@ void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLay
ASSERT(!m_layerTreeHost);

m_layerTreeHost = LayerTreeHost::create(&m_webPage);
if (m_nativeSurfaceHandleForCompositing)
m_layerTreeHost->setNativeSurfaceHandleForCompositing(m_nativeSurfaceHandleForCompositing);
if (!m_inUpdateBackingStoreState)
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);

@@ -677,10 +679,8 @@ void DrawingAreaImpl::setNativeSurfaceHandleForCompositing(uint64_t handle)
m_nativeSurfaceHandleForCompositing = handle;
m_webPage.corePage()->settings().setAcceleratedCompositingEnabled(true);

#if USE(COORDINATED_GRAPHICS_THREADED)
if (m_layerTreeHost)
m_layerTreeHost->setNativeSurfaceHandleForCompositing(handle);
#endif
}
#endif

@@ -93,6 +93,10 @@ class LayerTreeHost : public RefCounted<LayerTreeHost> {
virtual void scheduleAnimation() = 0;
#endif

#if USE(TEXTURE_MAPPER_GL) && PLATFORM(GTK)
virtual void setNativeSurfaceHandleForCompositing(uint64_t) = 0;
#endif

virtual void setViewOverlayRootLayer(WebCore::GraphicsLayer*) = 0;

protected:
@@ -78,17 +78,29 @@ LayerTreeHostGtk::LayerTreeHostGtk(WebPage* webPage)
{
}

GLContext* LayerTreeHostGtk::glContext()
bool LayerTreeHostGtk::makeContextCurrent()
{
if (m_context)
return m_context.get();
if (!m_context) {
if (!m_layerTreeContext.contextID)
return false;

m_context = GLContext::createContextForWindow(m_layerTreeContext.contextID, GLContext::sharingContext());
if (!m_context)
return false;
}

uint64_t windowHandle = m_webPage->drawingArea()->nativeSurfaceHandleForCompositing();
if (!windowHandle)
return 0;
return m_context->makeContextCurrent();
}

void LayerTreeHostGtk::ensureTextureMapper()
{
if (m_textureMapper)
return;

m_context = GLContext::createContextForWindow(windowHandle, GLContext::sharingContext());
return m_context.get();
ASSERT(m_isValid);
m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTextureMapper(m_textureMapper.get());
}

void LayerTreeHostGtk::initialize()
@@ -113,19 +125,11 @@ void LayerTreeHostGtk::initialize()
m_rootLayer->addChild(m_nonCompositedContentLayer.get());
m_nonCompositedContentLayer->setNeedsDisplay();

m_layerTreeContext.contextID = m_webPage->drawingArea()->nativeSurfaceHandleForCompositing();

GLContext* context = glContext();
if (!context)
return;

// The creation of the TextureMapper needs an active OpenGL context.
context->makeContextCurrent();

m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().setTextureMapper(m_textureMapper.get());
if (!makeContextCurrent())
return;

ensureTextureMapper();
scheduleLayerFlush();
}

@@ -289,10 +293,11 @@ bool LayerTreeHostGtk::flushPendingLayerChanges()

void LayerTreeHostGtk::compositeLayersToContext(CompositePurpose purpose)
{
GLContext* context = glContext();
if (!context || !context->makeContextCurrent())
if (!makeContextCurrent())
return;

ensureTextureMapper();

// The window size may be out of sync with the page size at this point, and getting
// the viewport parameters incorrect, means that the content will be misplaced. Thus
// we set the viewport parameters directly from the window size.
@@ -308,7 +313,7 @@ void LayerTreeHostGtk::compositeLayersToContext(CompositePurpose purpose)
downcast<GraphicsLayerTextureMapper>(*m_rootLayer).layer().paint();
m_textureMapper->endPainting();

context->swapBuffers();
m_context->swapBuffers();
}

void LayerTreeHostGtk::flushAndRenderLayers()
@@ -321,8 +326,7 @@ void LayerTreeHostGtk::flushAndRenderLayers()
return;
}

GLContext* context = glContext();
if (!context || !context->makeContextCurrent())
if (!makeContextCurrent())
return;

if (!flushPendingLayerChanges())
@@ -380,6 +384,11 @@ void LayerTreeHostGtk::setViewOverlayRootLayer(WebCore::GraphicsLayer* viewOverl
m_rootLayer->addChild(m_viewOverlayRootLayer);
}

void LayerTreeHostGtk::setNativeSurfaceHandleForCompositing(uint64_t handle)
{
m_layerTreeContext.contextID = handle;
}

} // namespace WebKit

#endif
@@ -61,6 +61,8 @@ class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClien
virtual void deviceOrPageScaleFactorChanged() override;
virtual void pageBackgroundTransparencyChanged() override;

virtual void setNativeSurfaceHandleForCompositing(uint64_t) override;

private:
// LayerTreeHost
virtual const LayerTreeContext& layerTreeContext() override;
@@ -84,7 +86,8 @@ class LayerTreeHostGtk final : public LayerTreeHost, WebCore::GraphicsLayerClien

void layerFlushTimerFired();

WebCore::GLContext* glContext();
bool makeContextCurrent();
void ensureTextureMapper();

LayerTreeContext m_layerTreeContext;
bool m_isValid;

0 comments on commit 93454d1

Please sign in to comment.