haikuwebkit/Source/WebKit/UIProcess/glib
Miguel Gomez 5d0c2ffb38 [GTK][WPE] Allow the user to configure the MemoryPressureHandler inside the web process
https://bugs.webkit.org/show_bug.cgi?id=222738

Reviewed by Carlos Garcia Campos.

Source/WebCore:

MemoryPressureHandler::currentMemoryUsagePolicy() is now an instance method and not a class one,
so update the call in RenderLayerCompositor to use the singleton instance.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingPolicy):

Source/WebKit:

Add a new API type WebKitMemoryPressureSettings that can be used to configure the behavior
of the MemoryPressureHandler. Add a property to WebKitWebContext that can be used to pass
new settings to it, and store them inside its API::ProcessPoolConfiguration. Those settings
will be set to new web processes during the platform initialization stage.

* PlatformGTK.cmake:
* PlatformWPE.cmake:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* SourcesGTK.txt:
* SourcesWPE.txt:
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/glib/WebKitMemoryPressureSettings.cpp: Added.
(webkit_memory_pressure_settings_new):
(webkit_memory_pressure_settings_copy):
(webkit_memory_pressure_settings_free):
(webkit_memory_pressure_settings_set_memory_limit):
(webkit_memory_pressure_settings_get_memory_limit):
(webkit_memory_pressure_settings_set_conservative_threshold):
(webkit_memory_pressure_settings_get_conservative_threshold):
(webkit_memory_pressure_settings_set_strict_threshold):
(webkit_memory_pressure_settings_get_strict_threshold):
(webkit_memory_pressure_settings_set_kill_threshold):
(webkit_memory_pressure_settings_get_kill_threshold):
(webkit_memory_pressure_settings_set_poll_interval):
(webkit_memory_pressure_settings_get_poll_interval):
(webkitMemoryPressureSettingsGetMemoryPressureHandlerConfiguration):
* UIProcess/API/glib/WebKitMemoryPressureSettingsPrivate.h: Added.
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkitWebContextSetProperty):
(webkitWebContextConstructed):
(webkit_web_context_class_init):
* UIProcess/API/gtk/WebKitAutocleanups.h:
* UIProcess/API/gtk/WebKitMemoryPressureSettings.h: Added.
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/gtk/webkit2.h:
* UIProcess/API/wpe/WebKitAutocleanups.h:
* UIProcess/API/wpe/WebKitMemoryPressureSettings.h: Added.
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
* UIProcess/API/wpe/webkit.h:
* UIProcess/glib/WebProcessPoolGLib.cpp:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* WebProcess/glib/WebProcessGLib.cpp:
(WebKit::WebProcess::platformInitializeWebProcess):

Source/WTF:

Add a configuration structure to MemoryPressureHandler, with the methods to encode/decode it. Also
add a method to set a configuration structure to a MemoryPressureHandler instance, and modify the
behavior so the the configuration is used when checking the memory used by the process.

* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
(WTF::MemoryPressureHandler::thresholdForMemoryKill):
(WTF::MemoryPressureHandler::thresholdForPolicy):
(WTF::MemoryPressureHandler::policyForFootprint):
(WTF::MemoryPressureHandler::Configuration::Configuration):
* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::Configuration::encode const):
(WTF::MemoryPressureHandler::Configuration::decode):
(WTF::MemoryPressureHandler::setConfiguration):

Tools:

Add a test for WebKitMemoryPressureSettings API and to test WebKitWebContext with
non default WebKitMemoryPressureSettings values.

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:
(MemoryPressureTest::setup):
(MemoryPressureTest::teardown):
(MemoryPressureTest::webProcessTerminatedCallback):
(MemoryPressureTest::waitUntilWebProcessTerminated):
(testMemoryPressureSettings):
(beforeAll):
* TestWebKitAPI/glib/WebKitGLib/TestMain.cpp:
* TestWebKitAPI/glib/WebKitGLib/TestMain.h:
(Test::Test):


Canonical link: https://commits.webkit.org/239852@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-21 20:10:49 +00:00
..
UserMediaPermissionRequestManagerProxyGLib.cpp Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
WebPageProxyGLib.cpp
WebProcessPoolGLib.cpp [GTK][WPE] Allow the user to configure the MemoryPressureHandler inside the web process 2021-07-21 20:10:49 +00:00
WebProcessProxyGLib.cpp
WebsiteDataStoreGLib.cpp