Never remove root compositing layers in the web process
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2012 23:42:17 +0000 (23:42 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2012 23:42:17 +0000 (23:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82255
<rdar://problem/11058521>

Reviewed by Sam Weinig.

Since we never leave accelerated compositing mode when using tiled drawing, we should
never remove root compositing layers in the web process.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index 6365f59..c7b8582 100644 (file)
@@ -1,3 +1,17 @@
+2012-03-26  Anders Carlsson  <andersca@apple.com>
+
+        Never remove root compositing layers in the web process
+        https://bugs.webkit.org/show_bug.cgi?id=82255
+        <rdar://problem/11058521>
+
+        Reviewed by Sam Weinig.
+
+        Since we never leave accelerated compositing mode when using tiled drawing, we should
+        never remove root compositing layers in the web process.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
+
 2012-03-26  Rafael Brandao  <rafael.lobo@openbossa.org>
 
         [Qt][WK2] default families are not set in QWebPreferences
index 25a8383..28658ad 100644 (file)
@@ -110,6 +110,13 @@ void TiledCoreAnimationDrawingArea::setRootCompositingLayer(GraphicsLayer* graph
 {
     CALayer *rootCompositingLayer = graphicsLayer ? graphicsLayer->platformLayer() : nil;
 
+    // Since we'll always be in accelerated compositing mode, the only time that layer will be nil
+    // is when the WKView is removed from its containing window. In that case, the layer will already be
+    // removed from the layer tree hierarchy over in the UI process, so there's no reason to remove it locally.
+    // In addition, removing the layer here will cause flashes when switching between tabs.
+    if (!rootCompositingLayer)
+        return;
+
     if (m_layerTreeStateIsFrozen) {
         m_pendingRootCompositingLayer = rootCompositingLayer;
         return;
@@ -325,19 +332,16 @@ void TiledCoreAnimationDrawingArea::setLayerHostingMode(uint32_t opaqueLayerHost
 
 void TiledCoreAnimationDrawingArea::setRootCompositingLayer(CALayer *layer)
 {
+    ASSERT(layer);
     ASSERT(!m_layerTreeStateIsFrozen);
 
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
 
-    if (!layer)
-        m_rootLayer.get().sublayers = nil;
-    else {
-        m_rootLayer.get().sublayers = [NSArray arrayWithObject:layer];
+    m_rootLayer.get().sublayers = [NSArray arrayWithObject:layer];
 
-        if (m_pageOverlayLayer)
-            [m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
-    }
+    if (m_pageOverlayLayer)
+        [m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
 
     [CATransaction commit];
 }