- Revision
- 187129
- Author
- dba...@webkit.org
- Date
- 2015-07-21 15:33:53 -0700 (Tue, 21 Jul 2015)
Log Message
WTFCrash() in WebKit::WebProcess::networkConnection()
https://bugs.webkit.org/show_bug.cgi?id=147112
<rdar://problem/18477459>
Reviewed by Gavin Barraclough.
Source/WebKit2:
Fixes an issue where a newly launched network process may be jetsam'd because it has not
taken a process assertion between the time it was launched and the time when a web process
makes use of it.
Initially a network process does not have a process assertion. A process assertion is taken
(if one has not been taken) for the network process when a process assertion is taken for at
least one web process. When the network process crashes a WebProcess may ultimately launch a
new network process in WebProcess::networkConnection(). The new network process may be jetsam'd
immediately when the system is under some measure pressure because it has a low jetsam priority,
0 (since it does not have a process assertion and higher priority implies that a process is less
likely to be jetsam'd). And the logic in WebProcess::networkConnection() explicitly calls
CRASH() if the newly launched network process crashes immediately. Towards preventing the newly
launched network process from being jetsam'd we should obtain a process assertion for it.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::WebProcessPool): Initialize m_didNetworkProcessCrash to false.
(WebKit::WebProcessPool::ensureNetworkProcess): If the network process crashed (m_didNetworkProcessCrash == true)
then tell each process in the pool to reinstate their network activity token for the new network process.
(WebKit::WebProcessPool::networkProcessCrashed): Set m_didNetworkProcessCrash to true when the
network process crashed.
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::reinstateNetworkProcessAssertionState): Added.
(WebKit::WebProcessProxy::didSetAssertionState): Add assert to ensure we never have both
a background- and foreground- activity token for the network process.
* UIProcess/WebProcessProxy.h:
Source/WTF:
Add explicit boolean conversion function and remove overload of operator! to support
checking whether an activity token is valid more directly than using the overloaded operator!.
* wtf/RefCounter.h:
(WTF::RefCounter::Token::operator bool): Added.
(WTF::RefCounter::Token::operator!): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (187128 => 187129)
--- trunk/Source/WTF/ChangeLog 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WTF/ChangeLog 2015-07-21 22:33:53 UTC (rev 187129)
@@ -1,3 +1,18 @@
+2015-07-21 Daniel Bates <daba...@apple.com>
+
+ WTFCrash() in WebKit::WebProcess::networkConnection()
+ https://bugs.webkit.org/show_bug.cgi?id=147112
+ <rdar://problem/18477459>
+
+ Reviewed by Gavin Barraclough.
+
+ Add explicit boolean conversion function and remove overload of operator! to support
+ checking whether an activity token is valid more directly than using the overloaded operator!.
+
+ * wtf/RefCounter.h:
+ (WTF::RefCounter::Token::operator bool): Added.
+ (WTF::RefCounter::Token::operator!): Deleted.
+
2015-07-20 Mark Lam <mark....@apple.com>
Rollout r187020 and r187021: breaks JSC API tests on debug builds.
Modified: trunk/Source/WTF/wtf/RefCounter.h (187128 => 187129)
--- trunk/Source/WTF/wtf/RefCounter.h 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WTF/wtf/RefCounter.h 2015-07-21 22:33:53 UTC (rev 187129)
@@ -67,7 +67,7 @@
inline Token<T>& operator=(const Token<T>&);
inline Token<T>& operator=(Token<T>&&);
- bool operator!() const { return !m_ptr; }
+ explicit operator bool() const { return m_ptr; }
private:
friend class RefCounter;
Modified: trunk/Source/WebKit2/ChangeLog (187128 => 187129)
--- trunk/Source/WebKit2/ChangeLog 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WebKit2/ChangeLog 2015-07-21 22:33:53 UTC (rev 187129)
@@ -1,5 +1,40 @@
2015-07-21 Daniel Bates <daba...@apple.com>
+ WTFCrash() in WebKit::WebProcess::networkConnection()
+ https://bugs.webkit.org/show_bug.cgi?id=147112
+ <rdar://problem/18477459>
+
+ Reviewed by Gavin Barraclough.
+
+ Fixes an issue where a newly launched network process may be jetsam'd because it has not
+ taken a process assertion between the time it was launched and the time when a web process
+ makes use of it.
+
+ Initially a network process does not have a process assertion. A process assertion is taken
+ (if one has not been taken) for the network process when a process assertion is taken for at
+ least one web process. When the network process crashes a WebProcess may ultimately launch a
+ new network process in WebProcess::networkConnection(). The new network process may be jetsam'd
+ immediately when the system is under some measure pressure because it has a low jetsam priority,
+ 0 (since it does not have a process assertion and higher priority implies that a process is less
+ likely to be jetsam'd). And the logic in WebProcess::networkConnection() explicitly calls
+ CRASH() if the newly launched network process crashes immediately. Towards preventing the newly
+ launched network process from being jetsam'd we should obtain a process assertion for it.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::WebProcessPool): Initialize m_didNetworkProcessCrash to false.
+ (WebKit::WebProcessPool::ensureNetworkProcess): If the network process crashed (m_didNetworkProcessCrash == true)
+ then tell each process in the pool to reinstate their network activity token for the new network process.
+ (WebKit::WebProcessPool::networkProcessCrashed): Set m_didNetworkProcessCrash to true when the
+ network process crashed.
+ * UIProcess/WebProcessPool.h:
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::reinstateNetworkProcessAssertionState): Added.
+ (WebKit::WebProcessProxy::didSetAssertionState): Add assert to ensure we never have both
+ a background- and foreground- activity token for the network process.
+ * UIProcess/WebProcessProxy.h:
+
+2015-07-21 Daniel Bates <daba...@apple.com>
+
ASSERT(m_suspendMessageCount >= 0) fails in ProcessThrottler::didCancelProcessSuspension()
when WebContent process crashes; Network process may never voluntarily suspend
https://bugs.webkit.org/show_bug.cgi?id=147122
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (187128 => 187129)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2015-07-21 22:33:53 UTC (rev 187129)
@@ -160,6 +160,7 @@
, m_processTerminationEnabled(true)
#if ENABLE(NETWORK_PROCESS)
, m_canHandleHTTPSServerTrustEvaluation(true)
+ , m_didNetworkProcessCrash(false)
#endif
#if USE(SOUP)
, m_ignoreTLSErrors(true)
@@ -419,6 +420,12 @@
m_networkProcess->send(Messages::NetworkProcess::SetQOS(networkProcessLatencyQOS(), networkProcessThroughputQOS()), 0);
#endif
+ if (m_didNetworkProcessCrash) {
+ m_didNetworkProcessCrash = false;
+ for (auto& process : m_processes)
+ process->reinstateNetworkProcessAssertionState(*m_networkProcess);
+ }
+
return *m_networkProcess;
}
@@ -426,6 +433,7 @@
{
ASSERT(m_networkProcess);
ASSERT(networkProcessProxy == m_networkProcess.get());
+ m_didNetworkProcessCrash = true;
WebContextSupplementMap::const_iterator it = m_supplements.begin();
WebContextSupplementMap::const_iterator end = m_supplements.end();
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (187128 => 187129)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h 2015-07-21 22:33:53 UTC (rev 187129)
@@ -498,6 +498,7 @@
#if ENABLE(NETWORK_PROCESS)
bool m_canHandleHTTPSServerTrustEvaluation;
+ bool m_didNetworkProcessCrash;
RefPtr<NetworkProcessProxy> m_networkProcess;
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (187128 => 187129)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-07-21 22:33:53 UTC (rev 187129)
@@ -925,9 +925,24 @@
m_throttler.didCancelProcessSuspension();
}
+#if ENABLE(NETWORK_PROCESS)
+void WebProcessProxy::reinstateNetworkProcessAssertionState(NetworkProcessProxy& newNetworkProcessProxy)
+{
+ ASSERT(!m_backgroundTokenForNetworkProcess || !m_foregroundTokenForNetworkProcess);
+
+ // The network process crashed; take new tokens for the new network process.
+ if (m_backgroundTokenForNetworkProcess)
+ m_backgroundTokenForNetworkProcess = newNetworkProcessProxy.throttler().backgroundActivityToken();
+ else if (m_foregroundTokenForNetworkProcess)
+ m_foregroundTokenForNetworkProcess = newNetworkProcessProxy.throttler().foregroundActivityToken();
+}
+#endif
+
void WebProcessProxy::didSetAssertionState(AssertionState state)
{
#if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS)
+ ASSERT(!m_backgroundTokenForNetworkProcess || !m_foregroundTokenForNetworkProcess);
+
switch (state) {
case AssertionState::Suspended:
m_foregroundTokenForNetworkProcess = nullptr;
@@ -950,6 +965,8 @@
page->processWillBecomeForeground();
break;
}
+
+ ASSERT(!m_backgroundTokenForNetworkProcess || !m_foregroundTokenForNetworkProcess);
#else
UNUSED_PARAM(state);
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (187128 => 187129)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2015-07-21 22:16:16 UTC (rev 187128)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2015-07-21 22:33:53 UTC (rev 187129)
@@ -59,6 +59,7 @@
namespace WebKit {
class DownloadProxyMap;
+class NetworkProcessProxy;
class WebBackForwardListItem;
class WebPageGroup;
class WebProcessPool;
@@ -150,6 +151,10 @@
ProcessThrottler& throttler() { return m_throttler; }
+#if ENABLE(NETWORK_PROCESS)
+ void reinstateNetworkProcessAssertionState(NetworkProcessProxy&);
+#endif
+
private:
explicit WebProcessProxy(WebProcessPool&);