Pages in the PageCache preserve their layers and backing stores and can consume a lot of memory. In situations where we need to handle low memory conditions we can still keep the Document in memory if we save enough memory by just clearing the backing stores + layers. This can also be done proactively when a page enters the PageCache.
Created attachment 97183 [details] [TEST] Test Page for numerous layers and iframes with layers. Test case I used. I saw ~90MB of CoreAnimation memory with Desktop Safari. With my patch, and the feature enabled, that memory dropped to 4KB when going to about:blank, and restored to 90 when going back to the page.
Created attachment 97185 [details] [PATCH] Clear Backing Stores entering Page Cache First attempt.
Attachment 97185 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/rendering/RenderLayer.cpp:3648: l is incorrectly named. Don't use the single letter 'l' as an identifier name. [readability/naming] [4] Total errors found: 1 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
<rdar://problem/8652717>
Comment on attachment 97185 [details] [PATCH] Clear Backing Stores entering Page Cache View in context: https://bugs.webkit.org/attachment.cgi?id=97185&action=review > Source/WebCore/ChangeLog:13 > + This only affects memory usage and is disabled by default, so no test. It would be nice to have a test that puts a composited page in the BF cache, brings it back, then calls layerTreeAsText(). That way at least platforms that enable the option will have test coverage.
Actually, it would be good to test that this doesn't break WebGL and <video> if enabled on desktop.
Attachment 97185 [details] was posted by a committer and has review+, assigning to Joseph Pecoraro for commit.
(In reply to comment #6) > Actually, it would be good to test that this doesn't break WebGL and <video> if enabled on desktop. Verified manually that this didn't break WebGL, <video>, and <audio> when enabled on Desktop.
Created attachment 97883 [details] [PATCH] LayoutTest for this This is a LayoutTest that dumps the layer tree after restoring a page with composited iframes from the page cache. Testing this with pageCache()->shouldClearBackingStores() enabled had the exact same results, which is what we want.
Comment on attachment 97883 [details] [PATCH] LayoutTest for this Test looks OK. Will this work on all platforms? If not, then doesn’t it need platform-specific results or skip list items?
(In reply to comment #10) > (From update of attachment 97883 [details]) > Test looks OK. Will this work on all platforms? If not, then doesn’t it need > platform-specific results or skip list items? It probably does. I wasn't sure so I was going to let the EWS tell me.
Looked good for EWS ports. Also, LayoutTests/composited/* has a lot of cross-platform expected results for layer tree dumps. I'll land with the test in its current spot and watch the build-bots in case I need to make a fix.
Landed the patch + test together in: r89316 http://trac.webkit.org/changeset/89316