Safari pages are blank sometimes (missing tiles)
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Feb 2017 22:33:42 +0000 (22:33 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Feb 2017 22:33:42 +0000 (22:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167904

Reviewed by Tim Horton.

Source/WebCore:

After r211683 we failed to udpate the "inWindow" flag on the page tiled layer, because
usingTiledBacking() on GraphicsLayer confusingly was false for the page tiled layer.

Fix by removing usingTiledBacking() entirely, and checking for tiledBacking(),
looking at the layer type when necessary.

Tested by tiled-drawing/tiled-backing-in-window.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::GraphicsLayer):
(WebCore::GraphicsLayer::setIsInWindowIncludingDescendants): This is the bug fix.
(WebCore::GraphicsLayer::getDebugBorderInfo):
(WebCore::GraphicsLayer::dumpProperties):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::usingTiledBacking): Deleted.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::changeLayerTypeTo):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::willDestroyLayer):
(WebCore::RenderLayerBacking::compositingLayerType):
* rendering/RenderLayerCompositor.cpp: A bit more logging.
(WebCore::RenderLayerCompositor::setIsInWindow):
(WebCore::RenderLayerCompositor::attachRootLayer):

LayoutTests:

New result; this test detected the bug.

* tiled-drawing/tiled-backing-in-window-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/tiled-drawing/tiled-backing-in-window-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 30b4f33..904705e 100644 (file)
@@ -1,3 +1,14 @@
+2017-02-06  Simon Fraser  <simon.fraser@apple.com>
+
+        Safari pages are blank sometimes (missing tiles)
+        https://bugs.webkit.org/show_bug.cgi?id=167904
+
+        Reviewed by Tim Horton.
+
+        New result; this test detected the bug.
+
+        * tiled-drawing/tiled-backing-in-window-expected.txt:
+
 2017-02-06  Ryan Haddad  <ryanhaddad@apple.com>
 
         Skip media/audio-dealloc-crash.html on ios-simulator.
index da114e1..d5cd7fb 100644 (file)
@@ -55,7 +55,7 @@ Tiled box
       (tile cache coverage 0, 0 1024 x 1016)
       (tile size 512 x 512)
       (top left tile 0, 0 tiles grid 2 x 2)
-      (in window 1)
+      (in window 0)
       (children 1
         (GraphicsLayer
           (position 8.00 8.00)
index e57f993..d572113 100644 (file)
@@ -1,3 +1,36 @@
+2017-02-06  Simon Fraser  <simon.fraser@apple.com>
+
+        Safari pages are blank sometimes (missing tiles)
+        https://bugs.webkit.org/show_bug.cgi?id=167904
+
+        Reviewed by Tim Horton.
+
+        After r211683 we failed to udpate the "inWindow" flag on the page tiled layer, because
+        usingTiledBacking() on GraphicsLayer confusingly was false for the page tiled layer.
+
+        Fix by removing usingTiledBacking() entirely, and checking for tiledBacking(),
+        looking at the layer type when necessary.
+
+        Tested by tiled-drawing/tiled-backing-in-window.html
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::GraphicsLayer):
+        (WebCore::GraphicsLayer::setIsInWindowIncludingDescendants): This is the bug fix.
+        (WebCore::GraphicsLayer::getDebugBorderInfo):
+        (WebCore::GraphicsLayer::dumpProperties):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::usingTiledBacking): Deleted.
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::recursiveCommitChanges):
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+        (WebCore::GraphicsLayerCA::changeLayerTypeTo):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::willDestroyLayer):
+        (WebCore::RenderLayerBacking::compositingLayerType):
+        * rendering/RenderLayerCompositor.cpp: A bit more logging.
+        (WebCore::RenderLayerCompositor::setIsInWindow):
+        (WebCore::RenderLayerCompositor::attachRootLayer):
+
 2017-02-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Change the CSS animation timer a to be little more than 60fps to ensure we hit that frame rate
index 2c40fc7..11beca7 100644 (file)
@@ -117,7 +117,6 @@ GraphicsLayer::GraphicsLayer(Type type, GraphicsLayerClient& client)
     , m_contentsOpaque(false)
     , m_preserves3D(false)
     , m_backfaceVisibility(true)
-    , m_usingTiledBacking(false)
     , m_masksToBounds(false)
     , m_drawsContent(false)
     , m_contentsVisible(true)
@@ -366,8 +365,8 @@ void GraphicsLayer::noteDeviceOrPageScaleFactorChangedIncludingDescendants()
 
 void GraphicsLayer::setIsInWindowIncludingDescendants(bool inWindow)
 {
-    if (usingTiledBacking())
-        tiledBacking()->setIsInWindow(inWindow);
+    if (TiledBacking* tiledBacking = this->tiledBacking())
+        tiledBacking->setIsInWindow(inWindow);
 
     for (auto* childLayer : children())
         childLayer->setIsInWindowIncludingDescendants(inWindow);
@@ -455,7 +454,7 @@ void GraphicsLayer::getDebugBorderInfo(Color& color, float& width) const
     }
     
     if (drawsContent()) {
-        if (m_usingTiledBacking) {
+        if (tiledBacking()) {
             color = Color(255, 128, 0, 128); // tiled layer: orange
             return;
         }
@@ -741,9 +740,9 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBe
     }
 #endif
 
-    if (m_usingTiledBacking) {
+    if (type() == Type::Normal && tiledBacking()) {
         writeIndent(ts, indent + 1);
-        ts << "(usingTiledLayer " << m_usingTiledBacking << ")\n";
+        ts << "(usingTiledLayer 1)\n";
     }
 
     bool needsIOSDumpRenderTreeMainFrameRenderViewLayerIsAlwaysOpaqueHack = m_client.needsIOSDumpRenderTreeMainFrameRenderViewLayerIsAlwaysOpaqueHack(*this);
index 35dce4b..e8b2f25 100644 (file)
@@ -543,7 +543,6 @@ public:
     // Return an estimate of the backing store memory cost (in bytes). May be incorrect for tiled layers.
     WEBCORE_EXPORT virtual double backingStoreMemoryEstimate() const;
 
-    bool usingTiledBacking() const { return m_usingTiledBacking; }
     virtual TiledBacking* tiledBacking() const { return 0; }
 
     void resetTrackedRepaints();
@@ -632,7 +631,6 @@ protected:
     bool m_contentsOpaque : 1;
     bool m_preserves3D: 1;
     bool m_backfaceVisibility : 1;
-    bool m_usingTiledBacking : 1;
     bool m_masksToBounds : 1;
     bool m_drawsContent : 1;
     bool m_contentsVisible : 1;
index 118ed82..9572a5e 100644 (file)
@@ -1382,7 +1382,7 @@ void GraphicsLayerCA::recursiveCommitChanges(const CommitState& commitState, con
 #ifdef VISIBLE_TILE_WASH
     // Use having a transform as a key to making the tile wash layer. If every layer gets a wash,
     // they start to obscure useful information.
-    if ((!m_transform.isIdentity() || m_usingTiledBacking) && !m_visibleTileWashLayer) {
+    if ((!m_transform.isIdentity() || tiledBacking()) && !m_visibleTileWashLayer) {
         static NeverDestroyed<Color> washFillColor(255, 0, 0, 50);
         static NeverDestroyed<Color> washBorderColor(255, 0, 0, 100);
         
@@ -1559,13 +1559,15 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState
 
     bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
     bool needBackdropLayerType = (customAppearance() == LightBackdropAppearance || customAppearance() == DarkBackdropAppearance);
-    PlatformCALayer::LayerType neededLayerType = m_layer->layerType();
+
+    PlatformCALayer::LayerType currentLayerType = m_layer->layerType();
+    PlatformCALayer::LayerType neededLayerType = currentLayerType;
 
     if (needBackdropLayerType)
         neededLayerType = layerTypeForCustomBackdropAppearance(customAppearance());
     else if (needTiledLayer)
         neededLayerType = PlatformCALayer::LayerTypeTiledBackingLayer;
-    else if (isCustomBackdropLayerType(m_layer->layerType()) || m_usingTiledBacking)
+    else if (currentLayerType == PlatformCALayer::LayerTypeTiledBackingLayer || isCustomBackdropLayerType(m_layer->layerType()))
         neededLayerType = PlatformCALayer::LayerTypeWebLayer;
 
     if (neededLayerType != m_layer->layerType())
@@ -3563,11 +3565,12 @@ void GraphicsLayerCA::changeLayerTypeTo(PlatformCALayer::LayerType newLayerType)
     if (newLayerType == oldLayerType)
         return;
 
-    RefPtr<PlatformCALayer> oldLayer = m_layer;
+    bool wasTiledLayer = oldLayerType == PlatformCALayer::LayerTypeTiledBackingLayer;
+    bool isTiledLayer = newLayerType == PlatformCALayer::LayerTypeTiledBackingLayer;
 
+    RefPtr<PlatformCALayer> oldLayer = m_layer;
     m_layer = createPlatformCALayer(newLayerType, this);
 
-    m_usingTiledBacking = newLayerType == PlatformCALayer::LayerTypeTiledBackingLayer;
     m_usingBackdropLayerType = isCustomBackdropLayerType(newLayerType);
 
     m_layer->adoptSublayers(*oldLayer);
@@ -3606,7 +3609,7 @@ void GraphicsLayerCA::changeLayerTypeTo(PlatformCALayer::LayerType newLayerType)
         | NameChanged
         | DebugIndicatorsChanged;
     
-    if (m_usingTiledBacking)
+    if (isTiledLayer)
         m_uncommittedChanges |= CoverageRectChanged;
 
     moveAnimations(oldLayer.get(), m_layer.get());
@@ -3614,8 +3617,8 @@ void GraphicsLayerCA::changeLayerTypeTo(PlatformCALayer::LayerType newLayerType)
     // need to tell new layer to draw itself
     setNeedsDisplay();
 
-    if (oldLayerType == PlatformCALayer::LayerTypeTiledBackingLayer || newLayerType == PlatformCALayer::LayerTypeTiledBackingLayer)
-        client().tiledBackingUsageChanged(this, m_usingTiledBacking);
+    if (wasTiledLayer || isTiledLayer)
+        client().tiledBackingUsageChanged(this, isTiledLayer);
 }
 
 GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayerCA::defaultContentsOrientation() const
index 0e61cff..0a6bf03 100644 (file)
@@ -127,7 +127,7 @@ RenderLayerBacking::~RenderLayerBacking()
 
 void RenderLayerBacking::willDestroyLayer(const GraphicsLayer* layer)
 {
-    if (layer && layer->usingTiledBacking())
+    if (layer && layer->type() == GraphicsLayer::Type::Normal && layer->tiledBacking())
         compositor().layerTiledBackingUsageChanged(layer, false);
 }
 
@@ -2798,7 +2798,7 @@ CompositingLayerType RenderLayerBacking::compositingLayerType() const
         return MediaCompositingLayer;
 
     if (m_graphicsLayer->drawsContent())
-        return m_graphicsLayer->usingTiledBacking() ? TiledCompositingLayer : NormalCompositingLayer;
+        return m_graphicsLayer->tiledBacking() ? TiledCompositingLayer : NormalCompositingLayer;
     
     return ContainerCompositingLayer;
 }
index 261d173..6d001c9 100644 (file)
@@ -2027,6 +2027,8 @@ GraphicsLayer* RenderLayerCompositor::footerLayer() const
 
 void RenderLayerCompositor::setIsInWindow(bool isInWindow)
 {
+    LOG(Compositing, "RenderLayerCompositor %p setIsInWindow %d", this, isInWindow);
+
     if (!inCompositingMode())
         return;
 
@@ -3445,6 +3447,8 @@ void RenderLayerCompositor::attachRootLayer(RootLayerAttachment attachment)
     if (!m_rootContentLayer)
         return;
 
+    LOG(Compositing, "RenderLayerCompositor %p attachRootLayer %d", this, attachment);
+
     switch (attachment) {
         case RootLayerUnattached:
             ASSERT_NOT_REACHED();