Title: [236621] trunk/Source/WebKit
- Revision
- 236621
- Author
- [email protected]
- Date
- 2018-09-28 16:09:32 -0700 (Fri, 28 Sep 2018)
Log Message
Do not do automatic process prewarming while under memory pressure
https://bugs.webkit.org/show_bug.cgi?id=190082
<rdar://problem/39771424>
Reviewed by Geoffrey Garen.
Do not do automatic process prewarming while under memory pressure and
also terminate any prewarmed process when receiving a memory warning.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::prewarmProcess):
(WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
(WebKit::WebProcessPool::handleMemoryPressureWarning):
* UIProcess/WebProcessPool.h:
* UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
(WebKit::installMemoryPressureHandler):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (236620 => 236621)
--- trunk/Source/WebKit/ChangeLog 2018-09-28 23:05:36 UTC (rev 236620)
+++ trunk/Source/WebKit/ChangeLog 2018-09-28 23:09:32 UTC (rev 236621)
@@ -1,3 +1,22 @@
+2018-09-28 Chris Dumez <[email protected]>
+
+ Do not do automatic process prewarming while under memory pressure
+ https://bugs.webkit.org/show_bug.cgi?id=190082
+ <rdar://problem/39771424>
+
+ Reviewed by Geoffrey Garen.
+
+ Do not do automatic process prewarming while under memory pressure and
+ also terminate any prewarmed process when receiving a memory warning.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::prewarmProcess):
+ (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
+ (WebKit::WebProcessPool::handleMemoryPressureWarning):
+ * UIProcess/WebProcessPool.h:
+ * UIProcess/ios/WebMemoryPressureHandlerIOS.mm:
+ (WebKit::installMemoryPressureHandler):
+
2018-09-28 Daniel Bates <[email protected]>
[iOS] Allow programmatic focus when hardware keyboard is attached
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (236620 => 236621)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-09-28 23:05:36 UTC (rev 236620)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-09-28 23:09:32 UTC (rev 236621)
@@ -997,6 +997,7 @@
if (!m_websiteDataStore)
m_websiteDataStore = API::WebsiteDataStore::defaultDataStore().ptr();
+ RELEASE_LOG(PerformanceLogging, "Prewarming a WebProcess for performance");
createNewWebProcess(m_websiteDataStore->websiteDataStore(), WebProcessProxy::IsPrewarmed::Yes);
}
@@ -1307,6 +1308,12 @@
if (!configuration().isAutomaticProcessWarmingEnabled())
return;
+ if (MemoryPressureHandler::singleton().isUnderMemoryPressure()) {
+ if (!m_prewarmedProcess)
+ RELEASE_LOG(PerformanceLogging, "Not automatically prewarming a WebProcess due to memory pressure");
+ return;
+ }
+
prewarmProcess();
}
@@ -1322,6 +1329,13 @@
return statistics;
}
+void WebProcessPool::handleMemoryPressureWarning(Critical)
+{
+ if (m_prewarmedProcess)
+ m_prewarmedProcess->shutDown();
+ ASSERT(!m_prewarmedProcess);
+}
+
#if ENABLE(NETSCAPE_PLUGIN_API)
void WebProcessPool::setAdditionalPluginsDirectory(const String& directory)
{
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (236620 => 236621)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-09-28 23:05:36 UTC (rev 236620)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-09-28 23:09:32 UTC (rev 236621)
@@ -51,6 +51,7 @@
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/MemoryPressureHandler.h>
#include <wtf/ProcessID.h>
#include <wtf/RefCounter.h>
#include <wtf/RefPtr.h>
@@ -201,6 +202,8 @@
void populateVisitedLinks();
+ void handleMemoryPressureWarning(Critical);
+
#if ENABLE(NETSCAPE_PLUGIN_API)
void setAdditionalPluginsDirectory(const String&);
void refreshPlugins();
Modified: trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm (236620 => 236621)
--- trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm 2018-09-28 23:05:36 UTC (rev 236620)
+++ trunk/Source/WebKit/UIProcess/ios/WebMemoryPressureHandlerIOS.mm 2018-09-28 23:09:32 UTC (rev 236621)
@@ -29,16 +29,13 @@
#if PLATFORM(IOS)
#import "ViewSnapshotStore.h"
+#import "WebProcessPool.h"
+#import <wtf/MemoryPressureHandler.h>
namespace WebKit {
void installMemoryPressureHandler()
{
- static bool installed = false;
- if (installed)
- return;
- installed = true;
-
// FIXME: This should be able to share code with WebCore's MemoryPressureHandler (and be platform independent).
// Right now it cannot because WebKit1 and WebKit2 need to be able to coexist in the UI process,
// and you can only have one WebCore::MemoryPressureHandler.
@@ -46,12 +43,14 @@
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitSuppressMemoryPressureHandler"])
return;
- // Use a static here so the intentionally immortal dispatch source does not show up as a storage leak.
- static auto source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN, dispatch_get_main_queue());
- dispatch_source_set_event_handler(source, ^ {
+ auto& memoryPressureHandler = MemoryPressureHandler::singleton();
+ memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous) {
ViewSnapshotStore::singleton().discardSnapshotImages();
+
+ for (auto* processPool : WebProcessPool::allProcessPools())
+ processPool->handleMemoryPressureWarning(critical);
});
- dispatch_resume(source);
+ memoryPressureHandler.install();
}
} // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes