Add assertions to help diagnose crash at WebProcessProxy::processPool()
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 May 2019 19:50:54 +0000 (19:50 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 May 2019 19:50:54 +0000 (19:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197856
<rdar://problem/49341366>

Reviewed by Chris Dumez.

* UIProcess/WebProcessCache.cpp:
(WebKit::WebProcessCache::CachedProcess::CachedProcess):
* UIProcess/WebProcessLifetimeObserver.cpp:
(WebKit::WebProcessLifetimeObserver::addWebPage):
(WebKit::WebProcessLifetimeObserver::removeWebPage):
* UIProcess/WebProcessLifetimeObserver.h:
(WebKit::WebProcessLifetimeObserver::hasProcess const):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebProcessCache.cpp
Source/WebKit/UIProcess/WebProcessLifetimeObserver.cpp
Source/WebKit/UIProcess/WebProcessLifetimeObserver.h

index d154f67..10205c8 100644 (file)
@@ -1,3 +1,19 @@
+2019-05-15  Sihui Liu  <sihui_liu@apple.com>
+
+        Add assertions to help diagnose crash at WebProcessProxy::processPool()
+        https://bugs.webkit.org/show_bug.cgi?id=197856
+        <rdar://problem/49341366>
+
+        Reviewed by Chris Dumez.
+
+        * UIProcess/WebProcessCache.cpp:
+        (WebKit::WebProcessCache::CachedProcess::CachedProcess):
+        * UIProcess/WebProcessLifetimeObserver.cpp:
+        (WebKit::WebProcessLifetimeObserver::addWebPage):
+        (WebKit::WebProcessLifetimeObserver::removeWebPage):
+        * UIProcess/WebProcessLifetimeObserver.h:
+        (WebKit::WebProcessLifetimeObserver::hasProcess const):
+
 2019-05-15  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         inputmode="numeric" should show a number pad with digits 0-9, instead of the numeric keyplane
index 797d7e5..88177b1 100644 (file)
@@ -246,6 +246,8 @@ WebProcessCache::CachedProcess::CachedProcess(Ref<WebProcessProxy>&& process)
     : m_process(WTFMove(process))
     , m_evictionTimer(RunLoop::main(), this, &CachedProcess::evictionTimerFired)
 {
+    RELEASE_ASSERT(!m_process->pageCount());
+    RELEASE_ASSERT_WITH_MESSAGE(!m_process->websiteDataStore().hasProcess(process.ptr()), "Only processes with pages should be registered with the data store");
     m_process->setIsInProcessCache(true);
     m_evictionTimer.startOneShot(cachedProcessLifetime);
 }
index 3d75abd..c8023de 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebProcessLifetimeObserver.h"
 
+#include "Logging.h"
 #include "WebPageProxy.h"
 #include "WebProcessProxy.h"
 
@@ -42,9 +43,13 @@ WebProcessLifetimeObserver::~WebProcessLifetimeObserver()
 void WebProcessLifetimeObserver::addWebPage(WebPageProxy& webPageProxy, WebProcessProxy& process)
 {
     ASSERT(process.state() == WebProcessProxy::State::Running);
+    RELEASE_ASSERT(!process.isInProcessCache());
+    RELEASE_ASSERT(!process.isPrewarmed());
 
-    if (m_processes.add(&process).isNewEntry)
+    if (m_processes.add(&process).isNewEntry) {
+        RELEASE_LOG(Loading, "%p - WebProcessLifetimeObserver::addWebPage: webPID = %i, pageID = %" PRIu64, this, process.processIdentifier(), webPageProxy.pageID());
         webProcessWillOpenConnection(process, *process.connection());
+    }
 
     webPageWillOpenConnection(webPageProxy, *process.connection());
 }
@@ -57,8 +62,10 @@ void WebProcessLifetimeObserver::removeWebPage(WebPageProxy& webPageProxy, WebPr
 
     webPageDidCloseConnection(webPageProxy, *process.connection());
 
-    if (m_processes.remove(&process))
+    if (m_processes.remove(&process)) {
+        RELEASE_LOG(Loading, "%p - WebProcessLifetimeObserver::removeWebPage: webPID = %i, pageID = %" PRIu64, this, process.processIdentifier(), webPageProxy.pageID());
         webProcessDidCloseConnection(process, *process.connection());
+    }
 }
 
 WTF::IteratorRange<HashCountedSet<WebProcessProxy*>::const_iterator::Keys> WebProcessLifetimeObserver::processes() const
index 61ce22b..6693973 100644 (file)
@@ -48,6 +48,8 @@ public:
 
     WTF::IteratorRange<HashCountedSet<WebProcessProxy*>::const_iterator::Keys> processes() const;
 
+    bool hasProcess(WebProcessProxy* process) const { return m_processes.contains(process); }
+
 private:
     friend class WebProcessLifetimeTracker;