Skip to content

Commit

Permalink
Avoid duplicate ReleaseMemory calls on Mac
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274396
rdar://127750149

Reviewed by Chris Dumez.

On the Mac, we enable NON_VISIBLE_WEBPROCESS_MEMORY_CLEANUP_TIMER, which calls releaseMemory to
clean up memory two minutes after a WebContent process has no visible webpages. We also call
releaseMemory just before a process suspends (in `WebProcessProxy::prepareToDropLastAssertion`),
whcih generally happens 8 minutes after a WebContent process has no visible webpages (see
`_wasRecentlyVisibleActivity` in WebPageProxy).

This means we are calling ReleaseMemory twice as a WebContent process transitions from foreground to
background to suspended states. We only meant to call this once. Fix this by disabling the call to
releaseMemory in prepareToDropLastAssertion if the non-visible cleanup timer is enabled.

* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::prepareToDropLastAssertion):

Canonical link: https://commits.webkit.org/279059@main
  • Loading branch information
bnham committed May 21, 2024
1 parent a0244be commit c77bdbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/WebProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ void WebProcessProxy::didDropLastAssertion()

void WebProcessProxy::prepareToDropLastAssertion(CompletionHandler<void()>&& completionHandler)
{
#if ENABLE(WEBPROCESS_CACHE)
#if !ENABLE(NON_VISIBLE_WEBPROCESS_MEMORY_CLEANUP_TIMER) && ENABLE(WEBPROCESS_CACHE)
if (isInProcessCache() || !m_suspendedPages.isEmptyIgnoringNullReferences() || (canTerminateAuxiliaryProcess() && canBeAddedToWebProcessCache())) {
// We avoid freeing caches if:
//
Expand Down

0 comments on commit c77bdbf

Please sign in to comment.