2011-03-14 Alexey Marinichev <amarinichev@chromium.org>

        Reviewed by Kenneth Russell.

        Graphics Context is not properly recovered if the GPU process dies.
        https://bugs.webkit.org/show_bug.cgi?id=56148

        Split context recreation into two steps.

        * src/WebViewImpl.cpp:
        (WebKit::WebViewImpl::composite):
        (WebKit::WebViewImpl::doComposite):
        (WebKit::WebViewImpl::reallocateRenderer):
        * src/WebViewImpl.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@81113 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0941835f
2011-03-14 Alexey Marinichev <amarinichev@chromium.org>
Reviewed by Kenneth Russell.
Graphics Context is not properly recovered if the GPU process dies.
https://bugs.webkit.org/show_bug.cgi?id=56148
Split context recreation into two steps.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::composite):
(WebKit::WebViewImpl::doComposite):
(WebKit::WebViewImpl::reallocateRenderer):
* src/WebViewImpl.h:
2011-03-14 Sheriff Bot <webkit.review.bot@gmail.com> 2011-03-14 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r81094. Unreviewed, rolling out r81094.
......
...@@ -1082,6 +1082,13 @@ void WebViewImpl::themeChanged() ...@@ -1082,6 +1082,13 @@ void WebViewImpl::themeChanged()
void WebViewImpl::composite(bool finish) void WebViewImpl::composite(bool finish)
{ {
#if USE(ACCELERATED_COMPOSITING) #if USE(ACCELERATED_COMPOSITING)
if (m_recreatingGraphicsContext) {
// reallocateRenderer will request a repaint whether or not it succeeded
// in creating a new context.
reallocateRenderer();
m_recreatingGraphicsContext = false;
return;
}
doComposite(); doComposite();
// Finish if requested. // Finish if requested.
...@@ -1092,8 +1099,16 @@ void WebViewImpl::composite(bool finish) ...@@ -1092,8 +1099,16 @@ void WebViewImpl::composite(bool finish)
m_layerRenderer->present(); m_layerRenderer->present();
GraphicsContext3D* context = m_layerRenderer->context(); GraphicsContext3D* context = m_layerRenderer->context();
if (context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR) if (context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR) {
reallocateRenderer(); // Trying to recover the context right here will not work if GPU process
// died. This is because GpuChannelHost::OnErrorMessage will only be
// called at the next iteration of the message loop, reverting our
// recovery attempts here. Instead, we detach the root layer from the
// renderer, recreate the renderer at the next message loop iteration
// and request a repaint yet again.
m_recreatingGraphicsContext = true;
setRootLayerNeedsDisplay();
}
#endif #endif
} }
...@@ -2399,6 +2414,12 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) ...@@ -2399,6 +2414,12 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
void WebViewImpl::doComposite() void WebViewImpl::doComposite()
{ {
ASSERT(m_layerRenderer);
if (!m_layerRenderer) {
setIsAcceleratedCompositingActive(false);
return;
}
ASSERT(isAcceleratedCompositingActive()); ASSERT(isAcceleratedCompositingActive());
if (!page()) if (!page())
return; return;
...@@ -2414,18 +2435,27 @@ void WebViewImpl::doComposite() ...@@ -2414,18 +2435,27 @@ void WebViewImpl::doComposite()
void WebViewImpl::reallocateRenderer() void WebViewImpl::reallocateRenderer()
{ {
GraphicsContext3D* context = m_layerRenderer->context(); RefPtr<GraphicsContext3D> newContext = GraphicsContext3D::create(
RefPtr<GraphicsContext3D> newContext = GraphicsContext3D::create(context->getContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow);
// GraphicsContext3D::create might fail and return 0, in that case LayerRendererChromium::create will also return 0. // GraphicsContext3D::create might fail and return 0, in that case LayerRendererChromium::create will also return 0.
RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(newContext, WebViewImplContentPainter::create(this), WebViewImplScrollbarPainter::create(this)); RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(newContext, WebViewImplContentPainter::create(this), WebViewImplScrollbarPainter::create(this));
// Reattach the root layer. Child layers will get reattached as a side effect of updateLayersRecursive. // Reattach the root layer. Child layers will get reattached as a side effect of updateLayersRecursive.
if (layerRenderer) if (layerRenderer) {
m_layerRenderer->transferRootLayer(layerRenderer.get()); m_layerRenderer->transferRootLayer(layerRenderer.get());
m_layerRenderer = layerRenderer; m_layerRenderer = layerRenderer;
// FIXME: In MacOS newContext->reshape method needs to be called to
// Enable or disable accelerated compositing and request a refresh. // allocate IOSurfaces. All calls to create a context followed by
setRootGraphicsLayer(m_layerRenderer ? m_layerRenderer->rootLayer() : 0); // reshape should really be extracted into one function; it is not
// immediately obvious that GraphicsContext3D object will not
// function properly until its reshape method is called.
newContext->reshape(std::max(1, m_size.width), std::max(1, m_size.height));
setRootGraphicsLayer(m_layerRenderer->rootLayer());
// Forces ViewHostMsg_DidActivateAcceleratedCompositing to be sent so
// that the browser process can reacquire surfaces.
m_client->didActivateAcceleratedCompositing(true);
} else
setRootGraphicsLayer(0);
} }
#endif #endif
......
...@@ -532,6 +532,8 @@ private: ...@@ -532,6 +532,8 @@ private:
RefPtr<WebCore::LayerRendererChromium> m_layerRenderer; RefPtr<WebCore::LayerRendererChromium> m_layerRenderer;
bool m_isAcceleratedCompositingActive; bool m_isAcceleratedCompositingActive;
bool m_compositorCreationFailed; bool m_compositorCreationFailed;
// If true, the graphics context is being restored.
bool m_recreatingGraphicsContext;
#endif #endif
static const WebInputEvent* m_currentInputEvent; static const WebInputEvent* m_currentInputEvent;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment