<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[188324] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/188324">188324</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-08-11 21:58:37 -0700 (Tue, 11 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WK2] ASSERT(!m_properties.backingStore || owner()) sometimes on zooming
https://bugs.webkit.org/show_bug.cgi?id=147854

Reviewed by Tim Horton.

When destroying a TileGrid, the container layer remains alive by virtue of being
in the layer tree, and it and its tiles get visited during layer tree transaction
building but we assert because we've cleared the owner on the tile layers.

The real bug is that TileController doesn't tell GraphicsLayerCA when the custom
sublayers change. Make this possible via a new PlatformCALayerClient function,
and make TileController use this when rearranging its tile grids.

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::platformCALayerCustomSublayersChanged):
(WebCore::GraphicsLayerCA::updateContentsScale): No need to explicitly set
the ChildrenChanged flag now.
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCALayerClient.h:
(WebCore::PlatformCALayerClient::platformCALayerCustomSublayersChanged):
(WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay):
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::setNeedsDisplay):
(WebCore::TileController::setContentsScale):
(WebCore::TileController::setZoomedOutContentsScale):
(WebCore::TileController::revalidateTiles):
(WebCore::TileController::clearZoomedOutTileGrid):
(WebCore::TileController::tileGridsChanged):
(WebCore::TileController::tileRevalidationTimerFired):
* platform/graphics/ca/TileController.h:
* platform/graphics/ca/TileGrid.h: Default param.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAh">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaPlatformCALayerClienth">trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileControllercpp">trunk/Source/WebCore/platform/graphics/ca/TileController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileControllerh">trunk/Source/WebCore/platform/graphics/ca/TileController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridh">trunk/Source/WebCore/platform/graphics/ca/TileGrid.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/ChangeLog        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2015-08-11  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS WK2] ASSERT(!m_properties.backingStore || owner()) sometimes on zooming
+        https://bugs.webkit.org/show_bug.cgi?id=147854
+
+        Reviewed by Tim Horton.
+
+        When destroying a TileGrid, the container layer remains alive by virtue of being
+        in the layer tree, and it and its tiles get visited during layer tree transaction
+        building but we assert because we've cleared the owner on the tile layers.
+
+        The real bug is that TileController doesn't tell GraphicsLayerCA when the custom
+        sublayers change. Make this possible via a new PlatformCALayerClient function,
+        and make TileController use this when rearranging its tile grids.
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::platformCALayerCustomSublayersChanged):
+        (WebCore::GraphicsLayerCA::updateContentsScale): No need to explicitly set
+        the ChildrenChanged flag now.
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/PlatformCALayerClient.h:
+        (WebCore::PlatformCALayerClient::platformCALayerCustomSublayersChanged):
+        (WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay):
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::setNeedsDisplay):
+        (WebCore::TileController::setContentsScale):
+        (WebCore::TileController::setZoomedOutContentsScale):
+        (WebCore::TileController::revalidateTiles):
+        (WebCore::TileController::clearZoomedOutTileGrid):
+        (WebCore::TileController::tileGridsChanged):
+        (WebCore::TileController::tileRevalidationTimerFired):
+        * platform/graphics/ca/TileController.h:
+        * platform/graphics/ca/TileGrid.h: Default param.
+
</ins><span class="cx"> 2015-08-11  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Disconnect LayoutStateDisabler logic and RenderView pointer.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -1404,6 +1404,11 @@
</span><span class="cx">         client().didCommitChangesForLayer(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsLayerCA::platformCALayerCustomSublayersChanged(PlatformCALayer*)
+{
+    noteLayerPropertyChanged(ChildrenChanged, m_isCommittingChanges ? DontScheduleFlush : ScheduleFlush);
+}
+
</ins><span class="cx"> bool GraphicsLayerCA::platformCALayerShowRepaintCounter(PlatformCALayer* platformLayer) const
</span><span class="cx"> {
</span><span class="cx">     // The repaint counters are painted into the TileController tiles (which have no corresponding platform layer),
</span><span class="lines">@@ -3200,9 +3205,6 @@
</span><span class="cx">         m_contentsLayer-&gt;setContentsScale(contentsScale);
</span><span class="cx"> 
</span><span class="cx">     if (tiledBacking()) {
</span><del>-        // Scale change may swap in a different set of tiles changing the custom child layers.
-        if (isPageTiledBackingLayer())
-            m_uncommittedChanges |= ChildrenChanged;
</del><span class="cx">         // Tiled backing repaints automatically on scale change.
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -181,6 +181,7 @@
</span><span class="cx">     // PlatformCALayerClient overrides
</span><span class="cx">     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }
</span><span class="cx">     virtual bool platformCALayerRespondsToLayoutChanges() const override { return false; }
</span><ins>+    WEBCORE_EXPORT void platformCALayerCustomSublayersChanged(PlatformCALayer*) override;
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void platformCALayerAnimationStarted(const String&amp; animationKey, CFTimeInterval beginTime) override;
</span><span class="cx">     WEBCORE_EXPORT void platformCALayerAnimationEnded(const String&amp; animationKey) override;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCALayerClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx">     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { }
</span><span class="cx">     virtual bool platformCALayerRespondsToLayoutChanges() const { return false; }
</span><span class="cx"> 
</span><ins>+    virtual void platformCALayerCustomSublayersChanged(PlatformCALayer*) { }
+
</ins><span class="cx">     virtual void platformCALayerAnimationStarted(const String&amp; /*animationKey*/, CFTimeInterval) { }
</span><span class="cx">     virtual void platformCALayerAnimationEnded(const String&amp; /*animationKey*/) { }
</span><span class="cx">     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; }
</span><span class="lines">@@ -49,7 +51,7 @@
</span><span class="cx">     
</span><span class="cx">     virtual bool platformCALayerContentsOpaque() const = 0;
</span><span class="cx">     virtual bool platformCALayerDrawsContent() const = 0;
</span><del>-    virtual void platformCALayerLayerDidDisplay(PlatformCALayer*)  { }
</del><ins>+    virtual void platformCALayerLayerDidDisplay(PlatformCALayer*) { }
</ins><span class="cx"> 
</span><span class="cx">     virtual void platformCALayerSetNeedsToRevalidateTiles() { }
</span><span class="cx">     virtual float platformCALayerDeviceScaleFactor() const = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx"> void TileController::setNeedsDisplay()
</span><span class="cx"> {
</span><span class="cx">     tileGrid().setNeedsDisplay();
</span><del>-    m_zoomedOutTileGrid = nullptr;
</del><ins>+    clearZoomedOutTileGrid();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileController::setNeedsDisplayInRect(const IntRect&amp; rect)
</span><span class="lines">@@ -125,7 +125,8 @@
</span><span class="cx">     if (m_zoomedOutTileGrid &amp;&amp; m_zoomedOutTileGrid-&gt;scale() == scale) {
</span><span class="cx">         m_tileGrid = WTF::move(m_zoomedOutTileGrid);
</span><span class="cx">         m_tileGrid-&gt;setIsZoomedOutTileGrid(false);
</span><del>-        m_tileGrid-&gt;revalidateTiles(0);
</del><ins>+        m_tileGrid-&gt;revalidateTiles();
+        tileGridsChanged();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -133,6 +134,7 @@
</span><span class="cx">         m_zoomedOutTileGrid = WTF::move(m_tileGrid);
</span><span class="cx">         m_zoomedOutTileGrid-&gt;setIsZoomedOutTileGrid(true);
</span><span class="cx">         m_tileGrid = std::make_unique&lt;TileGrid&gt;(*this);
</span><ins>+        tileGridsChanged();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     tileGrid().setScale(scale);
</span><span class="lines">@@ -161,7 +163,7 @@
</span><span class="cx">     m_zoomedOutContentsScale = scale;
</span><span class="cx"> 
</span><span class="cx">     if (m_zoomedOutTileGrid &amp;&amp; m_zoomedOutTileGrid-&gt;scale() != m_zoomedOutContentsScale)
</span><del>-        m_zoomedOutTileGrid = nullptr;
</del><ins>+        clearZoomedOutTileGrid();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
</span><span class="lines">@@ -261,7 +263,7 @@
</span><span class="cx"> void TileController::revalidateTiles()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(owningGraphicsLayer()-&gt;isCommittingChanges());
</span><del>-    tileGrid().revalidateTiles(0);
</del><ins>+    tileGrid().revalidateTiles();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileController::forceRepaint()
</span><span class="lines">@@ -426,6 +428,17 @@
</span><span class="cx">     return owningGraphicsLayer()-&gt;platformCALayerShouldTemporarilyRetainTileCohorts(m_tileCacheLayer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TileController::clearZoomedOutTileGrid()
+{
+    m_zoomedOutTileGrid = nullptr;
+    tileGridsChanged();
+}
+
+void TileController::tileGridsChanged()
+{
+    return owningGraphicsLayer()-&gt;platformCALayerCustomSublayersChanged(m_tileCacheLayer);
+}
+
</ins><span class="cx"> void TileController::tileRevalidationTimerFired()
</span><span class="cx"> {
</span><span class="cx">     if (!owningGraphicsLayer())
</span><span class="lines">@@ -436,7 +449,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     // If we are not visible get rid of the zoomed-out tiles.
</span><del>-    m_zoomedOutTileGrid = nullptr;
</del><ins>+    clearZoomedOutTileGrid();
</ins><span class="cx"> 
</span><span class="cx">     TileGrid::TileValidationPolicy validationPolicy = (shouldAggressivelyRetainTiles() ? 0 : TileGrid::PruneSecondaryTiles) | TileGrid::UnparentAllTiles;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileController.h        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -158,6 +158,9 @@
</span><span class="cx">     virtual void setZoomedOutContentsScale(float) override;
</span><span class="cx">     virtual float zoomedOutContentsScale() const override;
</span><span class="cx"> 
</span><ins>+    void clearZoomedOutTileGrid();
+    void tileGridsChanged();
+
</ins><span class="cx">     void tileRevalidationTimerFired();
</span><span class="cx">     void setNeedsRevalidateTiles();
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.h (188323 => 188324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.h        2015-08-12 04:20:24 UTC (rev 188323)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.h        2015-08-12 04:58:37 UTC (rev 188324)
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">         UnparentAllTiles    = 1 &lt;&lt; 1
</span><span class="cx">     };
</span><span class="cx">     typedef unsigned TileValidationPolicy;
</span><del>-    void revalidateTiles(TileValidationPolicy);
</del><ins>+    void revalidateTiles(TileValidationPolicy = 0);
</ins><span class="cx"> 
</span><span class="cx">     bool tilesWouldChangeForCoverageRect(const FloatRect&amp;) const;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>