https://hackernoon.com/ uses lots of layer backing store
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2018 18:22:06 +0000 (18:22 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jun 2018 18:22:06 +0000 (18:22 +0000)
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.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/backing/backing-store-attachment-outside-viewport-expected.txt [new file with mode: 0644]
LayoutTests/compositing/backing/backing-store-attachment-outside-viewport.html [new file with mode: 0644]
LayoutTests/fast/images/animated-gif-iframe-webkit-transform.html
LayoutTests/fast/images/animated-gif-webkit-transform.html
LayoutTests/platform/ios/compositing/backing/backing-store-attachment-outside-viewport-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/Scavenger.cpp

index 8bc1792..42abfdb 100644 (file)
@@ -1,3 +1,16 @@
+2018-06-27  Simon Fraser  <simon.fraser@apple.com>
+
+        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  <n_wang@apple.com>
 
         AX: [iOS] Remove the ability to set keyboard focus when VoiceOver takes focus
diff --git a/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport-expected.txt b/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport-expected.txt
new file mode 100644 (file)
index 0000000..5000839
--- /dev/null
@@ -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
diff --git a/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport.html b/LayoutTests/compositing/backing/backing-store-attachment-outside-viewport.html
new file mode 100644 (file)
index 0000000..6191cea
--- /dev/null
@@ -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>
index a414c49..c0b8677 100644 (file)
@@ -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="resources/iframe-with-animated-gif.html" 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="resources/iframe-with-animated-gif2.html" 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="resources/iframe-with-animated-gif2.html" style="margin-left: 100px; width: 245px; height: 245px;" onload="frameLoaded()"></iframe>
         </div>
     </div>
 </div>
@@ -52,7 +52,7 @@ function translateImagesLeft()
   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);
 }
 
index 7493bde..a55a958 100644 (file)
@@ -4,13 +4,13 @@
 <script src="../../resources/js-test-pre.js"></script>
 </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="resources/animated.gif"/>
         </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="resources/animated-10color.gif"/>
+        <div id="wrapper2" style="-webkit-transform: translate3d(0px, 0px, 0px); width: 700px; height: 245px; float: left; margin: 0; padding: 0">
+            <img id="b" src="resources/animated-10color.gif" style="margin-left: 100px;"/>
         </div>
     </div>
 </div>
@@ -42,7 +42,7 @@ function translateImagesLeft() {
   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);
 }
 
diff --git a/LayoutTests/platform/ios/compositing/backing/backing-store-attachment-outside-viewport-expected.txt b/LayoutTests/platform/ios/compositing/backing/backing-store-attachment-outside-viewport-expected.txt
new file mode 100644 (file)
index 0000000..f533daf
--- /dev/null
@@ -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
index e76af5e..2cf35ee 100644 (file)
@@ -1,3 +1,43 @@
+2018-06-27  Simon Fraser  <simon.fraser@apple.com>
+
+        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  <ddkilzer@apple.com>
 
         Fix clang static analyzer warnings: Branch condition evaluates to a garbage value
index bf36de0..015c0d5 100644 (file)
@@ -390,6 +390,8 @@ bool BitmapImage::canDestroyDecodedData()
 
 BitmapImage::StartAnimationStatus BitmapImage::internalStartAnimation()
 {
+    LOG_WITH_STREAM(Images, stream << "BitmapImage " << this << " internalStartAnimation");
+
     if (!canAnimate())
         return StartAnimationStatus::CannotStart;
 
index 99e98ba..33fdd82 100644 (file)
@@ -787,7 +787,7 @@ void GraphicsLayer::dumpProperties(TextStream& ts, LayerTreeAsTextBehavior behav
         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 @@ void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
     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
index 67b6393..e640f47 100644 (file)
@@ -552,6 +552,7 @@ public:
     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; }
index b2fc8f6..c3aa277 100644 (file)
@@ -72,6 +72,7 @@ enum LayerTreeAsTextBehaviorFlags {
     LayerTreeAsTextIncludePageOverlayLayers     = 1 << 6,
     LayerTreeAsTextIncludeAcceleratesDrawing    = 1 << 7,
     LayerTreeAsTextIncludeBackingStoreAttached  = 1 << 8,
+    LayerTreeAsTextShowAll                      = 0xFFFF
 };
 typedef unsigned LayerTreeAsTextBehavior;
 
index 31bf2fc..5ce7ca3 100644 (file)
@@ -881,14 +881,16 @@ bool GraphicsLayerCA::backingStoreAttached() const
     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 @@ void GraphicsLayerCA::updateCoverage(const CommitState& commitState)
             || 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)
index ee41cd4..296da67 100644 (file)
@@ -264,6 +264,7 @@ private:
     bool isRunningTransformAnimation() const;
 
     WEBCORE_EXPORT bool backingStoreAttached() const override;
+    WEBCORE_EXPORT bool backingStoreAttachedForTesting() const override;
 
     bool animationIsRunning(const String& animationName) const
     {
index 744662b..d7074db 100644 (file)
@@ -180,6 +180,7 @@ public:
     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;
 
index e59cb0d..13446cd 100644 (file)
@@ -116,6 +116,7 @@ public:
     bool supportsSubpixelAntialiasedText() const override;
     void setSupportsSubpixelAntialiasedText(bool) override;
 
+    bool hasContents() const override;
     CFTypeRef contents() const override;
     void setContents(CFTypeRef) override;
 
index ca1c45f..e4eed9a 100644 (file)
@@ -391,6 +391,9 @@ void PlatformCALayerCocoa::animationEnded(const String& animationKey)
 
 void PlatformCALayerCocoa::setNeedsDisplay()
 {
+    if (!m_backingStoreAttached)
+        return;
+
     BEGIN_BLOCK_OBJC_EXCEPTIONS
     [m_layer setNeedsDisplay];
     END_BLOCK_OBJC_EXCEPTIONS
@@ -398,6 +401,9 @@ void PlatformCALayerCocoa::setNeedsDisplay()
 
 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 @@ void PlatformCALayerCocoa::setBackingStoreAttached(bool attached)
 {
     if (attached == m_backingStoreAttached)
         return;
+
     m_backingStoreAttached = attached;
 
     if (attached)
@@ -739,6 +746,11 @@ void PlatformCALayerCocoa::setSupportsSubpixelAntialiasedText(bool supportsSubpi
     updateContentsFormat();
 }
 
+bool PlatformCALayerCocoa::hasContents() const
+{
+    return [m_layer contents];
+}
+
 CFTypeRef PlatformCALayerCocoa::contents() const
 {
     return (__bridge CFTypeRef)[m_layer contents];
index 3b30044..774416b 100644 (file)
@@ -1,3 +1,22 @@
+2018-06-27  Simon Fraser  <simon.fraser@apple.com>
+
+        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  <jbedard@apple.com>
 
         Enable WebKit iOS 12 build
index 53968fc..d8c27a7 100644 (file)
@@ -190,7 +190,9 @@ void PlatformCALayerRemote::didCommit()
 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 @@ void PlatformCALayerRemote::updateBackingStore()
     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::setNeedsDisplayInRect(const FloatRect& rect)
 
 void PlatformCALayerRemote::setNeedsDisplay()
 {
+    if (!m_properties.backingStoreAttached)
+        return;
+
     ensureBackingStore();
 
     m_properties.backingStore->setNeedsDisplay();
@@ -536,13 +546,18 @@ void PlatformCALayerRemote::setUserInteractionEnabled(bool value)
     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 @@ void PlatformCALayerRemote::setSupportsSubpixelAntialiasedText(bool)
 {
 }
 
+bool PlatformCALayerRemote::hasContents() const
+{
+    return !!m_properties.backingStore;
+}
+
 CFTypeRef PlatformCALayerRemote::contents() const
 {
     return nullptr;
index 8f84ca3..39e97a4 100644 (file)
@@ -120,6 +120,7 @@ public:
     bool supportsSubpixelAntialiasedText() const override;
     void setSupportsSubpixelAntialiasedText(bool) override;
 
+    bool hasContents() const override;
     CFTypeRef contents() const override;
     void setContents(CFTypeRef) override;
 
index 89175b1..2038d48 100644 (file)
@@ -1,3 +1,16 @@
+2018-06-27  Simon Fraser  <simon.fraser@apple.com>
+
+        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  <sbarati@apple.com>
 
         Unreviewed followup. Fix the watchos build after r233192.
index de99c17..edb014d 100644 (file)
@@ -158,7 +158,7 @@ inline void dumpStats()
     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