Title: [231771] trunk/Source/WebKit
Revision
231771
Author
[email protected]
Date
2018-05-14 15:31:40 -0700 (Mon, 14 May 2018)

Log Message

Overly aggressive timer throttling in service workers
https://bugs.webkit.org/show_bug.cgi?id=185575
<rdar://problem/40219038>

Reviewed by Geoff Garen.

After ~30 seconds, the system would put the service worker process in "App Nap",
causing its timers to get aggressively throttled. This happens because the
service worker processes are WebProcesses that have no visible WebPages.

To address the issue, we now disable process suppression for all service worker
processes. This causes those processes to construct a UserActivity which prevents
App Nap.

This patch also refactors the code a bit to avoid duplication. The ProcessSuppression
suppression logic in now all on ChildProcessProxy / ChildProcess.

* NetworkProcess/NetworkProcess.messages.in:
* PluginProcess/PluginProcess.messages.in:
* Shared/ChildProcess.messages.in:
* UIProcess/ChildProcessProxy.cpp:
(WebKit::ChildProcessProxy::setProcessSuppressionEnabled):
* UIProcess/ChildProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/mac/NetworkProcessProxyMac.mm: Removed.
* UIProcess/Plugins/PluginProcessProxy.h:
* UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
* UIProcess/ServiceWorkerProcessProxy.cpp:
(WebKit::ServiceWorkerProcessProxy::didFinishLaunching):
* UIProcess/ServiceWorkerProcessProxy.h:
* UIProcess/WebProcessProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebProcess.messages.in:

Modified Paths

Removed Paths

  • trunk/Source/WebKit/UIProcess/Network/mac/

Diff

Modified: trunk/Source/WebKit/ChangeLog (231770 => 231771)


--- trunk/Source/WebKit/ChangeLog	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/ChangeLog	2018-05-14 22:31:40 UTC (rev 231771)
@@ -1,3 +1,39 @@
+2018-05-14  Chris Dumez  <[email protected]>
+
+        Overly aggressive timer throttling in service workers
+        https://bugs.webkit.org/show_bug.cgi?id=185575
+        <rdar://problem/40219038>
+
+        Reviewed by Geoff Garen.
+
+        After ~30 seconds, the system would put the service worker process in "App Nap",
+        causing its timers to get aggressively throttled. This happens because the
+        service worker processes are WebProcesses that have no visible WebPages.
+
+        To address the issue, we now disable process suppression for all service worker
+        processes. This causes those processes to construct a UserActivity which prevents
+        App Nap.
+
+        This patch also refactors the code a bit to avoid duplication. The ProcessSuppression
+        suppression logic in now all on ChildProcessProxy / ChildProcess.
+
+        * NetworkProcess/NetworkProcess.messages.in:
+        * PluginProcess/PluginProcess.messages.in:
+        * Shared/ChildProcess.messages.in:
+        * UIProcess/ChildProcessProxy.cpp:
+        (WebKit::ChildProcessProxy::setProcessSuppressionEnabled):
+        * UIProcess/ChildProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/mac/NetworkProcessProxyMac.mm: Removed.
+        * UIProcess/Plugins/PluginProcessProxy.h:
+        * UIProcess/Plugins/mac/PluginProcessProxyMac.mm:
+        * UIProcess/ServiceWorkerProcessProxy.cpp:
+        (WebKit::ServiceWorkerProcessProxy::didFinishLaunching):
+        * UIProcess/ServiceWorkerProcessProxy.h:
+        * UIProcess/WebProcessProxy.h:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebProcess.messages.in:
+
 2018-05-14  Andy Estes  <[email protected]>
 
         [Wi-Fi Assertions] Allow clients to specify a context identifier

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (231770 => 231771)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-05-14 22:31:40 UTC (rev 231771)
@@ -52,7 +52,6 @@
     ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request)
     ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle, bool allowOverwrite)
 
-    SetProcessSuppressionEnabled(bool flag)
 #if PLATFORM(COCOA)
     SetQOS(int latencyQOS, int throughputQOS)
     SetCookieStoragePartitioningEnabled(bool enabled)

Modified: trunk/Source/WebKit/PluginProcess/PluginProcess.messages.in (231770 => 231771)


--- trunk/Source/WebKit/PluginProcess/PluginProcess.messages.in	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/PluginProcess/PluginProcess.messages.in	2018-05-14 22:31:40 UTC (rev 231771)
@@ -38,7 +38,6 @@
     DeleteWebsiteData(WallTime modifiedSince, uint64_t callbackID)
     DeleteWebsiteDataForHostNames(Vector<String> hostNames, uint64_t callbackID)
 
-    SetProcessSuppressionEnabled(bool flag)
 #if PLATFORM(COCOA)
     SetQOS(int latencyQOS, int throughputQOS)
 #endif

Modified: trunk/Source/WebKit/Shared/ChildProcess.messages.in (231770 => 231771)


--- trunk/Source/WebKit/Shared/ChildProcess.messages.in	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/Shared/ChildProcess.messages.in	2018-05-14 22:31:40 UTC (rev 231771)
@@ -23,4 +23,5 @@
 messages -> ChildProcess {
     ShutDown()
     RegisterURLSchemeServiceWorkersCanHandle(String scheme)
+    SetProcessSuppressionEnabled(bool flag)
 }

Modified: trunk/Source/WebKit/UIProcess/ChildProcessProxy.cpp (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/ChildProcessProxy.cpp	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/ChildProcessProxy.cpp	2018-05-14 22:31:40 UTC (rev 231771)
@@ -213,6 +213,18 @@
     m_connection = nullptr;
 }
 
+void ChildProcessProxy::setProcessSuppressionEnabled(bool processSuppressionEnabled)
+{
+#if PLATFORM(COCOA)
+    if (state() != State::Running)
+        return;
+
+    connection()->send(Messages::ChildProcess::SetProcessSuppressionEnabled(processSuppressionEnabled), 0);
+#else
+    UNUSED_PARAM(processSuppressionEnabled);
+#endif
+}
+
 void ChildProcessProxy::connectionWillOpen(IPC::Connection&)
 {
 }

Modified: trunk/Source/WebKit/UIProcess/ChildProcessProxy.h (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/ChildProcessProxy.h	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/ChildProcessProxy.h	2018-05-14 22:31:40 UTC (rev 231771)
@@ -83,6 +83,8 @@
 
     WebCore::ProcessIdentifier coreProcessIdentifier() const { return m_processIdentifier; }
 
+    void setProcessSuppressionEnabled(bool);
+
 protected:
     // ProcessLauncher::Client
     void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2018-05-14 22:31:40 UTC (rev 231771)
@@ -76,10 +76,6 @@
     void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, WTF::Function<void()>&& completionHandler);
     void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, WTF::Function<void()>&& completionHandler);
 
-#if PLATFORM(COCOA)
-    void setProcessSuppressionEnabled(bool);
-#endif
-
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
     void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);

Modified: trunk/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.h (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.h	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.h	2018-05-14 22:31:40 UTC (rev 231771)
@@ -84,11 +84,6 @@
 
     bool isValid() const { return m_connection; }
 
-#if PLATFORM(COCOA)
-    void setProcessSuppressionEnabled(bool);
-
-#endif
-
 #if PLUGIN_ARCHITECTURE(UNIX)
     static bool scanPlugin(const String& pluginPath, RawPluginMetaData& result);
 #endif

Modified: trunk/Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/Plugins/mac/PluginProcessProxyMac.mm	2018-05-14 22:31:40 UTC (rev 231771)
@@ -230,14 +230,6 @@
     makePluginProcessTheFrontProcess();
 }
 
-void PluginProcessProxy::setProcessSuppressionEnabled(bool processSuppressionEnabled)
-{
-    if (!isValid())
-        return;
-
-    m_connection->send(Messages::PluginProcess::SetProcessSuppressionEnabled(processSuppressionEnabled), 0);
-}
-
 static bool isFlashUpdater(const String& launchPath, const Vector<String>& arguments)
 {
     if (launchPath != "/Applications/Utilities/Adobe Flash Player Install Manager.app/Contents/MacOS/Adobe Flash Player Install Manager")

Modified: trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp	2018-05-14 22:31:40 UTC (rev 231771)
@@ -105,6 +105,15 @@
     challenge->performDefaultHandling();
 }
 
+void ServiceWorkerProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
+{
+    WebProcessProxy::didFinishLaunching(launcher, connectionIdentifier);
+
+    // Prevent App Nap for Service Worker processes.
+    // FIXME: Ideally, the Service Worker process would app nap when all its clients app nap (http://webkit.org/b/185626).
+    setProcessSuppressionEnabled(false);
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h	2018-05-14 22:31:40 UTC (rev 231771)
@@ -54,6 +54,9 @@
     // ChildProcessProxy
     void getLaunchOptions(ProcessLauncher::LaunchOptions&) final;
 
+    // ProcessLauncher::Client
+    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) final;
+
     bool isServiceWorkerProcess() const final { return true; }
 
     ServiceWorkerProcessProxy(WebProcessPool&, const WebCore::SecurityOriginData&, WebsiteDataStore&);

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (231770 => 231771)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2018-05-14 22:31:40 UTC (rev 231771)
@@ -230,6 +230,9 @@
     void connectionWillOpen(IPC::Connection&) override;
     void processWillShutDown(IPC::Connection&) override;
 
+    // ProcessLauncher::Client
+    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
+
 private:
     // Called when the web process has crashed or we know that it will terminate soon.
     // Will potentially cause the WebProcessProxy object to be freed.
@@ -293,9 +296,6 @@
     void sendProcessDidResume() override;
     void didSetAssertionState(AssertionState) override;
 
-    // ProcessLauncher::Client
-    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
-
     // Implemented in generated WebProcessProxyMessageReceiver.cpp
     void didReceiveWebProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
     void didReceiveSyncWebProcessProxyMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (231770 => 231771)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2018-05-14 22:31:40 UTC (rev 231771)
@@ -1074,7 +1074,6 @@
 		515E7727183DD6F60007203F /* AsyncRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515E7725183DD6F60007203F /* AsyncRequest.cpp */; };
 		515E7728183DD6F60007203F /* AsyncRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E7726183DD6F60007203F /* AsyncRequest.h */; };
 		5160BFE113381DF900918999 /* LoggingFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160BFE013381DF900918999 /* LoggingFoundation.mm */; };
-		516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */; };
 		5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ACC9341628064800342550 /* NetworkProcessMessageReceiver.cpp */; };
 		5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ACC9351628064800342550 /* NetworkProcessMessages.h */; };
 		516A4A5D120A2CCD00C05B7F /* APIError.h in Headers */ = {isa = PBXBuildFile; fileRef = 516A4A5B120A2CCD00C05B7F /* APIError.h */; };
@@ -2072,7 +2071,6 @@
 		CDA29A2B1CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A271CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h */; };
 		CDC2831D201BD79D00E6E745 /* WKFullscreenStackView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */; };
 		CDC2831E201BD79D00E6E745 /* WKFullscreenStackView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */; };
-		CDC382FE17211799008A2FC3 /* SecItemShimLibrary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 511F8A78138B460900A95F44 /* SecItemShimLibrary.mm */; };
 		CDCA85C8132ABA4E00E961DF /* WKFullScreenWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */; };
 		CDCA85C9132ABA4E00E961DF /* WKFullScreenWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */; };
 		CE11AD501CBC47F800681EE5 /* CodeSigning.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE11AD4F1CBC47F800681EE5 /* CodeSigning.mm */; };
@@ -3489,7 +3487,6 @@
 		515E7725183DD6F60007203F /* AsyncRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncRequest.cpp; sourceTree = "<group>"; };
 		515E7726183DD6F60007203F /* AsyncRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncRequest.h; sourceTree = "<group>"; };
 		5160BFE013381DF900918999 /* LoggingFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingFoundation.mm; sourceTree = "<group>"; };
-		516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessProxyMac.mm; path = mac/NetworkProcessProxyMac.mm; sourceTree = "<group>"; };
 		5164C0941B05B757004F102A /* ChildProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChildProcess.messages.in; sourceTree = "<group>"; };
 		516A4A5B120A2CCD00C05B7F /* APIError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIError.h; sourceTree = "<group>"; };
 		517A33B3130B308C00F80CB5 /* WKApplicationCacheManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKApplicationCacheManager.cpp; sourceTree = "<group>"; };
@@ -4605,7 +4602,6 @@
 		CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKFullscreenStackView.h; path = ios/fullscreen/WKFullscreenStackView.h; sourceTree = "<group>"; };
 		CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFullscreenStackView.mm; path = ios/fullscreen/WKFullscreenStackView.mm; sourceTree = "<group>"; };
 		CDC382F717211506008A2FC3 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = /System/Library/Frameworks/CFNetwork.framework; sourceTree = "<absolute>"; };
-		CDC3830617211799008A2FC3 /* WebProcessShim.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = WebProcessShim.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDC8F4881725E67800166F6E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
 		CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFullScreenWindowController.mm; sourceTree = "<group>"; };
 		CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFullScreenWindowController.h; sourceTree = "<group>"; };
@@ -6589,7 +6585,6 @@
 		516319931628980E00E22F00 /* mac */ = {
 			isa = PBXGroup;
 			children = (
-				516319911628980A00E22F00 /* NetworkProcessProxyMac.mm */,
 			);
 			name = mac;
 			sourceTree = "<group>";
@@ -10704,7 +10699,6 @@
 				5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */,
 				E14A954916E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp in Sources */,
 				5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */,
-				516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */,
 				513A163C163088F6005D7D22 /* NetworkProcessProxyMessageReceiver.cpp in Sources */,
 				51FD18B51651FBAD00DBE1CE /* NetworkResourceLoader.cpp in Sources */,
 				E152551A17011819003D7ADB /* NetworkResourceLoaderMessageReceiver.cpp in Sources */,
@@ -11450,14 +11444,6 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
-		CDC382FD17211799008A2FC3 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				CDC382FE17211799008A2FC3 /* SecItemShimLibrary.mm in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (231770 => 231771)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-05-14 22:14:40 UTC (rev 231770)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2018-05-14 22:31:40 UTC (rev 231771)
@@ -84,7 +84,6 @@
     DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins) -> ()
 
     SetHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds)
-    SetProcessSuppressionEnabled(bool flag)
 #if PLATFORM(COCOA)
     SetQOS(int latencyQOS, int throughputQOS)
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to