Title: [279594] trunk/Source/WebCore
Revision
279594
Author
[email protected]
Date
2021-07-06 10:32:16 -0700 (Tue, 06 Jul 2021)

Log Message

Add assertions in LayerPool to help debug <rdar://80184576>
https://bugs.webkit.org/show_bug.cgi?id=227710

Reviewed by Simon Fraser.

* platform/graphics/ca/LayerPool.cpp:
(WebCore::LayerPool::LayerPool):
(WebCore::LayerPool::~LayerPool):
(WebCore::LayerPool::addLayer):
(WebCore::LayerPool::takeLayerWithSize):
(WebCore::LayerPool::pruneTimerFired):
(WebCore::LayerPool::drain):
* platform/graphics/ca/LayerPool.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279593 => 279594)


--- trunk/Source/WebCore/ChangeLog	2021-07-06 17:29:30 UTC (rev 279593)
+++ trunk/Source/WebCore/ChangeLog	2021-07-06 17:32:16 UTC (rev 279594)
@@ -1,5 +1,21 @@
 2021-07-06  Chris Dumez  <[email protected]>
 
+        Add assertions in LayerPool to help debug <rdar://80184576>
+        https://bugs.webkit.org/show_bug.cgi?id=227710
+
+        Reviewed by Simon Fraser.
+
+        * platform/graphics/ca/LayerPool.cpp:
+        (WebCore::LayerPool::LayerPool):
+        (WebCore::LayerPool::~LayerPool):
+        (WebCore::LayerPool::addLayer):
+        (WebCore::LayerPool::takeLayerWithSize):
+        (WebCore::LayerPool::pruneTimerFired):
+        (WebCore::LayerPool::drain):
+        * platform/graphics/ca/LayerPool.h:
+
+2021-07-06  Chris Dumez  <[email protected]>
+
         Unreviewed, reverting r279495.
 
         Seems to have caused a ~2% PLT5 regression

Modified: trunk/Source/WebCore/platform/graphics/ca/LayerPool.cpp (279593 => 279594)


--- trunk/Source/WebCore/platform/graphics/ca/LayerPool.cpp	2021-07-06 17:29:30 UTC (rev 279593)
+++ trunk/Source/WebCore/platform/graphics/ca/LayerPool.cpp	2021-07-06 17:32:16 UTC (rev 279594)
@@ -31,23 +31,25 @@
 
 namespace WebCore {
 
-static const Seconds capacityDecayTime { 5_s };
+static constexpr Seconds capacityDecayTime { 5_s };
 
 LayerPool::LayerPool()
-    : m_totalBytes(0)
-    , m_maxBytesForPool(48 * 1024 * 1024)
+    : m_maxBytesForPool(48 * 1024 * 1024)
     , m_pruneTimer(*this, &LayerPool::pruneTimerFired)
 {
+    RELEASE_ASSERT(isMainThread());
     allLayerPools().add(this);
 }
 
 LayerPool::~LayerPool()
 {
+    RELEASE_ASSERT(isMainThread());
     allLayerPools().remove(this);
 }
 
 HashSet<LayerPool*>& LayerPool::allLayerPools()
 {
+    RELEASE_ASSERT(isMainThread());
     static NeverDestroyed<HashSet<LayerPool*>> allLayerPools;
     return allLayerPools.get();
 }
@@ -72,6 +74,7 @@
 
 void LayerPool::addLayer(const RefPtr<PlatformCALayer>& layer)
 {
+    RELEASE_ASSERT(isMainThread());
     IntSize layerSize(expandedIntSize(layer->bounds().size()));
     if (!canReuseLayerWithSize(layerSize))
         return;
@@ -85,6 +88,7 @@
 
 RefPtr<PlatformCALayer> LayerPool::takeLayerWithSize(const IntSize& size)
 {
+    RELEASE_ASSERT(isMainThread());
     if (!canReuseLayerWithSize(size))
         return nullptr;
     LayerList& reuseList = listOfLayersWithSize(size, MarkAsUsed);
@@ -113,11 +117,14 @@
 
 void LayerPool::pruneTimerFired()
 {
+    RELEASE_ASSERT(isMainThread());
     unsigned shrinkTo = decayedCapacity();
     while (m_totalBytes > shrinkTo) {
-        ASSERT(!m_sizesInPruneOrder.isEmpty());
+        RELEASE_ASSERT(!m_sizesInPruneOrder.isEmpty());
         IntSize sizeToDrop = m_sizesInPruneOrder.first();
-        LayerList& oldestReuseList = m_reuseLists.find(sizeToDrop)->value;
+        auto it = m_reuseLists.find(sizeToDrop);
+        RELEASE_ASSERT(it != m_reuseLists.end());
+        LayerList& oldestReuseList = it->value;
         if (oldestReuseList.isEmpty()) {
             m_reuseLists.remove(sizeToDrop);
             m_sizesInPruneOrder.remove(0);
@@ -124,10 +131,11 @@
             continue;
         }
 
+        ASSERT(m_totalBytes >= backingStoreBytesForSize(sizeToDrop));
         m_totalBytes -= backingStoreBytesForSize(sizeToDrop);
         // The last element in the list is the oldest, hence most likely not to
         // still have a backing store.
-        oldestReuseList.remove(--oldestReuseList.end());
+        oldestReuseList.removeLast();
     }
     if (MonotonicTime::now() - m_lastAddTime <= capacityDecayTime)
         schedulePrune();
@@ -135,6 +143,7 @@
 
 void LayerPool::drain()
 {
+    RELEASE_ASSERT(isMainThread());
     m_reuseLists.clear();
     m_sizesInPruneOrder.clear();
     m_totalBytes = 0;

Modified: trunk/Source/WebCore/platform/graphics/ca/LayerPool.h (279593 => 279594)


--- trunk/Source/WebCore/platform/graphics/ca/LayerPool.h	2021-07-06 17:29:30 UTC (rev 279593)
+++ trunk/Source/WebCore/platform/graphics/ca/LayerPool.h	2021-07-06 17:32:16 UTC (rev 279594)
@@ -70,7 +70,7 @@
     HashMap<IntSize, LayerList> m_reuseLists;
     // Ordered by recent use. The last size is the most recently used.
     Vector<IntSize> m_sizesInPruneOrder;
-    unsigned m_totalBytes;
+    unsigned m_totalBytes { 0 };
     unsigned m_maxBytesForPool;
 
     Timer m_pruneTimer;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to