Title: [277792] trunk/Source
Revision
277792
Author
gga...@apple.com
Date
2021-05-20 10:08:30 -0700 (Thu, 20 May 2021)

Log Message

GraphicsLayer::setName() causes heap fragmentation
https://bugs.webkit.org/show_bug.cgi?id=225838

Reviewed by Simon Fraser.

Profiling for heap fragmentation shows that GraphicsLayer::setName() is
a top contributor. Worth about 5MB maximum on GMail.

Use MAKE_STATIC_STRING_IMPL for our constant layer names so we end up
with only one copy and no heap allocation in the many cases that are
compile-time constants.

Source/WebCore:

* display/compositing/DisplayLayerController.cpp:
(WebCore::Display::LayerController::setupRootLayerHierarchy):
* page/PageOverlayController.cpp:
(WebCore::PageOverlayController::createRootLayersIfNeeded):
(WebCore::PageOverlayController::installPageOverlay):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setContentsToSolidColor):
(WebCore::GraphicsLayerCA::setContentsToModel):
(WebCore::GraphicsLayerCA::updateBackdropFilters):
(WebCore::GraphicsLayerCA::updateContentsImage):
(WebCore::GraphicsLayerCA::updateClippingStrategy):
(WebCore::GraphicsLayerCA::updateContentsRects):
* platform/graphics/ca/TileCoverageMap.cpp:
(WebCore::TileCoverageMap::TileCoverageMap):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::initialize):
(WebCore::CACFLayerTreeHost::updateDebugInfoLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
(WebCore::RenderLayerCompositor::updateLayerForHeader):
(WebCore::RenderLayerCompositor::updateLayerForFooter):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
(WebCore::RenderLayerCompositor::ensureRootLayer):

Source/WebKit:

* WebProcess/Inspector/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::showPaintRect):
* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
(WebKit::CompositingCoordinator::CompositingCoordinator):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::LayerTreeHost):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp:
(WebKit::LayerTreeHost::LayerTreeHost):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (277791 => 277792)


--- trunk/Source/WebCore/ChangeLog	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/ChangeLog	2021-05-20 17:08:30 UTC (rev 277792)
@@ -1,3 +1,44 @@
+2021-05-20  Geoffrey Garen  <gga...@apple.com>
+
+        GraphicsLayer::setName() causes heap fragmentation
+        https://bugs.webkit.org/show_bug.cgi?id=225838
+
+        Reviewed by Simon Fraser.
+
+        Profiling for heap fragmentation shows that GraphicsLayer::setName() is
+        a top contributor. Worth about 5MB maximum on GMail.
+
+        Use MAKE_STATIC_STRING_IMPL for our constant layer names so we end up
+        with only one copy and no heap allocation in the many cases that are
+        compile-time constants.
+
+        * display/compositing/DisplayLayerController.cpp:
+        (WebCore::Display::LayerController::setupRootLayerHierarchy):
+        * page/PageOverlayController.cpp:
+        (WebCore::PageOverlayController::createRootLayersIfNeeded):
+        (WebCore::PageOverlayController::installPageOverlay):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setContentsToSolidColor):
+        (WebCore::GraphicsLayerCA::setContentsToModel):
+        (WebCore::GraphicsLayerCA::updateBackdropFilters):
+        (WebCore::GraphicsLayerCA::updateContentsImage):
+        (WebCore::GraphicsLayerCA::updateClippingStrategy):
+        (WebCore::GraphicsLayerCA::updateContentsRects):
+        * platform/graphics/ca/TileCoverageMap.cpp:
+        (WebCore::TileCoverageMap::TileCoverageMap):
+        * platform/graphics/ca/win/CACFLayerTreeHost.cpp:
+        (WebCore::CACFLayerTreeHost::initialize):
+        (WebCore::CACFLayerTreeHost::updateDebugInfoLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea):
+        (WebCore::RenderLayerCompositor::updateLayerForBottomOverhangArea):
+        (WebCore::RenderLayerCompositor::updateLayerForHeader):
+        (WebCore::RenderLayerCompositor::updateLayerForFooter):
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+        (WebCore::RenderLayerCompositor::ensureRootLayer):
+
 2021-05-20  Devin Rousso  <drou...@apple.com>
 
         [Modern Media Controls] should not include `TextTrack` when sorting `TextTrackList` if it doesn't have a desired `TextTrack::Kind` when `CaptionDisplayMode::Manual`

Modified: trunk/Source/WebCore/display/compositing/DisplayLayerController.cpp (277791 => 277792)


--- trunk/Source/WebCore/display/compositing/DisplayLayerController.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/display/compositing/DisplayLayerController.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -151,16 +151,16 @@
 {
     // FIXME: This layer hierarchy is just enough to get topContentInset working.
     m_rootLayer = GraphicsLayer::create(graphicsLayerFactory(), m_rootLayerClient);
-    m_rootLayer->setName("display root");
+    m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("display root"));
     m_rootLayer->setPosition({ });
     m_rootLayer->setAnchorPoint({ });
 
     m_contentHostLayer = GraphicsLayer::create(graphicsLayerFactory(), m_rootLayerClient);
-    m_contentHostLayer->setName("content host");
+    m_contentHostLayer->setName(MAKE_STATIC_STRING_IMPL("content host"));
     m_contentHostLayer->setAnchorPoint({ });
 
     m_contentLayer = GraphicsLayer::create(graphicsLayerFactory(), m_rootLayerClient);
-    m_contentLayer->setName("content");
+    m_contentLayer->setName(MAKE_STATIC_STRING_IMPL("content"));
     m_contentLayer->setPosition({ });
     m_contentLayer->setAnchorPoint({ });
     m_contentLayer->setDrawsContent(true);

Modified: trunk/Source/WebCore/page/PageOverlayController.cpp (277791 => 277792)


--- trunk/Source/WebCore/page/PageOverlayController.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/page/PageOverlayController.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -61,8 +61,8 @@
 
     m_documentOverlayRootLayer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
     m_viewOverlayRootLayer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
-    m_documentOverlayRootLayer->setName("Document overlay Container");
-    m_viewOverlayRootLayer->setName("View overlay container");
+    m_documentOverlayRootLayer->setName(MAKE_STATIC_STRING_IMPL("Document overlay Container"));
+    m_viewOverlayRootLayer->setName(MAKE_STATIC_STRING_IMPL("View overlay container"));
 }
 
 void PageOverlayController::installedPageOverlaysChanged()
@@ -188,7 +188,7 @@
     auto layer = GraphicsLayer::create(m_page.chrome().client().graphicsLayerFactory(), *this);
     layer->setAnchorPoint({ });
     layer->setBackgroundColor(overlay.backgroundColor());
-    layer->setName("Overlay content");
+    layer->setName(MAKE_STATIC_STRING_IMPL("Overlay content"));
 
     updateSettingsForLayer(layer.get());
 

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


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -1200,7 +1200,7 @@
 #if ENABLE(TREE_DEBUGGING)
             m_contentsLayer->setName(makeString("contents color ", m_contentsLayer->layerID()));
 #else
-            m_contentsLayer->setName("contents color");
+            m_contentsLayer->setName(MAKE_STATIC_STRING_IMPL("contents color"));
 #endif
             contentsLayerChanged = true;
         }
@@ -1259,7 +1259,7 @@
 #if ENABLE(TREE_DEBUGGING)
         m_contentsLayer->setName(makeString("contents model ", m_contentsLayer->layerID()));
 #else
-        m_contentsLayer->setName("contents model");
+        m_contentsLayer->setName(MAKE_STATIC_STRING_IMPL("contents model"));
 #endif
 
         m_contentsLayerPurpose = ContentsLayerPurpose::Model;
@@ -2351,7 +2351,7 @@
         m_backdropLayer = createPlatformCALayer(PlatformCALayer::LayerTypeBackdropLayer, this);
         m_backdropLayer->setAnchorPoint(FloatPoint3D());
         m_backdropLayer->setMasksToBounds(true);
-        m_backdropLayer->setName("backdrop");
+        m_backdropLayer->setName(MAKE_STATIC_STRING_IMPL("backdrop"));
     }
 
     m_backdropLayer->setHidden(!m_contentsVisible);
@@ -2677,7 +2677,7 @@
 #if ENABLE(TREE_DEBUGGING)
             m_contentsLayer->setName(makeString("contents image ", m_contentsLayer->layerID()));
 #else
-            m_contentsLayer->setName("contents image");
+            m_contentsLayer->setName(MAKE_STATIC_STRING_IMPL("contents image"));
 #endif
             setupContentsLayer(m_contentsLayer.get());
             // m_contentsLayer will be parented by updateSublayerList
@@ -2752,7 +2752,7 @@
     if (!shapeMaskLayer) {
         shapeMaskLayer = createPlatformCALayer(PlatformCALayer::LayerTypeShapeLayer, this);
         shapeMaskLayer->setAnchorPoint({ });
-        shapeMaskLayer->setName("shape mask");
+        shapeMaskLayer->setName(MAKE_STATIC_STRING_IMPL("shape mask"));
     }
 
     // clippingLayer's boundsOrigin is roundedRect.rect().location(), and is non-zero to positioning descendant layers.
@@ -2786,7 +2786,7 @@
 #if ENABLE(TREE_DEBUGGING)
             m_contentsClippingLayer->setName(makeString("contents clipping ", m_contentsClippingLayer->layerID()));
 #else
-            m_contentsClippingLayer->setName("contents clipping");
+            m_contentsClippingLayer->setName(MAKE_STATIC_STRING_IMPL("contents clipping"));
 #endif
             gainedOrLostClippingLayer = true;
         }

Modified: trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp (277791 => 277792)


--- trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -48,17 +48,17 @@
     m_layer.get().setPosition(FloatPoint(2, 2));
     m_layer.get().setContentsScale(m_controller.deviceScaleFactor());
 
-    m_visibleViewportIndicatorLayer.get().setName("visible viewport indicator");
+    m_visibleViewportIndicatorLayer.get().setName(MAKE_STATIC_STRING_IMPL("visible viewport indicator"));
     m_visibleViewportIndicatorLayer.get().setBorderWidth(2);
     m_visibleViewportIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
     m_visibleViewportIndicatorLayer.get().setBorderColor(Color::red.colorWithAlphaByte(200));
 
-    m_layoutViewportIndicatorLayer.get().setName("layout viewport indicator");
+    m_layoutViewportIndicatorLayer.get().setName(MAKE_STATIC_STRING_IMPL("layout viewport indicator"));
     m_layoutViewportIndicatorLayer.get().setBorderWidth(2);
     m_layoutViewportIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
     m_layoutViewportIndicatorLayer.get().setBorderColor(SRGBA<uint8_t> { 0, 128, 128, 200 });
     
-    m_coverageRectIndicatorLayer.get().setName("coverage indicator");
+    m_coverageRectIndicatorLayer.get().setName(MAKE_STATIC_STRING_IMPL("coverage indicator"));
     m_coverageRectIndicatorLayer.get().setAnchorPoint(FloatPoint3D());
     m_coverageRectIndicatorLayer.get().setBackgroundColor(SRGBA<uint8_t> { 64, 64, 64, 50 });
 

Modified: trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp (277791 => 277792)


--- trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -154,7 +154,7 @@
     // cause any repositioning.
     // Scrolling will affect only the position of the scroll layer without affecting the bounds.
 
-    m_rootLayer->setName("CACFLayerTreeHost rootLayer");
+    m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("CACFLayerTreeHost rootLayer"));
     m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
     m_rootLayer->setGeometryFlipped(true);
 
@@ -371,7 +371,7 @@
 
         if (m_debugInfoLayer) {
 #ifndef NDEBUG
-            m_debugInfoLayer->setName("Debug Info");
+            m_debugInfoLayer->setName(MAKE_STATIC_STRING_IMPL("Debug Info"));
 #endif
             m_rootLayer->appendSublayer(*m_debugInfoLayer);
         }

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (277791 => 277792)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -959,7 +959,7 @@
                             m_backdropLayer = adoptRef(*new CoordinatedGraphicsLayer(Type::Normal, client()));
                             m_backdropLayer->setAnchorPoint(FloatPoint3D());
                             m_backdropLayer->setMasksToBounds(true);
-                            m_backdropLayer->setName("backdrop");
+                            m_backdropLayer->setName(MAKE_STATIC_STRING_IMPL("backdrop"));
                             if (m_coordinator)
                                 m_coordinator->attachLayer(m_backdropLayer.get());
                         }

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (277791 => 277792)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -3771,7 +3771,7 @@
 
     if (!m_layerForTopOverhangArea) {
         m_layerForTopOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
-        m_layerForTopOverhangArea->setName("top overhang");
+        m_layerForTopOverhangArea->setName(MAKE_STATIC_STRING_IMPL("top overhang"));
         m_scrolledContentsLayer->addChildBelow(*m_layerForTopOverhangArea, m_rootContentsLayer.get());
     }
 
@@ -3790,7 +3790,7 @@
 
     if (!m_layerForBottomOverhangArea) {
         m_layerForBottomOverhangArea = GraphicsLayer::create(graphicsLayerFactory(), *this);
-        m_layerForBottomOverhangArea->setName("bottom overhang");
+        m_layerForBottomOverhangArea->setName(MAKE_STATIC_STRING_IMPL("bottom overhang"));
         m_scrolledContentsLayer->addChildBelow(*m_layerForBottomOverhangArea, m_rootContentsLayer.get());
     }
 
@@ -3818,7 +3818,7 @@
 
     if (!m_layerForHeader) {
         m_layerForHeader = GraphicsLayer::create(graphicsLayerFactory(), *this);
-        m_layerForHeader->setName("header");
+        m_layerForHeader->setName(MAKE_STATIC_STRING_IMPL("header"));
         m_scrolledContentsLayer->addChildAbove(*m_layerForHeader, m_rootContentsLayer.get());
         m_renderView.frameView().addPaintPendingMilestones(DidFirstFlushForHeaderLayer);
     }
@@ -3855,7 +3855,7 @@
 
     if (!m_layerForFooter) {
         m_layerForFooter = GraphicsLayer::create(graphicsLayerFactory(), *this);
-        m_layerForFooter->setName("footer");
+        m_layerForFooter->setName(MAKE_STATIC_STRING_IMPL("footer"));
         m_scrolledContentsLayer->addChildAbove(*m_layerForFooter, m_rootContentsLayer.get());
     }
 
@@ -3983,7 +3983,7 @@
     if (requiresOverhangAreasLayer()) {
         if (!m_layerForOverhangAreas) {
             m_layerForOverhangAreas = GraphicsLayer::create(graphicsLayerFactory(), *this);
-            m_layerForOverhangAreas->setName("overhang areas");
+            m_layerForOverhangAreas->setName(MAKE_STATIC_STRING_IMPL("overhang areas"));
             m_layerForOverhangAreas->setDrawsContent(false);
 
             float topContentInset = m_renderView.frameView().topContentInset();
@@ -4004,7 +4004,7 @@
     if (requiresContentShadowLayer()) {
         if (!m_contentShadowLayer) {
             m_contentShadowLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
-            m_contentShadowLayer->setName("content shadow");
+            m_contentShadowLayer->setName(MAKE_STATIC_STRING_IMPL("content shadow"));
             m_contentShadowLayer->setSize(m_rootContentsLayer->size());
             m_contentShadowLayer->setPosition(m_rootContentsLayer->position());
             m_contentShadowLayer->setAnchorPoint(FloatPoint3D());
@@ -4021,7 +4021,7 @@
             m_layerForHorizontalScrollbar = GraphicsLayer::create(graphicsLayerFactory(), *this);
             m_layerForHorizontalScrollbar->setAllowsBackingStoreDetaching(false);
             m_layerForHorizontalScrollbar->setShowDebugBorder(m_showDebugBorders);
-            m_layerForHorizontalScrollbar->setName("horizontal scrollbar container");
+            m_layerForHorizontalScrollbar->setName(MAKE_STATIC_STRING_IMPL("horizontal scrollbar container"));
 #if PLATFORM(COCOA) && USE(CA)
             m_layerForHorizontalScrollbar->setAcceleratesDrawing(acceleratedDrawingEnabled());
 #endif
@@ -4042,7 +4042,7 @@
             m_layerForVerticalScrollbar = GraphicsLayer::create(graphicsLayerFactory(), *this);
             m_layerForVerticalScrollbar->setAllowsBackingStoreDetaching(false);
             m_layerForVerticalScrollbar->setShowDebugBorder(m_showDebugBorders);
-            m_layerForVerticalScrollbar->setName("vertical scrollbar container");
+            m_layerForVerticalScrollbar->setName(MAKE_STATIC_STRING_IMPL("vertical scrollbar container"));
 #if PLATFORM(COCOA) && USE(CA)
             m_layerForVerticalScrollbar->setAcceleratesDrawing(acceleratedDrawingEnabled());
 #endif
@@ -4063,7 +4063,7 @@
             m_layerForScrollCorner = GraphicsLayer::create(graphicsLayerFactory(), *this);
             m_layerForScrollCorner->setAllowsBackingStoreDetaching(false);
             m_layerForScrollCorner->setShowDebugBorder(m_showDebugBorders);
-            m_layerForScrollCorner->setName("scroll corner");
+            m_layerForScrollCorner->setName(MAKE_STATIC_STRING_IMPL("scroll corner"));
 #if PLATFORM(COCOA) && USE(CA)
             m_layerForScrollCorner->setAcceleratesDrawing(acceleratedDrawingEnabled());
 #endif
@@ -4083,7 +4083,7 @@
 
     if (!m_rootContentsLayer) {
         m_rootContentsLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
-        m_rootContentsLayer->setName("content root");
+        m_rootContentsLayer->setName(MAKE_STATIC_STRING_IMPL("content root"));
         IntRect overflowRect = snappedIntRect(m_renderView.layoutOverflowRect());
         m_rootContentsLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.maxY()));
         m_rootContentsLayer->setPosition(FloatPoint());
@@ -4106,10 +4106,10 @@
 
             // Create a layer to host the clipping layer and the overflow controls layers.
             m_overflowControlsHostLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
-            m_overflowControlsHostLayer->setName("overflow controls host");
+            m_overflowControlsHostLayer->setName(MAKE_STATIC_STRING_IMPL("overflow controls host"));
 
             m_scrolledContentsLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrolledContents);
-            m_scrolledContentsLayer->setName("frame scrolled contents");
+            m_scrolledContentsLayer->setName(MAKE_STATIC_STRING_IMPL("frame scrolled contents"));
             m_scrolledContentsLayer->setAnchorPoint({ });
 
 #if PLATFORM(IOS_FAMILY)
@@ -4116,7 +4116,7 @@
             if (m_renderView.settings().asyncFrameScrollingEnabled()) {
                 m_scrollContainerLayer = GraphicsLayer::create(graphicsLayerFactory(), *this, GraphicsLayer::Type::ScrollContainer);
 
-                m_scrollContainerLayer->setName("scroll container");
+                m_scrollContainerLayer->setName(MAKE_STATIC_STRING_IMPL("scroll container"));
                 m_scrollContainerLayer->setMasksToBounds(true);
                 m_scrollContainerLayer->setAnchorPoint({ });
 
@@ -4128,7 +4128,7 @@
             // account for clipping and top content inset (see FrameView::yPositionForInsetClipLayer()).
             if (!m_scrollContainerLayer) {
                 m_clipLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
-                m_clipLayer->setName("frame clipping");
+                m_clipLayer->setName(MAKE_STATIC_STRING_IMPL("frame clipping"));
                 m_clipLayer->setMasksToBounds(true);
                 m_clipLayer->setAnchorPoint({ });
 

Modified: trunk/Source/WebKit/ChangeLog (277791 => 277792)


--- trunk/Source/WebKit/ChangeLog	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebKit/ChangeLog	2021-05-20 17:08:30 UTC (rev 277792)
@@ -1,3 +1,28 @@
+2021-05-20  Geoffrey Garen  <gga...@apple.com>
+
+        GraphicsLayer::setName() causes heap fragmentation
+        https://bugs.webkit.org/show_bug.cgi?id=225838
+
+        Reviewed by Simon Fraser.
+
+        Profiling for heap fragmentation shows that GraphicsLayer::setName() is
+        a top contributor. Worth about 5MB maximum on GMail.
+
+        Use MAKE_STATIC_STRING_IMPL for our constant layer names so we end up
+        with only one copy and no heap allocation in the many cases that are
+        compile-time constants.
+
+        * WebProcess/Inspector/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::showPaintRect):
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+        (WebKit::CompositingCoordinator::CompositingCoordinator):
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::LayerTreeHost):
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp:
+        (WebKit::LayerTreeHost::LayerTreeHost):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
+
 2021-05-20  Per Arne  <pvol...@apple.com>
 
         [iOS] Add missing method in sandbox IOKit filter

Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorClient.cpp (277791 => 277792)


--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorClient.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorClient.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -173,7 +173,7 @@
 
     auto paintLayer = GraphicsLayer::create(m_page->drawingArea()->graphicsLayerFactory(), *m_paintIndicatorLayerClient);
     
-    paintLayer->setName("paint rect");
+    paintLayer->setName(MAKE_STATIC_STRING_IMPL("paint rect"));
     paintLayer->setAnchorPoint(FloatPoint3D());
     paintLayer->setPosition(rect.location());
     paintLayer->setSize(rect.size());

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (277791 => 277792)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -61,7 +61,7 @@
 
     m_rootLayer = GraphicsLayer::create(this, *this);
 #ifndef NDEBUG
-    m_rootLayer->setName("CompositingCoordinator root layer");
+    m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("CompositingCoordinator root layer"));
 #endif
     m_rootLayer->setDrawsContent(false);
     m_rootLayer->setSize(m_page.size());

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp (277791 => 277792)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp	2021-05-20 17:08:30 UTC (rev 277792)
@@ -107,7 +107,7 @@
     m_rootLayer->setSize(m_webPage.size());
     m_rootLayer->setNeedsDisplay();
 #ifndef NDEBUG
-    m_rootLayer->setName("Root layer");
+    m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("Root layer"));
 #endif
     applyDeviceScaleFactor();
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (277791 => 277792)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2021-05-20 17:00:15 UTC (rev 277791)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2021-05-20 17:08:30 UTC (rev 277792)
@@ -64,7 +64,7 @@
     , m_updateRenderingTimer(*this, &RemoteLayerTreeDrawingArea::updateRendering)
 {
     webPage.corePage()->settings().setForceCompositingMode(true);
-    m_rootLayer->setName("drawing area root");
+    m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("drawing area root"));
 
     m_commitQueue = adoptOSObject(dispatch_queue_create("com.apple.WebKit.WebContent.RemoteLayerTreeDrawingArea.CommitQueue", nullptr));
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to