[chromium] Gracefully handle compositor initialization failure in single-threaded...
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2012 21:50:57 +0000 (21:50 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2012 21:50:57 +0000 (21:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78013

Reviewed by Kenneth Russell.

If compositor initialization fails it's not safe to proceed through the rest of the frame process. This adds
some early outs.

Tested manually by forcing the first makeContextCurrent() call fail.

* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::updateLayers):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::compositeAndReadback):
(WebCore::CCSingleThreadProxy::compositeImmediately):
(WebCore::CCSingleThreadProxy::commitIfNeeded):
* platform/graphics/chromium/cc/CCSingleThreadProxy.h:
(CCSingleThreadProxy):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106986 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

index 780eca1..bc50fc8 100644 (file)
@@ -1,3 +1,26 @@
+2012-02-07  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Gracefully handle compositor initialization failure in single-threaded proxy
+        https://bugs.webkit.org/show_bug.cgi?id=78013
+
+        Reviewed by Kenneth Russell.
+
+        If compositor initialization fails it's not safe to proceed through the rest of the frame process. This adds
+        some early outs.
+
+        Tested manually by forcing the first makeContextCurrent() call fail.
+
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::updateLayers):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHost):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::compositeAndReadback):
+        (WebCore::CCSingleThreadProxy::compositeImmediately):
+        (WebCore::CCSingleThreadProxy::commitIfNeeded):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
+        (CCSingleThreadProxy):
+
 2012-02-07  Brady Eidson  <beidson@apple.com>
 
         <rdar://problem/9567286> and https://bugs.webkit.org/show_bug.cgi?id=78003
index 3c356ef..70c9c82 100644 (file)
@@ -371,22 +371,23 @@ void CCLayerTreeHost::composite()
     static_cast<CCSingleThreadProxy*>(m_proxy.get())->compositeImmediately();
 }
 
-void CCLayerTreeHost::updateLayers()
+bool CCLayerTreeHost::updateLayers()
 {
     if (!m_layerRendererInitialized) {
         initializeLayerRenderer();
         // If we couldn't initialize, then bail since we're returning to software mode.
         if (!m_layerRendererInitialized)
-            return;
+            return false;
     }
 
     if (!rootLayer())
-        return;
+        return true;
 
     if (viewportSize().isEmpty())
-        return;
+        return true;
 
     updateLayers(rootLayer());
+    return true;
 }
 
 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer)
index 2224f7c..c3810ab 100644 (file)
@@ -184,7 +184,8 @@ public:
 
     void setHaveWheelEventHandlers(bool);
 
-    void updateLayers();
+    // Returns false if we should abort this frame due to initialization failure.
+    bool updateLayers();
 
     void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
     void applyScrollAndScale(const CCScrollAndScaleSet&);
index 70dec05..cb696ed 100644 (file)
@@ -78,7 +78,8 @@ bool CCSingleThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect
         return false;
     }
 
-    commitIfNeeded();
+    if (!commitIfNeeded())
+        return false;
 
     if (!doComposite())
         return false;
@@ -228,7 +229,8 @@ void CCSingleThreadProxy::compositeImmediately()
     if (!recreateContextIfNeeded())
         return;
 
-    commitIfNeeded();
+    if (!commitIfNeeded())
+        return;
 
     if (doComposite())
         m_layerTreeHostImpl->swapBuffers();
@@ -282,13 +284,15 @@ bool CCSingleThreadProxy::recreateContextIfNeeded()
     return false;
 }
 
-void CCSingleThreadProxy::commitIfNeeded()
+bool CCSingleThreadProxy::commitIfNeeded()
 {
     ASSERT(CCProxy::isMainThread());
 
-    m_layerTreeHost->updateLayers();
+    if (!m_layerTreeHost->updateLayers())
+        return false;
 
     doCommit();
+    return true;
 }
 
 bool CCSingleThreadProxy::doComposite()
index 4345ed6..da1fe46 100644 (file)
@@ -68,7 +68,7 @@ public:
 private:
     explicit CCSingleThreadProxy(CCLayerTreeHost*);
     bool recreateContextIfNeeded();
-    void commitIfNeeded();
+    bool commitIfNeeded();
     void doCommit();
     bool doComposite();
 
index 4b203f3..fd63bd5 100644 (file)
@@ -397,7 +397,8 @@ void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTim
     // updateLayers.
     m_commitRequested = false;
 
-    m_layerTreeHost->updateLayers();
+    if (!m_layerTreeHost->updateLayers())
+        return;
 
     // Before applying scrolls and calling animate, we set m_animateRequested to false.
     // If it is true now, it means setNeedAnimate was called again. Call setNeedsCommit