Title: [223713] trunk/Source/WebKit
Revision
223713
Author
cdu...@apple.com
Date
2017-10-19 14:31:17 -0700 (Thu, 19 Oct 2017)

Log Message

Service Worker process should not be selected to open WebView on it
https://bugs.webkit.org/show_bug.cgi?id=178527

Patch by Youenn Fablet <you...@apple.com> on 2017-10-19
Reviewed by Chris Dumez.

Selection of process to open a page will no longer use an existing web process if it is the service worker process.

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (223712 => 223713)


--- trunk/Source/WebKit/ChangeLog	2017-10-19 21:23:13 UTC (rev 223712)
+++ trunk/Source/WebKit/ChangeLog	2017-10-19 21:31:17 UTC (rev 223713)
@@ -1,3 +1,15 @@
+2017-10-19  Youenn Fablet  <you...@apple.com>
+
+        Service Worker process should not be selected to open WebView on it
+        https://bugs.webkit.org/show_bug.cgi?id=178527
+
+        Reviewed by Chris Dumez.
+
+        Selection of process to open a page will no longer use an existing web process if it is the service worker process.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::createNewWebProcessRespectingProcessCountLimit):
+
 2017-10-19  Tim Horton  <timothy_hor...@apple.com>
 
         Display link bringup can block the main thread for ~150ms during WKWebView init

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (223712 => 223713)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2017-10-19 21:23:13 UTC (rev 223712)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2017-10-19 21:31:17 UTC (rev 223713)
@@ -937,25 +937,19 @@
     if (m_processes.size() < maximumNumberOfProcesses())
         return createNewWebProcess(websiteDataStore);
 
-    Vector<RefPtr<WebProcessProxy>> processesMatchingDataStore;
-    if (mustMatchDataStore) {
-        for (auto& process : m_processes) {
-            if (&process->websiteDataStore() == &websiteDataStore)
-                processesMatchingDataStore.append(process);
-        }
-
-        if (processesMatchingDataStore.isEmpty())
-            return createNewWebProcess(websiteDataStore);
+    WebProcessProxy* processToReuse = nullptr;
+    for (auto& process : m_processes) {
+        if (mustMatchDataStore && &process->websiteDataStore() != &websiteDataStore)
+            continue;
+#if ENABLE(SERVICE_WORKER)
+        if (process.get() == m_workerContextProcess)
+            continue;
+#endif
+        // Choose the process with fewest pages.
+        if (!processToReuse || processToReuse->pageCount() > process->pageCount())
+            processToReuse = process.get();
     }
-
-    // Choose the process with fewest pages.
-    auto* processes = mustMatchDataStore ? &processesMatchingDataStore : &m_processes;
-    ASSERT(!processes->isEmpty());
-    auto& process = *std::min_element(processes->begin(), processes->end(), [](const RefPtr<WebProcessProxy>& a, const RefPtr<WebProcessProxy>& b) {
-        return a->pageCount() < b->pageCount();
-    });
-
-    return *process;
+    return processToReuse ? *processToReuse : createNewWebProcess(websiteDataStore);
 }
 
 Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to