Title: [248063] branches/safari-608-branch/Source/WebKit
- Revision
- 248063
- Author
- [email protected]
- Date
- 2019-07-31 13:56:31 -0700 (Wed, 31 Jul 2019)
Log Message
Cherry-pick r247933. rdar://problem/53764069
Try fixing crash at com.apple.WebKit.Networking: NetworkProcess::setSharedHTTPCookieStorage
https://bugs.webkit.org/show_bug.cgi?id=200189
<rdar://problem/41325767>
Reviewed by Chris Dumez.
The crash indicates that sharedCookieStorage is accessed before being set in network process.
sharedCookieStorage is set during the processing of InitializeNetworkProcess message, and access to
sharedCookieStorage is supposed to happen after that. Therefore, it is likely some message is received and
handled before InitializeNetworkProcess.
One possible explanation is WebKit APIs get called on different threads. Because of the race in checking and
setting m_networkProcess, some message is sent between network process gets launched (m_networkProcess is set)
and InitializeNetworkProcess message is sent. To mitigate this issue, we make sure m_networkProcess is set only
in the main runloop and only after InitializeNetworkProcess is sent.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureNetworkProcess):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248062 => 248063)
--- branches/safari-608-branch/Source/WebKit/ChangeLog 2019-07-31 20:56:28 UTC (rev 248062)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog 2019-07-31 20:56:31 UTC (rev 248063)
@@ -1,5 +1,52 @@
2019-07-31 Alan Coon <[email protected]>
+ Cherry-pick r247933. rdar://problem/53764069
+
+ Try fixing crash at com.apple.WebKit.Networking: NetworkProcess::setSharedHTTPCookieStorage
+ https://bugs.webkit.org/show_bug.cgi?id=200189
+ <rdar://problem/41325767>
+
+ Reviewed by Chris Dumez.
+
+ The crash indicates that sharedCookieStorage is accessed before being set in network process.
+ sharedCookieStorage is set during the processing of InitializeNetworkProcess message, and access to
+ sharedCookieStorage is supposed to happen after that. Therefore, it is likely some message is received and
+ handled before InitializeNetworkProcess.
+
+ One possible explanation is WebKit APIs get called on different threads. Because of the race in checking and
+ setting m_networkProcess, some message is sent between network process gets launched (m_networkProcess is set)
+ and InitializeNetworkProcess message is sent. To mitigate this issue, we make sure m_networkProcess is set only
+ in the main runloop and only after InitializeNetworkProcess is sent.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::ensureNetworkProcess):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-29 Sihui Liu <[email protected]>
+
+ Try fixing crash at com.apple.WebKit.Networking: NetworkProcess::setSharedHTTPCookieStorage
+ https://bugs.webkit.org/show_bug.cgi?id=200189
+ <rdar://problem/41325767>
+
+ Reviewed by Chris Dumez.
+
+ The crash indicates that sharedCookieStorage is accessed before being set in network process.
+ sharedCookieStorage is set during the processing of InitializeNetworkProcess message, and access to
+ sharedCookieStorage is supposed to happen after that. Therefore, it is likely some message is received and
+ handled before InitializeNetworkProcess.
+
+ One possible explanation is WebKit APIs get called on different threads. Because of the race in checking and
+ setting m_networkProcess, some message is sent between network process gets launched (m_networkProcess is set)
+ and InitializeNetworkProcess message is sent. To mitigate this issue, we make sure m_networkProcess is set only
+ in the main runloop and only after InitializeNetworkProcess is sent.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::ensureNetworkProcess):
+
+2019-07-31 Alan Coon <[email protected]>
+
Cherry-pick r247923. rdar://problem/53764209
REGRESSION: WebSockets no longer work in Service Workers
Modified: branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (248062 => 248063)
--- branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-07-31 20:56:28 UTC (rev 248062)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2019-07-31 20:56:31 UTC (rev 248063)
@@ -473,6 +473,18 @@
NetworkProcessProxy& WebProcessPool::ensureNetworkProcess(WebsiteDataStore* withWebsiteDataStore)
{
+ ASSERT(RunLoop::isMain());
+
+ // FIXME: This is a temporary workaround for apps using WebKit API on non-main threads.
+ // We should remove this once we enforce threading violation check on our APIs.
+ // https://bugs.webkit.org/show_bug.cgi?id=200246.
+ if (!RunLoop::isMain()) {
+ callOnMainRunLoopAndWait([this, protectedThis = makeRef(*this)] {
+ ensureNetworkProcess();
+ });
+ return *m_networkProcess;
+ }
+
if (m_networkProcess) {
if (withWebsiteDataStore) {
m_networkProcess->addSession(makeRef(*withWebsiteDataStore));
@@ -481,7 +493,7 @@
return *m_networkProcess;
}
- m_networkProcess = std::make_unique<NetworkProcessProxy>(*this);
+ auto networkProcess = std::make_unique<NetworkProcessProxy>(*this);
NetworkProcessCreationParameters parameters;
@@ -553,7 +565,7 @@
parameters.defaultDataStoreParameters.indexedDatabaseDirectory = API::WebsiteDataStore::defaultDataStore()->websiteDataStore().parameters().indexedDatabaseDirectory;
SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.indexedDatabaseDirectory, parameters.defaultDataStoreParameters.indexedDatabaseDirectoryExtensionHandle);
- m_networkProcess->createSymLinkForFileUpgrade(parameters.defaultDataStoreParameters.indexedDatabaseDirectory);
+ networkProcess->createSymLinkForFileUpgrade(parameters.defaultDataStoreParameters.indexedDatabaseDirectory);
#endif
#if ENABLE(SERVICE_WORKER)
@@ -619,22 +631,22 @@
platformInitializeNetworkProcess(parameters);
// Initialize the network process.
- m_networkProcess->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
+ networkProcess->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
if (WebPreferences::anyPagesAreUsingPrivateBrowsing())
- m_networkProcess->send(Messages::NetworkProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::legacyPrivateSessionParameters()), 0);
+ networkProcess->send(Messages::NetworkProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::legacyPrivateSessionParameters()), 0);
#if PLATFORM(COCOA)
- m_networkProcess->send(Messages::NetworkProcess::SetQOS(networkProcessLatencyQOS(), networkProcessThroughputQOS()), 0);
+ networkProcess->send(Messages::NetworkProcess::SetQOS(networkProcessLatencyQOS(), networkProcessThroughputQOS()), 0);
#endif
if (m_didNetworkProcessCrash) {
m_didNetworkProcessCrash = false;
- reinstateNetworkProcessAssertionState(*m_networkProcess);
+ reinstateNetworkProcessAssertionState(*networkProcess);
}
if (withWebsiteDataStore) {
- m_networkProcess->addSession(makeRef(*withWebsiteDataStore));
+ networkProcess->addSession(makeRef(*withWebsiteDataStore));
withWebsiteDataStore->clearPendingCookies();
}
@@ -641,9 +653,10 @@
// Make sure the network process knows about all the sessions that have been registered before it started.
for (auto& sessionID : m_sessionToPageIDsMap.keys()) {
if (auto* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID))
- m_networkProcess->addSession(*websiteDataStore);
+ networkProcess->addSession(*websiteDataStore);
}
+ m_networkProcess = WTFMove(networkProcess);
return *m_networkProcess;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes