Skip to content

Commit

Permalink
Add ENABLE macro for WebProcess cache
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261952
rdar://115896548

Reviewed by Brent Fulgham.

In https://commits.webkit.org/266267@main, the WebProcess cache was enabled on iOS,
but also enabled on watchOS and tvOS, which was not intentional. Fix this by adding
a ENABLE macro for the feature.

* Source/WTF/wtf/PlatformEnable.h:
* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WTF/wtf/PlatformEnableWinCairo.h:
* Source/WebKit/UIProcess/WebProcessCache.cpp:
(WebKit::WebProcessCache::updateCapacity):
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::prepareToSuspend):

Canonical link: https://commits.webkit.org/268334@main
  • Loading branch information
pvollan committed Sep 22, 2023
1 parent a6e0f8a commit e42376b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/WTF/wtf/PlatformEnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,3 +1033,11 @@
#if ENABLE(WEBXR_HANDS) && !ENABLE(WEBXR)
#error "ENABLE(WEBXR_HANDS) requires ENABLE(WEBXR)"
#endif

#if !defined(ENABLE_WEBPROCESS_CACHE) && (PLATFORM(GTK) || PLATFORM(WPE))
#define ENABLE_WEBPROCESS_CACHE 1
#endif

#if !defined(ENABLE_WEBPROCESS_CACHE)
#define ENABLE_WEBPROCESS_CACHE 0
#endif
5 changes: 5 additions & 0 deletions Source/WTF/wtf/PlatformEnableCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -1023,3 +1023,8 @@
#if !defined(ENABLE_STATIC_IPAD_USER_AGENT_VALUE) && PLATFORM(VISION)
#define ENABLE_STATIC_IPAD_USER_AGENT_VALUE 1
#endif

#if !defined(ENABLE_WEBPROCESS_CACHE) && (PLATFORM(MAC) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400))
#define ENABLE_WEBPROCESS_CACHE 1
#endif

4 changes: 4 additions & 0 deletions Source/WTF/wtf/PlatformEnableWinCairo.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@
#if !defined(ENABLE_GEOLOCATION)
#define ENABLE_GEOLOCATION 1
#endif

#if !defined(ENABLE_WEBPROCESS_CACHE)
#define ENABLE_WEBPROCESS_CACHE 1
#endif
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/WebProcessCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ RefPtr<WebProcessProxy> WebProcessCache::takeProcess(const WebCore::RegistrableD

void WebProcessCache::updateCapacity(WebProcessPool& processPool)
{
#if ENABLE(WEBPROCESS_CACHE)
if (!processPool.configuration().processSwapsOnNavigation() || !processPool.configuration().usesWebProcessCache() || LegacyGlobalSettings::singleton().cacheModel() != CacheModel::PrimaryWebBrowser || processPool.configuration().usesSingleWebProcess()) {
if (!processPool.configuration().processSwapsOnNavigation())
WEBPROCESSCACHE_RELEASE_LOG("updateCapacity: Cache is disabled because process swap on navigation is disabled", 0);
Expand Down Expand Up @@ -205,6 +206,7 @@ void WebProcessCache::updateCapacity(WebProcessPool& processPool)

if (!m_capacity)
clear();
#endif
}

void WebProcessCache::clear()
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/WebProcess/WebProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,11 @@ void WebProcess::prepareToSuspend(bool isSuspensionImminent, MonotonicTime estim
platformMediaSessionManager->processWillSuspend();
#endif

#if !ENABLE(WEBPROCESS_CACHE)
if (!m_suppressMemoryPressureHandler)
releaseMemory([] { });
#endif

freezeAllLayerTrees();

#if PLATFORM(COCOA)
Expand Down

0 comments on commit e42376b

Please sign in to comment.