REGRESSION(r223718): Leaking WebProcessPool after reconfiguration
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 23:02:16 +0000 (23:02 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 23:02:16 +0000 (23:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179123
<rdar://problem/35294685>

Reviewed by Geoffrey Garen.

Make sure we destroy the ServiceWorker WebProcess once all other WebProcesses
go away at there is no use keeping it running at this point. Also, this prevents
leaking the WebProcessPool since the WebProcessProxy holds a strong reference
to the WebProcessPool.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::disconnectProcess):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224438 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp

index a9b26e0..a85272e 100644 (file)
@@ -1,3 +1,19 @@
+2017-11-03  Chris Dumez  <cdumez@apple.com>
+
+        REGRESSION(r223718): Leaking WebProcessPool after reconfiguration
+        https://bugs.webkit.org/show_bug.cgi?id=179123
+        <rdar://problem/35294685>
+
+        Reviewed by Geoffrey Garen.
+
+        Make sure we destroy the ServiceWorker WebProcess once all other WebProcesses
+        go away at there is no use keeping it running at this point. Also, this prevents
+        leaking the WebProcessPool since the WebProcessProxy holds a strong reference
+        to the WebProcessPool.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::disconnectProcess):
+
 2017-11-03  Youenn Fablet  <youenn@apple.com>
 
         Implement Service Worker Matching Registration algorithm
index 44a4d65..199d1cb 100644 (file)
@@ -76,8 +76,16 @@ bool StorageProcess::shouldTerminate()
     return true;
 }
 
-void StorageProcess::didClose(IPC::Connection&)
+void StorageProcess::didClose(IPC::Connection& connection)
 {
+#if ENABLE(SERVICE_WORKER)
+    if (m_workerContextProcessConnection == &connection) {
+        m_workerContextProcessConnection = nullptr;
+        return;
+    }
+#else
+    UNUSED_PARAM(connection);
+#endif
     stopRunLoop();
 }
 
index 801764e..99e2c44 100644 (file)
@@ -935,6 +935,15 @@ void WebProcessPool::disconnectProcess(WebProcessProxy* process)
     if (m_processesUsingGamepads.contains(process))
         processStoppedUsingGamepads(*process);
 #endif
+
+#if ENABLE(SERVICE_WORKER)
+    // FIXME: We should do better than this. For now, we just destroy the ServiceWorker process
+    // whenever there is no regular WebContent process remaining.
+    if (m_processes.size() == 1 && m_processes[0] == m_serviceWorkerProcess) {
+        m_serviceWorkerProcess = nullptr;
+        m_processes.clear();
+    }
+#endif
 }
 
 WebProcessProxy& WebProcessPool::createNewWebProcessRespectingProcessCountLimit(WebsiteDataStore& websiteDataStore)