Title: [233268] trunk
Revision
233268
Author
[email protected]
Date
2018-06-27 11:22:06 -0700 (Wed, 27 Jun 2018)

Log Message

https://hackernoon.com/ uses lots of layer backing store
https://bugs.webkit.org/show_bug.cgi?id=186909
rdar://problem/40257540

Reviewed by Tim Horton.

Source/bmalloc:

Drive-by typo fix.

* bmalloc/Scavenger.cpp:
(bmalloc::dumpStats):

Source/WebCore:

The existing "backing store detached" logic, which was used to eliminate backing store
for compositing layers outside the viewport, had a number of bugs that allowed layers
to have backing store when they should not.

Specifically, any code path that ended up in setNeedsDisplay{InRect}() in PlatformCALayer
could trigger backing store creation on layers that should have never had any.

Rather than monkeypatch all the GraphicsLayerCA call sites that call setNeedsDisplay{InRect}(),
just bail early from the PlatformCALayer* methods that trigger repaints.

Tests didn't catch this because they just dumped the state of the backingStoreAttached flag. To fix this,
create backingStoreAttachedForTesting() which also tests whether the layer has contents.

Test: compositing/backing/backing-store-attachment-outside-viewport.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::dumpProperties const):
(showGraphicsLayerTree):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::backingStoreAttachedForTesting const):
* platform/graphics/GraphicsLayerClient.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::backingStoreAttachedForTesting const):
(WebCore::GraphicsLayerCA::setNeedsDisplay):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayerCocoa::setNeedsDisplay):
(PlatformCALayerCocoa::setNeedsDisplayInRect):
(PlatformCALayerCocoa::hasContents const):

Source/WebKit:

PlatformCALayerRemote was actually holding onto backing stores for layers with
backing store detached, which could increase memory use. When told that backing stores
are not attached, explicitly throw away the backing, and re-create it (via setNeedsDisplay)
when attached. This is now similar to what PlatformLayerCACocoa does.

* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::setNeedsDisplayInRect):
(WebKit::PlatformCALayerRemote::setNeedsDisplay):
(WebKit::PlatformCALayerRemote::hasContents const):
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:

LayoutTests:

New test.

* compositing/backing/backing-store-attachment-outside-viewport-expected.txt: Added.
* compositing/backing/backing-store-attachment-outside-viewport.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233267 => 233268)


--- trunk/LayoutTests/ChangeLog	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/LayoutTests/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
@@ -1,3 +1,16 @@
+2018-06-27  Simon Fraser  <[email protected]>
+
+        https://hackernoon.com/ uses lots of layer backing store
+        https://bugs.webkit.org/show_bug.cgi?id=186909
+        rdar://problem/40257540
+
+        Reviewed by Tim Horton.
+        
+        New test.
+
+        * compositing/backing/backing-store-attachment-outside-viewport-expected.txt: Added.
+        * compositing/backing/backing-store-attachment-outside-viewport.html: Added.
+
 2018-06-27  Nan Wang  <[email protected]>
 
         AX: [iOS] Remove the ability to set keyboard focus when VoiceOver takes focus

Added: trunk/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport-expected.txt (0 => 233268)


--- trunk/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport-expected.txt	2018-06-27 18:22:06 UTC (rev 233268)
@@ -0,0 +1,35 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 785.00 3821.00)
+  (backingStoreAttached 1)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 3821.00)
+      (contentsOpaque 1)
+      (backingStoreAttached 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 13.00)
+          (bounds 600.00 600.00)
+          (drawsContent 1)
+          (backingStoreAttached 1)
+        )
+        (GraphicsLayer
+          (position 8.00 1613.00)
+          (bounds 600.00 600.00)
+          (drawsContent 1)
+          (backingStoreAttached 0)
+        )
+        (GraphicsLayer
+          (position 8.00 3213.00)
+          (bounds 600.00 600.00)
+          (drawsContent 1)
+          (backingStoreAttached 0)
+        )
+      )
+    )
+  )
+)
+I'm attached.
+I'm detached.
+I'm detached. Triggers repaint

Added: trunk/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport.html (0 => 233268)


--- trunk/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport.html	2018-06-27 18:22:06 UTC (rev 233268)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.layerized {
+    transform: translateZ(0);
+    width: 600px;
+    height: 600px;
+}
+.vspace {
+    height: 1000px;
+}
+</style>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+window._onload_ = function() {
+    if (!window.testRunner)
+        return;
+
+    document.getElementById('repainting').style.color = 'blue';
+    setTimeout(function() {
+        var out = document.getElementById('out');
+        out.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED);
+        testRunner.notifyDone();
+    }, 0);
+};
+</script>
+</head>
+<body>
+<pre id="out"></pre>
+<div class="layerized">I'm attached.</div>
+<div class="vspace"></div>
+<div class="layerized">I'm detached.</div>
+<div class="vspace"></div>
+<div class="layerized">I'm detached. <span id="repainting">Triggers repaint</span></div>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/images/animated-gif-iframe-webkit-transform.html (233267 => 233268)


--- trunk/LayoutTests/fast/images/animated-gif-iframe-webkit-transform.html	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/LayoutTests/fast/images/animated-gif-iframe-webkit-transform.html	2018-06-27 18:22:06 UTC (rev 233268)
@@ -6,12 +6,12 @@
 <body>
 <p id="description"></p>
 <div id="scroller" style="width: 800px; overflow: hidden">
-    <div id="scroller-cont" style="height: 245px; width: 1600px; position: relative; top: 0; left: 0; -webkit-transform: translate(0px, 0px) translateZ(0px);">
-        <div id="wrapper1" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 800px; height: 245px; float: left; margin: 0; padding: 0">
+    <div id="scroller-cont" style="height: 245px; width: 1410px; position: relative; top: 0; left: 0; -webkit-transform: translate(0px, 0px) translateZ(0px);">
+        <div id="wrapper1" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 710px; height: 245px; float: left; margin: 0; padding: 0">
             <iframe id="testFrame1" src="" style="width: 245px; height: 245px;" _onload_="frameLoaded()"></iframe>
         </div>
-        <div id="wrapper2" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 800px; height: 245px; float: left; margin: 0; padding: 0">
-            <iframe id="testFrame2" src="" style="width: 245px; height: 245px;" _onload_="frameLoaded()"></iframe>
+        <div id="wrapper2" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 700px; height: 245px; float: left; margin: 0; padding: 0">
+            <iframe id="testFrame2" src="" style="margin-left: 100px; width: 245px; height: 245px;" _onload_="frameLoaded()"></iframe>
         </div>
     </div>
 </div>
@@ -52,7 +52,7 @@
   shouldBeFalse("isFirstImagePaused()");
   debug("Translating images left so that first image is no longer visible, but second image is.");
   forceLayout();
-  document.getElementById("scroller-cont").style["-webkit-transform"] = "translate(-800px, 0px)";
+  document.getElementById("scroller-cont").style["-webkit-transform"] = "translate(-610px, 0px)";
   shouldBecomeEqual("isFirstImagePaused()", "true", checkSecondImageUnpaused);
 }
 

Modified: trunk/LayoutTests/fast/images/animated-gif-webkit-transform.html (233267 => 233268)


--- trunk/LayoutTests/fast/images/animated-gif-webkit-transform.html	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/LayoutTests/fast/images/animated-gif-webkit-transform.html	2018-06-27 18:22:06 UTC (rev 233268)
@@ -4,13 +4,13 @@
 <script src=""
 </head>
 <body _onload_="runTest()">
-<div id="scroller" style="width: 800px; overflow: hidden">
-    <div id="scroller-cont" style="height: 245px; width: 1600px; position: relative; top: 0; left: 0; -webkit-transform: translate(0px, 0px) translateZ(0px);">
-        <div id="wrapper1" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 800px; height: 245px; float: left; margin: 0; padding: 0">
+<div id="scroller" style="width: 800px; overflow: scroll">
+    <div id="scroller-cont" style="height: 245px; width: 1410px; position: relative; top: 0; left: 0; -webkit-transform: translate(0px, 0px) translateZ(0px);">
+        <div id="wrapper1" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 710px; height: 245px; float: left; margin: 0; padding: 0">
             <img id="a" src=""
         </div>
-        <div id="wrapper2" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 800px; height: 245px; float: left; margin: 0; padding: 0">
-            <img id="b" src=""
+        <div id="wrapper2" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 700px; height: 245px; float: left; margin: 0; padding: 0">
+            <img id="b" src="" style="margin-left: 100px;"/>
         </div>
     </div>
 </div>
@@ -42,7 +42,7 @@
   shouldBeFalse("isFirstImagePaused()");
   debug("Translating images left so that first image is no longer visible, but second image is.");
   forceLayout();
-  document.getElementById("scroller-cont").style["-webkit-transform"] = "translate(-800px, 0px)";
+  document.getElementById("scroller-cont").style["-webkit-transform"] = "translate(-610px, 0px)";
   shouldBecomeEqual("isFirstImagePaused()", "true", checkSecondImageUnpaused);
 }
 

Added: trunk/LayoutTests/platform/ios/compositing/backing/backing-store-attachment-outside-viewport-expected.txt (0 => 233268)


--- trunk/LayoutTests/platform/ios/compositing/backing/backing-store-attachment-outside-viewport-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios/compositing/backing/backing-store-attachment-outside-viewport-expected.txt	2018-06-27 18:22:06 UTC (rev 233268)
@@ -0,0 +1,35 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 3821.00)
+  (backingStoreAttached 1)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 3821.00)
+      (contentsOpaque 1)
+      (backingStoreAttached 1)
+      (children 3
+        (GraphicsLayer
+          (position 8.00 13.00)
+          (bounds 600.00 600.00)
+          (drawsContent 1)
+          (backingStoreAttached 1)
+        )
+        (GraphicsLayer
+          (position 8.00 1613.00)
+          (bounds 600.00 600.00)
+          (drawsContent 1)
+          (backingStoreAttached 0)
+        )
+        (GraphicsLayer
+          (position 8.00 3213.00)
+          (bounds 600.00 600.00)
+          (drawsContent 1)
+          (backingStoreAttached 0)
+        )
+      )
+    )
+  )
+)
+I'm attached.
+I'm detached.
+I'm detached. Triggers repaint

Modified: trunk/Source/WebCore/ChangeLog (233267 => 233268)


--- trunk/Source/WebCore/ChangeLog	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
@@ -1,3 +1,43 @@
+2018-06-27  Simon Fraser  <[email protected]>
+
+        https://hackernoon.com/ uses lots of layer backing store
+        https://bugs.webkit.org/show_bug.cgi?id=186909
+        rdar://problem/40257540
+
+        Reviewed by Tim Horton.
+        
+        The existing "backing store detached" logic, which was used to eliminate backing store
+        for compositing layers outside the viewport, had a number of bugs that allowed layers
+        to have backing store when they should not.
+        
+        Specifically, any code path that ended up in setNeedsDisplay{InRect}() in PlatformCALayer
+        could trigger backing store creation on layers that should have never had any.
+        
+        Rather than monkeypatch all the GraphicsLayerCA call sites that call setNeedsDisplay{InRect}(),
+        just bail early from the PlatformCALayer* methods that trigger repaints.
+        
+        Tests didn't catch this because they just dumped the state of the backingStoreAttached flag. To fix this,
+        create backingStoreAttachedForTesting() which also tests whether the layer has contents.
+
+        Test: compositing/backing/backing-store-attachment-outside-viewport.html
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::dumpProperties const):
+        (showGraphicsLayerTree):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::backingStoreAttachedForTesting const):
+        * platform/graphics/GraphicsLayerClient.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::backingStoreAttachedForTesting const):
+        (WebCore::GraphicsLayerCA::setNeedsDisplay):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+        (PlatformCALayerCocoa::setNeedsDisplay):
+        (PlatformCALayerCocoa::setNeedsDisplayInRect):
+        (PlatformCALayerCocoa::hasContents const):
+
 2018-06-27  David Kilzer  <[email protected]>
 
         Fix clang static analyzer warnings: Branch condition evaluates to a garbage value

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2018-06-27 18:22:06 UTC (rev 233268)
@@ -390,6 +390,8 @@
 
 BitmapImage::StartAnimationStatus BitmapImage::internalStartAnimation()
 {
+    LOG_WITH_STREAM(Images, stream << "BitmapImage " << this << " internalStartAnimation");
+
     if (!canAnimate())
         return StartAnimationStatus::CannotStart;
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2018-06-27 18:22:06 UTC (rev 233268)
@@ -787,7 +787,7 @@
         ts << indent << "(acceleratesDrawing " << m_acceleratesDrawing << ")\n";
 
     if (behavior & LayerTreeAsTextIncludeBackingStoreAttached)
-        ts << indent << "(backingStoreAttached " << backingStoreAttached() << ")\n";
+        ts << indent << "(backingStoreAttached " << backingStoreAttachedForTesting() << ")\n";
 
     if (!m_transform.isIdentity()) {
         ts << indent << "(transform ";
@@ -931,7 +931,7 @@
     if (!layer)
         return;
 
-    String output = layer->layerTreeAsText(WebCore::LayerTreeAsTextDebug | WebCore::LayerTreeAsTextIncludeVisibleRects | WebCore::LayerTreeAsTextIncludeTileCaches | WebCore::LayerTreeAsTextIncludeContentLayers);
+    String output = layer->layerTreeAsText(WebCore::LayerTreeAsTextShowAll);
     fprintf(stderr, "%s\n", output.utf8().data());
 }
 #endif

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2018-06-27 18:22:06 UTC (rev 233268)
@@ -552,6 +552,7 @@
     WEBCORE_EXPORT virtual double backingStoreMemoryEstimate() const;
 
     virtual bool backingStoreAttached() const { return true; }
+    virtual bool backingStoreAttachedForTesting() const { return backingStoreAttached(); }
 
     void setCanDetachBackingStore(bool b) { m_canDetachBackingStore = b; }
     bool canDetachBackingStore() const { return m_canDetachBackingStore; }

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2018-06-27 18:22:06 UTC (rev 233268)
@@ -72,6 +72,7 @@
     LayerTreeAsTextIncludePageOverlayLayers     = 1 << 6,
     LayerTreeAsTextIncludeAcceleratesDrawing    = 1 << 7,
     LayerTreeAsTextIncludeBackingStoreAttached  = 1 << 8,
+    LayerTreeAsTextShowAll                      = 0xFFFF
 };
 typedef unsigned LayerTreeAsTextBehavior;
 

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2018-06-27 18:22:06 UTC (rev 233268)
@@ -881,14 +881,16 @@
     return m_layer->backingStoreAttached();
 }
 
+bool GraphicsLayerCA::backingStoreAttachedForTesting() const
+{
+    return m_layer->backingStoreAttached() || m_layer->hasContents();
+}
+
 void GraphicsLayerCA::setNeedsDisplay()
 {
     if (!drawsContent())
         return;
 
-    if (!backingStoreAttached())
-        return;
-
     m_needsFullRepaint = true;
     m_dirtyRects.clear();
     noteLayerPropertyChanged(DirtyRectsChanged);
@@ -2349,6 +2351,8 @@
             || commitState.ancestorWithTransformAnimationIntersectsCoverageRect // FIXME: Compute backing exactly for descendants of animating layers.
             || (isRunningTransformAnimation() && !animationExtent()); // Create backing if we don't know the animation extent.
 
+        LOG_WITH_STREAM(Compositing, stream << "GraphicsLayerCA " << this << " id " << primaryLayerID() << " setBackingStoreAttached: " << requiresBacking);
+
         m_layer->setBackingStoreAttached(requiresBacking);
         if (m_layerClones) {
             for (auto& it : *m_layerClones)

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2018-06-27 18:22:06 UTC (rev 233268)
@@ -264,6 +264,7 @@
     bool isRunningTransformAnimation() const;
 
     WEBCORE_EXPORT bool backingStoreAttached() const override;
+    WEBCORE_EXPORT bool backingStoreAttachedForTesting() const override;
 
     bool animationIsRunning(const String& animationName) const
     {

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h	2018-06-27 18:22:06 UTC (rev 233268)
@@ -180,6 +180,7 @@
     virtual bool supportsSubpixelAntialiasedText() const = 0;
     virtual void setSupportsSubpixelAntialiasedText(bool) = 0;
 
+    virtual bool hasContents() const = 0;
     virtual CFTypeRef contents() const = 0;
     virtual void setContents(CFTypeRef) = 0;
 

Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h	2018-06-27 18:22:06 UTC (rev 233268)
@@ -116,6 +116,7 @@
     bool supportsSubpixelAntialiasedText() const override;
     void setSupportsSubpixelAntialiasedText(bool) override;
 
+    bool hasContents() const override;
     CFTypeRef contents() const override;
     void setContents(CFTypeRef) override;
 

Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (233267 => 233268)


--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2018-06-27 18:22:06 UTC (rev 233268)
@@ -391,6 +391,9 @@
 
 void PlatformCALayerCocoa::setNeedsDisplay()
 {
+    if (!m_backingStoreAttached)
+        return;
+
     BEGIN_BLOCK_OBJC_EXCEPTIONS
     [m_layer setNeedsDisplay];
     END_BLOCK_OBJC_EXCEPTIONS
@@ -398,6 +401,9 @@
 
 void PlatformCALayerCocoa::setNeedsDisplayInRect(const FloatRect& dirtyRect)
 {
+    if (!m_backingStoreAttached)
+        return;
+
     BEGIN_BLOCK_OBJC_EXCEPTIONS
     [m_layer setNeedsDisplayInRect:dirtyRect];
     END_BLOCK_OBJC_EXCEPTIONS
@@ -638,6 +644,7 @@
 {
     if (attached == m_backingStoreAttached)
         return;
+
     m_backingStoreAttached = attached;
 
     if (attached)
@@ -739,6 +746,11 @@
     updateContentsFormat();
 }
 
+bool PlatformCALayerCocoa::hasContents() const
+{
+    return [m_layer contents];
+}
+
 CFTypeRef PlatformCALayerCocoa::contents() const
 {
     return (__bridge CFTypeRef)[m_layer contents];

Modified: trunk/Source/WebKit/ChangeLog (233267 => 233268)


--- trunk/Source/WebKit/ChangeLog	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebKit/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
@@ -1,3 +1,22 @@
+2018-06-27  Simon Fraser  <[email protected]>
+
+        https://hackernoon.com/ uses lots of layer backing store
+        https://bugs.webkit.org/show_bug.cgi?id=186909
+        rdar://problem/40257540
+
+        Reviewed by Tim Horton.
+        
+        PlatformCALayerRemote was actually holding onto backing stores for layers with
+        backing store detached, which could increase memory use. When told that backing stores
+        are not attached, explicitly throw away the backing, and re-create it (via setNeedsDisplay)
+        when attached. This is now similar to what PlatformLayerCACocoa does.
+
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::setNeedsDisplayInRect):
+        (WebKit::PlatformCALayerRemote::setNeedsDisplay):
+        (WebKit::PlatformCALayerRemote::hasContents const):
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
+
 2018-06-27  Jonathan Bedard  <[email protected]>
 
         Enable WebKit iOS 12 build

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp (233267 => 233268)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2018-06-27 18:22:06 UTC (rev 233268)
@@ -190,7 +190,9 @@
 void PlatformCALayerRemote::ensureBackingStore()
 {
     ASSERT(owner());
-    
+
+    ASSERT(m_properties.backingStoreAttached);
+
     if (!m_properties.backingStore)
         m_properties.backingStore = std::make_unique<RemoteLayerBackingStore>(this);
 
@@ -202,11 +204,16 @@
     if (!m_properties.backingStore)
         return;
 
+    ASSERT(m_properties.backingStoreAttached);
+
     m_properties.backingStore->ensureBackingStore(m_properties.bounds.size(), m_properties.contentsScale, m_acceleratesDrawing, m_wantsDeepColorBackingStore, m_properties.opaque);
 }
 
 void PlatformCALayerRemote::setNeedsDisplayInRect(const FloatRect& rect)
 {
+    if (!m_properties.backingStoreAttached)
+        return;
+
     ensureBackingStore();
 
     // FIXME: Need to map this through contentsRect/etc.
@@ -215,6 +222,9 @@
 
 void PlatformCALayerRemote::setNeedsDisplay()
 {
+    if (!m_properties.backingStoreAttached)
+        return;
+
     ensureBackingStore();
 
     m_properties.backingStore->setNeedsDisplay();
@@ -536,13 +546,18 @@
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::UserInteractionEnabledChanged);
 }
 
-void PlatformCALayerRemote::setBackingStoreAttached(bool value)
+void PlatformCALayerRemote::setBackingStoreAttached(bool attached)
 {
-    if (m_properties.backingStoreAttached == value)
+    if (m_properties.backingStoreAttached == attached)
         return;
 
-    m_properties.backingStoreAttached = value;
+    m_properties.backingStoreAttached = attached;
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::BackingStoreAttachmentChanged);
+    
+    if (attached)
+        setNeedsDisplay();
+    else
+        m_properties.backingStore = nullptr;
 }
 
 bool PlatformCALayerRemote::backingStoreAttached() const
@@ -617,6 +632,11 @@
 {
 }
 
+bool PlatformCALayerRemote::hasContents() const
+{
+    return !!m_properties.backingStore;
+}
+
 CFTypeRef PlatformCALayerRemote::contents() const
 {
     return nullptr;

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h (233267 => 233268)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h	2018-06-27 18:22:06 UTC (rev 233268)
@@ -120,6 +120,7 @@
     bool supportsSubpixelAntialiasedText() const override;
     void setSupportsSubpixelAntialiasedText(bool) override;
 
+    bool hasContents() const override;
     CFTypeRef contents() const override;
     void setContents(CFTypeRef) override;
 

Modified: trunk/Source/bmalloc/ChangeLog (233267 => 233268)


--- trunk/Source/bmalloc/ChangeLog	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/bmalloc/ChangeLog	2018-06-27 18:22:06 UTC (rev 233268)
@@ -1,3 +1,16 @@
+2018-06-27  Simon Fraser  <[email protected]>
+
+        https://hackernoon.com/ uses lots of layer backing store
+        https://bugs.webkit.org/show_bug.cgi?id=186909
+        rdar://problem/40257540
+
+        Reviewed by Tim Horton.
+        
+        Drive-by typo fix.
+
+        * bmalloc/Scavenger.cpp:
+        (bmalloc::dumpStats):
+
 2018-06-26  Saam Barati  <[email protected]>
 
         Unreviewed followup. Fix the watchos build after r233192.

Modified: trunk/Source/bmalloc/bmalloc/Scavenger.cpp (233267 => 233268)


--- trunk/Source/bmalloc/bmalloc/Scavenger.cpp	2018-06-27 18:07:00 UTC (rev 233267)
+++ trunk/Source/bmalloc/bmalloc/Scavenger.cpp	2018-06-27 18:22:06 UTC (rev 233268)
@@ -158,7 +158,7 @@
     task_vm_info_data_t vmInfo;
     mach_msg_type_number_t vmSize = TASK_VM_INFO_COUNT;
     if (KERN_SUCCESS == task_info(mach_task_self(), TASK_VM_INFO, (task_info_t)(&vmInfo), &vmSize)) {
-        dump("phys_footrpint", vmInfo.phys_footprint);
+        dump("phys_footprint", vmInfo.phys_footprint);
         dump("internal+compressed", vmInfo.internal + vmInfo.compressed);
     }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to