Title: [215181] trunk
Revision
215181
Author
akl...@apple.com
Date
2017-04-10 06:49:18 -0700 (Mon, 10 Apr 2017)

Log Message

Don't generate extra scrolling tiles for non-visible pages.
https://bugs.webkit.org/show_bug.cgi?id=167213
<rdar://problem/30105774>

Reviewed by Antti Koivisto.

Source/WebCore:

Reduce the tiling coverage to a minimum when the page is non-visible.
On macOS, this means that fully occluded web views can maintain a smaller set of tiles
in non-volatile surfaces, reducing net footprint.

Test: compositing/tiling/non-visible-window-tile-coverage.html

* rendering/RenderLayerBacking.cpp:
(WebCore::computePageTiledBackingCoverage): If the page's activity state is non-visible, use minimal tile coverage.
* platform/ScrollView.h:
* page/FrameView.h:
* page/FrameView.cpp:
(WebCore::FrameView::hide): Call adjustTiledBackingCoverage() in hide() since it now takes page visibility into account.

(WebCore::FrameView::enableSpeculativeTilingIfNeeded):
* testing/Internals.cpp:
(WebCore::Internals::setSpeculativeTilingDelayDisabledForTesting):
* testing/Internals.h:
* testing/Internals.idl: Add an internals API for disabling the 500ms delay before speculative tiling begins after
the main frame load finishes. This is needed for reliably testing this change.

LayoutTests:

* TestExpectations:
* compositing/tiling/non-visible-window-tile-coverage-expected.txt: Added.
* compositing/tiling/non-visible-window-tile-coverage.html: Added.
* platform/mac-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (215180 => 215181)


--- trunk/LayoutTests/ChangeLog	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/LayoutTests/ChangeLog	2017-04-10 13:49:18 UTC (rev 215181)
@@ -1,3 +1,16 @@
+2017-04-10  Andreas Kling  <akl...@apple.com>
+
+        Don't generate extra scrolling tiles for non-visible pages.
+        https://bugs.webkit.org/show_bug.cgi?id=167213
+        <rdar://problem/30105774>
+
+        Reviewed by Antti Koivisto.
+
+        * TestExpectations:
+        * compositing/tiling/non-visible-window-tile-coverage-expected.txt: Added.
+        * compositing/tiling/non-visible-window-tile-coverage.html: Added.
+        * platform/mac-wk2/TestExpectations:
+
 2017-04-10  Carlos Garcia Campos  <cgar...@igalia.com>
 
         REGRESSION(r214426): [GTK] Test media/video-click-dblckick-standalone.html started to fail in the bots after r214426

Modified: trunk/LayoutTests/TestExpectations (215180 => 215181)


--- trunk/LayoutTests/TestExpectations	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/LayoutTests/TestExpectations	2017-04-10 13:49:18 UTC (rev 215181)
@@ -1247,3 +1247,6 @@
 
 webkit.org/b/170355 [ Release ] fast/mediastream/MediaStream-page-muted.html [ Pass Timeout ]
 webkit.org/b/170355 [ Debug ] fast/mediastream/MediaStream-page-muted.html [ Pass Crash ]
+
+# Only relevant on Mac-WK2
+compositing/tiling/non-visible-window-tile-coverage.html [ Skip ]

Added: trunk/LayoutTests/compositing/tiling/non-visible-window-tile-coverage-expected.txt (0 => 215181)


--- trunk/LayoutTests/compositing/tiling/non-visible-window-tile-coverage-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/non-visible-window-tile-coverage-expected.txt	2017-04-10 13:49:18 UTC (rev 215181)
@@ -0,0 +1,49 @@
+Tiles when window is visible:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 3008.00 3092.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (coverage rect 0.00, 0.00 785.00 x 585.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 3008.00 3092.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (coverage rect 0.00, 0.00 1570.00 x 1755.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (tile cache coverage 0, 0 2048 x 2048)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 4 x 4)
+      (in window 1)
+    )
+  )
+)
+Tiles when window is not visible:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 3008.00 3438.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (coverage rect 0.00, 0.00 785.00 x 585.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 3008.00 3438.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (coverage rect 0.00, 0.00 785.00 x 585.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/tiling/non-visible-window-tile-coverage.html (0 => 215181)


--- trunk/LayoutTests/compositing/tiling/non-visible-window-tile-coverage.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/tiling/non-visible-window-tile-coverage.html	2017-04-10 13:49:18 UTC (rev 215181)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Tiles when window is visible:</p>
+<pre id="visibleResult"></pre>
+<p>Tiles when window is not visible:</p>
+<pre id="nonVisibleResult"></pre>
+<div style="height: 3000px; width: 3000px"></div>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    internals.setSpeculativeTilingDelayDisabledForTesting(true);
+
+    _onload_ = function() {
+        setTimeout(function() {
+
+            document.getElementById("visibleResult").innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+            document._onvisibilitychange_ = function() {
+                if (!document.hidden)
+                    return;
+                setTimeout(function() {
+                    document.getElementById("nonVisibleResult").innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+
+                    testRunner.resetPageVisibility();
+                    internals.setSpeculativeTilingDelayDisabledForTesting(false);
+                    testRunner.notifyDone();
+                }, 0);
+            }
+            testRunner.setPageVisibility("hidden");
+        }, 0);
+    }
+}
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (215180 => 215181)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2017-04-10 13:49:18 UTC (rev 215181)
@@ -647,3 +647,5 @@
 webkit.org/b/170203 fast/images/animated-image-different-dest-size.html [ Pass ImageOnlyFailure ]
 
 webkit.org/b/170410 fast/images/animated-gif-webkit-transform.html [ Pass Failure ]
+
+compositing/tiling/non-visible-window-tile-coverage.html [ Pass ]

Modified: trunk/Source/WebCore/ChangeLog (215180 => 215181)


--- trunk/Source/WebCore/ChangeLog	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/ChangeLog	2017-04-10 13:49:18 UTC (rev 215181)
@@ -1,3 +1,31 @@
+2017-04-10  Andreas Kling  <akl...@apple.com>
+
+        Don't generate extra scrolling tiles for non-visible pages.
+        https://bugs.webkit.org/show_bug.cgi?id=167213
+        <rdar://problem/30105774>
+
+        Reviewed by Antti Koivisto.
+
+        Reduce the tiling coverage to a minimum when the page is non-visible.
+        On macOS, this means that fully occluded web views can maintain a smaller set of tiles
+        in non-volatile surfaces, reducing net footprint.
+
+        Test: compositing/tiling/non-visible-window-tile-coverage.html
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::computePageTiledBackingCoverage): If the page's activity state is non-visible, use minimal tile coverage.
+        * platform/ScrollView.h:
+        * page/FrameView.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::hide): Call adjustTiledBackingCoverage() in hide() since it now takes page visibility into account.
+
+        (WebCore::FrameView::enableSpeculativeTilingIfNeeded):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setSpeculativeTilingDelayDisabledForTesting):
+        * testing/Internals.h:
+        * testing/Internals.idl: Add an internals API for disabling the 500ms delay before speculative tiling begins after
+        the main frame load finishes. This is needed for reliably testing this change.
+
 2017-04-10  Per Arne Vollan  <pvol...@apple.com>
 
         Add fallback fonts to video captions stylesheet.

Modified: trunk/Source/WebCore/page/FrameView.cpp (215180 => 215181)


--- trunk/Source/WebCore/page/FrameView.cpp	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/page/FrameView.cpp	2017-04-10 13:49:18 UTC (rev 215181)
@@ -2931,6 +2931,12 @@
     }
     if (!shouldEnableSpeculativeTilingDuringLoading(*this))
         return;
+
+    if (m_speculativeTilingDelayDisabledForTesting) {
+        speculativeTilingEnableTimerFired();
+        return;
+    }
+
     if (m_speculativeTilingEnableTimer.isActive())
         return;
     // Delay enabling a bit as load completion may trigger further loading from scripts.
@@ -2958,6 +2964,13 @@
         adjustTiledBackingCoverage();
     }
 }
+
+void FrameView::hide()
+{
+    ScrollView::hide();
+    adjustTiledBackingCoverage();
+}
+
 void FrameView::convertSubtreeLayoutToFullLayout()
 {
     ASSERT(m_layoutRoot);

Modified: trunk/Source/WebCore/page/FrameView.h (215180 => 215181)


--- trunk/Source/WebCore/page/FrameView.h	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/page/FrameView.h	2017-04-10 13:49:18 UTC (rev 215181)
@@ -582,6 +582,7 @@
     void didChangeScrollOffset();
 
     void show() final;
+    void hide() final;
 
     bool shouldPlaceBlockDirectionScrollbarOnLeft() const final;
 
@@ -590,6 +591,8 @@
     void willDestroyRenderTree();
     void didDestroyRenderTree();
 
+    void setSpeculativeTilingDelayDisabledForTesting(bool disabled) { m_speculativeTilingDelayDisabledForTesting = disabled; }
+
 protected:
     bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) final;
     void scrollContentsSlowPath(const IntRect& updateRect) final;
@@ -862,6 +865,7 @@
 
     bool m_visualUpdatesAllowedByClient;
     bool m_hasFlippedBlockRenderers;
+    bool m_speculativeTilingDelayDisabledForTesting { false };
 
     ScrollPinningBehavior m_scrollPinningBehavior;
 

Modified: trunk/Source/WebCore/platform/ScrollView.h (215180 => 215181)


--- trunk/Source/WebCore/platform/ScrollView.h	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/platform/ScrollView.h	2017-04-10 13:49:18 UTC (rev 215181)
@@ -349,7 +349,7 @@
 
     // Widget overrides to ensure that our children's visibility status is kept up to date when we get shown and hidden.
     WEBCORE_EXPORT void show() override;
-    WEBCORE_EXPORT void hide() final;
+    WEBCORE_EXPORT void hide() override;
     WEBCORE_EXPORT void setParentVisible(bool) final;
     
     // Pan scrolling.

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (215180 => 215181)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2017-04-10 13:49:18 UTC (rev 215181)
@@ -300,6 +300,10 @@
     // FIXME: When we use TiledBacking for overflow, this should look at RenderView scrollability.
     FrameView& frameView = backing->owningLayer().renderer().view().frameView();
 
+    // If the page is non-visible, don't incur the cost of keeping extra tiles for scrolling.
+    if (!backing->owningLayer().page().isVisible())
+        return TiledBacking::CoverageForVisibleArea;
+
     TiledBacking::TileCoverage tileCoverage = TiledBacking::CoverageForVisibleArea;
     bool useMinimalTilesDuringLiveResize = frameView.inLiveResize();
     if (frameView.speculativeTilingEnabled() && !useMinimalTilesDuringLiveResize) {

Modified: trunk/Source/WebCore/testing/Internals.cpp (215180 => 215181)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-04-10 13:49:18 UTC (rev 215181)
@@ -800,6 +800,17 @@
         backing->setTileSizeUpdateDelayDisabledForTesting(true);
 }
 
+void Internals::setSpeculativeTilingDelayDisabledForTesting(bool disabled)
+{
+    Document* document = contextDocument();
+    if (!document || !document->frame())
+        return;
+
+    if (auto* frameView = document->frame()->view())
+        frameView->setSpeculativeTilingDelayDisabledForTesting(disabled);
+}
+
+
 Node* Internals::treeScopeRootNode(Node& node)
 {
     return &node.treeScope().rootNode();

Modified: trunk/Source/WebCore/testing/Internals.h (215180 => 215181)


--- trunk/Source/WebCore/testing/Internals.h	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/testing/Internals.h	2017-04-10 13:49:18 UTC (rev 215181)
@@ -128,6 +128,8 @@
 
     void disableTileSizeUpdateDelay();
 
+    void setSpeculativeTilingDelayDisabledForTesting(bool);
+
     Ref<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Element&) const;
 
     Node* ensureUserAgentShadowRoot(Element& host);

Modified: trunk/Source/WebCore/testing/Internals.idl (215180 => 215181)


--- trunk/Source/WebCore/testing/Internals.idl	2017-04-10 12:55:07 UTC (rev 215180)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-04-10 13:49:18 UTC (rev 215181)
@@ -524,6 +524,7 @@
     [CallWith=Document] void setAsRunningUserScripts();
 
     void disableTileSizeUpdateDelay();
+    void setSpeculativeTilingDelayDisabledForTesting(boolean disabled);
 
     [Conditional=WEBGL] void simulateWebGLContextChanged(WebGLRenderingContextBase context);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to