Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 119dfcf94b3739cb0c6061c2800cbc40d1d33c0c
https://github.com/WebKit/WebKit/commit/119dfcf94b3739cb0c6061c2800cbc40d1d33c0c
Author: Ryan Reno <[email protected]>
Date: 2026-09-29 (Tue, 29 Sep 2026)
Changed paths:
M Source/WebCore/PlatformCocoa.cmake
M Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations
M Source/WebCore/SourcesCocoa.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm
M Source/WebCore/platform/graphics/ImageBufferBackend.cpp
M Source/WebCore/platform/graphics/ImageBufferBackend.h
R Source/WebCore/platform/graphics/ca/LayerPool.cpp
R Source/WebCore/platform/graphics/ca/LayerPool.h
M Source/WebCore/platform/graphics/ca/PlatformCALayer.h
M Source/WebCore/platform/graphics/ca/PlatformCALayer.mm
M Source/WebCore/platform/graphics/ca/TileController.cpp
M Source/WebCore/platform/graphics/ca/TileGrid.cpp
M Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp
M Source/WebCore/platform/graphics/cg/IOSurfacePool.h
M Source/WebCore/platform/graphics/cocoa/IOSurface.mm
M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h
M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.mm
M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h
M Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/IOSurfacePoolTests.cpp
Log Message:
-----------
Remove the PlatformCALayer LayerPool in favor of a more tuned IOSurfacePool
https://bugs.webkit.org/show_bug.cgi?id=296891
rdar://157494632
Reviewed by Matt Woodrow.
LayerPool kept removed tile layers for reuse with their backing store still
attached, so up to 48 MB
of surfaces per pool stayed non-volatile and out of IOSurfacePool's reach,
charged to the Web process.
It also keyed on exact layer size, so for a layer whose size animates it rarely
recycled anything and
just held memory.
IOSurfacePool itself only marked a cached surface volatile after it had gone
unused for 2 seconds,
checked on a 500 ms timer. During a continuous animation such as scrolling,
zooming, or element
animation, surfaces are recycled faster than they age, so nothing was ever
marked volatile. On some
sites as much as 99% of memory cached in the IOSurfacePool is non-volatile and
charged to the process.
This can easily put the web process over jetsam limits on iOS or drive
excessive memory use generally.
Remove LayerPool. A removed tile's PlatformCALayer is now destroyed, and its
surfaces return to IOSurfacePool like any
other layer.
IOSurfacePool now marks a surface volatile as soon as it enters the pool, as
long as it is not in use.
A surface that is still in use stays non-volatile until the collection timer
finds it released. The timer
now runs every 100 ms, and only while the pool holds in-use surfaces.
Because pooled surfaces are no longer charged to the owning process, pool
capacity is nearly free
and the hit rate is what matters. Every miss allocates a fresh non-volatile
surface, while a hit
takes back bytes that were not being charged. This can significantly reduce
allocation churn as measured
on a variety of live web sites. Raise the pool's cap on iOS from 64 MB to 256
MB, the same as macOS.
The in-use limits are unchanged: 32 MB on iOS, 128 MB on macOS.
PLUM and Membuster report a 5-10% reduction in peak physical footprint. And
during pinch zoom or
aggressive scrolling with rubber banding the peak footprint can be reduced by
as much as 30%.
Tests: TestWebKitAPI.IOSurfacePoolTest.AddedSurfaceIsVolatileUntilTaken
TestWebKitAPI.IOSurfacePoolTest.InUseSurfaceBecomesVolatileWhenNoLongerInUse
* Source/WebCore/PlatformCocoa.cmake:
* Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations:
* Source/WebCore/SourcesCocoa.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm:
(WebCore::platformReleaseMemory):
* Source/WebCore/platform/graphics/ImageBufferBackend.cpp:
(WebCore::operator<<):
Move from IOSurface and export so that DUMP_POOL_STATISTICS can
report whether a surface it handed out was purged while in the pool.
* Source/WebCore/platform/graphics/ImageBufferBackend.h:
* Source/WebCore/platform/graphics/ca/LayerPool.cpp: Removed.
* Source/WebCore/platform/graphics/ca/LayerPool.h: Removed.
* Source/WebCore/platform/graphics/ca/PlatformCALayer.h:
* Source/WebCore/platform/graphics/ca/PlatformCALayer.mm:
(WebCore::PlatformCALayer::createCompatibleLayerWithSize const):
(WebCore::PlatformCALayer::createCompatibleLayerOrTakeFromPool): Deleted.
(WebCore::PlatformCALayer::moveToLayerPool): Deleted.
(WebCore::PlatformCALayer::layerPool): Deleted.
* Source/WebCore/platform/graphics/ca/TileController.cpp:
(WebCore::TileController::createTileLayer):
* Source/WebCore/platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::removeTiles):
* Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::willAddSurface):
(WebCore::IOSurfacePool::didRemoveSurface):
(WebCore::IOSurfacePool::takeSurface):
(WebCore::IOSurfacePool::insertSurfaceIntoPool):
(WebCore::IOSurfacePool::collectInUseSurfaces):
(WebCore::IOSurfacePool::collectionTimerFired):
(WebCore::IOSurfacePool::scheduleCollectionTimer):
(WebCore::IOSurfacePool::discardAllSurfacesInternal):
(WebCore::IOSurfacePool::markOlderSurfacesPurgeable): Deleted.
* Source/WebCore/platform/graphics/cg/IOSurfacePool.h:
(WebCore::IOSurfacePool::CachedSurfaceDetails::CachedSurfaceDetails): Deleted.
(WebCore::IOSurfacePool::CachedSurfaceDetails::resetLastUseTime): Deleted.
* Source/WebCore/platform/graphics/cocoa/IOSurface.mm:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.mm:
(WebKit::PlatformCALayerRemote::layerPool): Deleted.
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.h:
(WebKit::RemoteLayerTreeContext::layerPool): Deleted.
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::RemoteLayerTreeContext):
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/IOSurfacePoolTests.cpp:
(TestWebKitAPI::isVolatile):
(TestWebKitAPI::TEST(IOSurfacePoolTest, AddedSurfaceIsVolatileUntilTaken)):
(TestWebKitAPI::TEST(IOSurfacePoolTest,
InUseSurfaceBecomesVolatileWhenNoLongerInUse)):
Canonical link: https://commits.webkit.org/322160@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications