RESOLVED FIXED 225007
Reduce memory footprint for background tabs
https://bugs.webkit.org/show_bug.cgi?id=225007
Summary Reduce memory footprint for background tabs
Ben Nham
Reported 2021-04-23 16:06:04 PDT
Reduce memory footprint for background tabs
Attachments
Patch (7.23 KB, patch)
2021-04-23 16:10 PDT, Ben Nham
no flags
Patch (7.67 KB, patch)
2021-04-26 13:11 PDT, Ben Nham
no flags
patch for landing (7.65 KB, patch)
2021-04-26 13:57 PDT, Ben Nham
no flags
Patch (8.11 KB, patch)
2021-04-29 09:41 PDT, Ben Nham
no flags
Ben Nham
Comment 1 2021-04-23 16:10:53 PDT
Radar WebKit Bug Importer
Comment 2 2021-04-23 16:11:36 PDT
Ben Nham
Comment 3 2021-04-23 16:12:29 PDT
Comment on attachment 426961 [details] Patch initial pass for testing
Chris Dumez
Comment 4 2021-04-23 16:36:37 PDT
Comment on attachment 426961 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426961&action=review > Source/WTF/ChangeLog:9 > + similar just before WebContent suspends. The major difference is that on iOS the process suspends and does not keep allocating memory after we simulate memory pressure. > Source/WTF/wtf/PlatformEnableCocoa.h:393 > +#if !defined(ENABLE_NON_VISIBLE_WEBPROCESS_MEMORY_CLEANUP_TIMER) Did you mean to enable this only on macOS? > Source/WebKit/WebProcess/WebProcess.cpp:1590 > +#if ENABLE(NON_VISIBLE_WEBPROCESS_MEMORY_CLEANUP_TIMER) This should probably cover the whole timer logic. Why start a timer to do nothing on iOS? > Source/WebKit/WebProcess/WebProcess.cpp:1591 > + WebCore::releaseMemory(WTF::Critical::Yes, WTF::Synchronous::No, WebCore::MaintainBackForwardCache::No, WebCore::MaintainMemoryCache::No); One concern. Consider the case where we navigate cross-origin (Process-swap-on-navigation). To support back/forward cache, we keep the previous process around with its back/forward cache entry. When we swapped process, I am assuming that pageWillLeaveWindow() gets called in the previous process. If so, it would start your 1min timer and it would clear my back/forward cache entry. This means that the back/forward cache only works for 1min after a process-swap. If so, this seems bad.
Ben Nham
Comment 5 2021-04-26 13:11:19 PDT
Ben Nham
Comment 6 2021-04-26 13:17:08 PDT
Comment on attachment 427084 [details] Patch Enable only for Mac and Catalyst and don't drop the back/forward cache.
Chris Dumez
Comment 7 2021-04-26 13:37:13 PDT
Comment on attachment 427084 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427084&action=review r- because this clears the back/forward cache and thus likely breaks the back/forward cache after 1 min, after navigating cross-origin (process-swap). > Source/WebKit/WebProcess/WebProcess.cpp:1600 > + WebCore::releaseMemory(WTF::Critical::Yes, WTF::Synchronous::No, WebCore::MaintainBackForwardCache::Yes, WebCore::MaintainMemoryCache::No); You are still clearing the back/forward cache, which is the one I complained about. WTF:: is unnecessary, so is WebCore::. > Source/WebKit/WebProcess/WebProcess.cpp:1602 > + page->releaseMemory(WTF::Critical::Yes); WTF:: is unnecessary.
Chris Dumez
Comment 8 2021-04-26 13:39:45 PDT
Comment on attachment 427084 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427084&action=review r=me with nits. >> Source/WebKit/WebProcess/WebProcess.cpp:1600 >> + WebCore::releaseMemory(WTF::Critical::Yes, WTF::Synchronous::No, WebCore::MaintainBackForwardCache::Yes, WebCore::MaintainMemoryCache::No); > > You are still clearing the back/forward cache, which is the one I complained about. > > WTF:: is unnecessary, so is WebCore::. Oh, I misread, this is keeping the back/forward cache. My bad.
Ben Nham
Comment 9 2021-04-26 13:57:02 PDT
Created attachment 427088 [details] patch for landing
EWS
Comment 10 2021-04-26 16:42:11 PDT
Committed r276619 (237048@main): <https://commits.webkit.org/237048@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427088 [details].
Ben Nham
Comment 11 2021-04-29 09:26:47 PDT
Reverted r276619 for reason: Causes multiple regressions on perf bots. Committed r276779 (237162@main): <https://commits.webkit.org/237162@main>
Ben Nham
Comment 12 2021-04-29 09:41:23 PDT
Ben Nham
Comment 13 2021-04-29 09:42:21 PDT
*** Bug 225165 has been marked as a duplicate of this bug. ***
EWS
Comment 14 2021-04-29 12:02:02 PDT
Committed r276788 (237166@main): <https://commits.webkit.org/237166@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427351 [details].
Note You need to log in before you can comment on or make changes to this bug.