Title: [247822] trunk
Revision
247822
Author
[email protected]
Date
2019-07-25 08:42:11 -0700 (Thu, 25 Jul 2019)

Log Message

Avoid UI Process hangs when the WebContent process is showing JS prompts / alerts
https://bugs.webkit.org/show_bug.cgi?id=200107
<rdar://problem/53034592>

Reviewed by Geoffrey Garen.

Source/WebCore:

Add testing infrastructure for SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply.

Test: fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html

* page/ChromeClient.h:
* testing/Internals.cpp:
(WebCore::Internals::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

* Platform/IPC/Connection.cpp:
(IPC::Connection::SyncMessageState::incrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount):
(IPC::Connection::SyncMessageState::decrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount):
(IPC::Connection::SyncMessageState::processIncomingMessage):
(IPC::Connection::sendSyncMessage):
* Platform/IPC/Connection.h:
Add support for new SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply flag
to allow processing incoming sync messages while sending a particular sync IPC. This is the
default behavior in all processes except in the WebContent process, where we try to avoid
re-entering to prevent bugs. This flag allows the WebContent process to change its default
behavior for some specific IPCs, where we know it is safe to re-enter and where it benefits
performance to re-renter.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didReceiveSyncMessage):
(WebKit::NetworkProcessProxy::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::sendSyncWithDelayedReply):
* WebProcess/WebPage/WebPage.messages.in:
SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply
Add testing infrastructure for SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply
flag.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::runJavaScriptAlert):
(WebKit::WebChromeClient::runJavaScriptConfirm):
(WebKit::WebChromeClient::runJavaScriptPrompt):
Use new SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply flag when sending
the synchronous IPC for JS alerts / prompt / confirm. This allows the WebProcess to process
incoming synchronous IPC for other processes (in particular the UIProcess) while it is blocked
on those synchronous IPCs. It is safe to re-enter the WebContent process on these sync IPCs
since they are triggered by JS and we return to JS right after. This should avoid UIProcess
hangs when the UIProcess is sending a sync IPC to the WebContent process, which is itself
stuck on the sync IPC to show a JS alert.

LayoutTests:

Add layout test coverage for SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply.
Without the flag on the sendSync from the WebContent process of the
NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply IPC, the
test would hang. This is because the WebContent process sends a sync IPC to the network process,
which in turns sends one to the UIProcess, which itself sends one back to the WebContent process.
This would attempt to re-enter the WebContent process which is currently sending a sync IPC, which
is not allowed by default.

* fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt: Added.
* fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (247821 => 247822)


--- trunk/LayoutTests/ChangeLog	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/LayoutTests/ChangeLog	2019-07-25 15:42:11 UTC (rev 247822)
@@ -1,3 +1,22 @@
+2019-07-25  Chris Dumez  <[email protected]>
+
+        Avoid UI Process hangs when the WebContent process is showing JS prompts / alerts
+        https://bugs.webkit.org/show_bug.cgi?id=200107
+        <rdar://problem/53034592>
+
+        Reviewed by Geoffrey Garen.
+
+        Add layout test coverage for SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply.
+        Without the flag on the sendSync from the WebContent process of the
+        NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply IPC, the
+        test would hang. This is because the WebContent process sends a sync IPC to the network process,
+        which in turns sends one to the UIProcess, which itself sends one back to the WebContent process.
+        This would attempt to re-enter the WebContent process which is currently sending a sync IPC, which
+        is not allowed by default.
+
+        * fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt: Added.
+        * fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html: Added.
+
 2019-07-25  Rob Buis  <[email protected]>
 
         Make storing cross-origin top-level prefetches in HTTP cache optional

Added: trunk/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt (0 => 247822)


--- trunk/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt	2019-07-25 15:42:11 UTC (rev 247822)
@@ -0,0 +1,10 @@
+Test for the SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply sendSync flag
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.testProcessIncomingSyncMessagesWhenWaitingForSyncReply() is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html (0 => 247822)


--- trunk/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html	                        (rev 0)
+++ trunk/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html	2019-07-25 15:42:11 UTC (rev 247822)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test for the SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply sendSync flag");
+
+shouldBeTrue("internals.testProcessIncomingSyncMessagesWhenWaitingForSyncReply()");
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (247821 => 247822)


--- trunk/Source/WebCore/ChangeLog	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebCore/ChangeLog	2019-07-25 15:42:11 UTC (rev 247822)
@@ -1,3 +1,21 @@
+2019-07-25  Chris Dumez  <[email protected]>
+
+        Avoid UI Process hangs when the WebContent process is showing JS prompts / alerts
+        https://bugs.webkit.org/show_bug.cgi?id=200107
+        <rdar://problem/53034592>
+
+        Reviewed by Geoffrey Garen.
+
+        Add testing infrastructure for SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply.
+
+        Test: fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html
+
+        * page/ChromeClient.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-07-25  Rob Buis  <[email protected]>
 
         Make storing cross-origin top-level prefetches in HTTP cache optional

Modified: trunk/Source/WebCore/page/ChromeClient.h (247821 => 247822)


--- trunk/Source/WebCore/page/ChromeClient.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebCore/page/ChromeClient.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -381,6 +381,8 @@
     virtual void assistiveTechnologyMakeFirstResponder() { }
 #endif
 
+    virtual bool testProcessIncomingSyncMessagesWhenWaitingForSyncReply() { return true; }
+
 #if PLATFORM(IOS_FAMILY)
     // FIXME: Come up with a more descriptive name for this function and make it platform independent (if possible).
     virtual bool isStopping() = 0;

Modified: trunk/Source/WebCore/testing/Internals.cpp (247821 => 247822)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-07-25 15:42:11 UTC (rev 247822)
@@ -2275,6 +2275,13 @@
 #endif
 }
 
+bool Internals::testProcessIncomingSyncMessagesWhenWaitingForSyncReply()
+{
+    ASSERT(contextDocument());
+    ASSERT(contextDocument()->page());
+    return contextDocument()->page()->chrome().client().testProcessIncomingSyncMessagesWhenWaitingForSyncReply();
+}
+
 void Internals::setAutomaticDashSubstitutionEnabled(bool enabled)
 {
     if (!contextDocument() || !contextDocument()->frame())

Modified: trunk/Source/WebCore/testing/Internals.h (247821 => 247822)


--- trunk/Source/WebCore/testing/Internals.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebCore/testing/Internals.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -331,6 +331,8 @@
     bool isOverwriteModeEnabled();
     void toggleOverwriteModeEnabled();
 
+    bool testProcessIncomingSyncMessagesWhenWaitingForSyncReply();
+
     ExceptionOr<RefPtr<Range>> rangeOfString(const String&, RefPtr<Range>&&, const Vector<String>& findOptions);
     ExceptionOr<unsigned> countMatchesForText(const String&, const Vector<String>& findOptions, const String& markMatches);
     ExceptionOr<unsigned> countFindMatches(const String&, const Vector<String>& findOptions);

Modified: trunk/Source/WebCore/testing/Internals.idl (247821 => 247822)


--- trunk/Source/WebCore/testing/Internals.idl	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebCore/testing/Internals.idl	2019-07-25 15:42:11 UTC (rev 247822)
@@ -382,6 +382,8 @@
     [MayThrowException] readonly attribute boolean areSVGAnimationsPaused;
     [MayThrowException] double svgAnimationsInterval(SVGSVGElement element);
 
+    boolean testProcessIncomingSyncMessagesWhenWaitingForSyncReply();
+
     // Flags for layerTreeAsText.
     const unsigned short LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1;
     const unsigned short LAYER_TREE_INCLUDES_TILE_CACHES = 2;

Modified: trunk/Source/WebKit/ChangeLog (247821 => 247822)


--- trunk/Source/WebKit/ChangeLog	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/ChangeLog	2019-07-25 15:42:11 UTC (rev 247822)
@@ -1,3 +1,57 @@
+2019-07-25  Chris Dumez  <[email protected]>
+
+        Avoid UI Process hangs when the WebContent process is showing JS prompts / alerts
+        https://bugs.webkit.org/show_bug.cgi?id=200107
+        <rdar://problem/53034592>
+
+        Reviewed by Geoffrey Garen.
+
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::SyncMessageState::incrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount):
+        (IPC::Connection::SyncMessageState::decrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount):
+        (IPC::Connection::SyncMessageState::processIncomingMessage):
+        (IPC::Connection::sendSyncMessage):
+        * Platform/IPC/Connection.h:
+        Add support for new SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply flag
+        to allow processing incoming sync messages while sending a particular sync IPC. This is the
+        default behavior in all processes except in the WebContent process, where we try to avoid
+        re-entering to prevent bugs. This flag allows the WebContent process to change its default
+        behavior for some specific IPCs, where we know it is safe to re-enter and where it benefits
+        performance to re-renter.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didReceiveSyncMessage):
+        (WebKit::NetworkProcessProxy::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::sendSyncWithDelayedReply):
+        * WebProcess/WebPage/WebPage.messages.in:
+        SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply
+        Add testing infrastructure for SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply
+        flag.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::runJavaScriptAlert):
+        (WebKit::WebChromeClient::runJavaScriptConfirm):
+        (WebKit::WebChromeClient::runJavaScriptPrompt):
+        Use new SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply flag when sending
+        the synchronous IPC for JS alerts / prompt / confirm. This allows the WebProcess to process
+        incoming synchronous IPC for other processes (in particular the UIProcess) while it is blocked
+        on those synchronous IPCs. It is safe to re-enter the WebContent process on these sync IPCs
+        since they are triggered by JS and we return to JS right after. This should avoid UIProcess
+        hangs when the UIProcess is sending a sync IPC to the WebContent process, which is itself
+        stuck on the sync IPC to show a JS alert.
+
 2019-07-25  Rob Buis  <[email protected]>
 
         Make storing cross-origin top-level prefetches in HTTP cache optional

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (247821 => 247822)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-07-25 15:42:11 UTC (rev 247822)
@@ -34,6 +34,7 @@
 #include "NetworkProcess.h"
 #include "NetworkProcessConnectionMessages.h"
 #include "NetworkProcessMessages.h"
+#include "NetworkProcessProxyMessages.h"
 #include "NetworkRTCMonitorMessages.h"
 #include "NetworkRTCProviderMessages.h"
 #include "NetworkRTCSocketMessages.h"
@@ -411,6 +412,14 @@
     loader->start();
 }
 
+void NetworkConnectionToWebProcess::testProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebCore::PageIdentifier webPageID, Messages::NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&& reply)
+{
+    bool handled = false;
+    if (!m_networkProcess->parentProcessConnection()->sendSync(Messages::NetworkProcessProxy::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(webPageID), Messages::NetworkProcessProxy::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::Reply(handled), 0))
+        return reply(false);
+    reply(handled);
+}
+
 void NetworkConnectionToWebProcess::loadPing(NetworkResourceLoadParameters&& loadParameters)
 {
     auto completionHandler = [connection = m_connection.copyRef(), identifier = loadParameters.identifier] (const ResourceError& error, const ResourceResponse& response) {

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (247821 => 247822)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -165,6 +165,7 @@
 
     void scheduleResourceLoad(NetworkResourceLoadParameters&&);
     void performSynchronousLoad(NetworkResourceLoadParameters&&, Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply&&);
+    void testProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebCore::PageIdentifier, Messages::NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&&);
     void loadPing(NetworkResourceLoadParameters&&);
     void prefetchDNS(const String&);
     void preconnectTo(uint64_t preconnectionIdentifier, NetworkResourceLoadParameters&&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (247821 => 247822)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2019-07-25 15:42:11 UTC (rev 247822)
@@ -24,6 +24,7 @@
 
     ScheduleResourceLoad(WebKit::NetworkResourceLoadParameters resourceLoadParameters)
     PerformSynchronousLoad(WebKit::NetworkResourceLoadParameters resourceLoadParameters) -> (WebCore::ResourceError error, WebCore::ResourceResponse response, Vector<char> data) Synchronous
+    TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebCore::PageIdentifier webPageID) -> (bool handled) Synchronous
     LoadPing(WebKit::NetworkResourceLoadParameters resourceLoadParameters)
     RemoveLoadIdentifier(uint64_t resourceLoadIdentifier)
     PageLoadCompleted(WebCore::PageIdentifier webPageID)

Modified: trunk/Source/WebKit/Platform/IPC/Connection.cpp (247821 => 247822)


--- trunk/Source/WebKit/Platform/IPC/Connection.cpp	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/Platform/IPC/Connection.cpp	2019-07-25 15:42:11 UTC (rev 247822)
@@ -98,6 +98,9 @@
     // from that connection and put the other messages back in the queue.
     void dispatchMessages(Connection* allowedConnection);
 
+    void incrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount() { ++m_processIncomingSyncMessagesWhenWaitingForSyncReplyCount; }
+    void decrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount() { --m_processIncomingSyncMessagesWhenWaitingForSyncReplyCount; }
+
 private:
     void dispatchMessageAndResetDidScheduleDispatchMessagesForConnection(Connection&);
 
@@ -114,6 +117,8 @@
         std::unique_ptr<Decoder> message;
     };
     Vector<ConnectionAndIncomingMessage> m_messagesToDispatchWhileWaitingForSyncReply;
+
+    std::atomic<unsigned> m_processIncomingSyncMessagesWhenWaitingForSyncReplyCount { 0 };
 };
 
 Connection::SyncMessageState& Connection::SyncMessageState::singleton()
@@ -134,7 +139,16 @@
 
 bool Connection::SyncMessageState::processIncomingMessage(Connection& connection, std::unique_ptr<Decoder>& message)
 {
-    if (!message->shouldDispatchMessageWhenWaitingForSyncReply())
+    bool shouldDispatchMessageWhenWaitingForSyncReply = message->shouldDispatchMessageWhenWaitingForSyncReply();
+
+    // We dispatch synchronous messages even if shouldDispatchMessageWhenWaitingForSyncReply returns false if the
+    // sendSync() used SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply. This is used for some messages
+    // in the WebContent process (which normally does not dispatch messages when waiting for a sync reply), to avoid
+    // hangs.
+    if (!shouldDispatchMessageWhenWaitingForSyncReply && message->isSyncMessage() && m_processIncomingSyncMessagesWhenWaitingForSyncReplyCount.load())
+        shouldDispatchMessageWhenWaitingForSyncReply = true;
+
+    if (!shouldDispatchMessageWhenWaitingForSyncReply)
         return false;
 
     ConnectionAndIncomingMessage connectionAndIncomingMessage { connection, WTFMove(message) };
@@ -565,11 +579,17 @@
     // First send the message.
     sendMessage(WTFMove(encoder), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
 
+    if (sendSyncOptions.contains(SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
+        SyncMessageState::singleton().incrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount();
+
     // Then wait for a reply. Waiting for a reply could involve dispatching incoming sync messages, so
     // keep an extra reference to the connection here in case it's invalidated.
     Ref<Connection> protect(*this);
     std::unique_ptr<Decoder> reply = waitForSyncReply(syncRequestID, timeout, sendSyncOptions);
 
+    if (sendSyncOptions.contains(SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
+        SyncMessageState::singleton().decrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount();
+
     --m_inSendSyncCount;
 
     // Finally, pop the pending sync reply information.

Modified: trunk/Source/WebKit/Platform/IPC/Connection.h (247821 => 247822)


--- trunk/Source/WebKit/Platform/IPC/Connection.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/Platform/IPC/Connection.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -68,6 +68,7 @@
     // Use this to inform that this sync call will suspend this process until the user responds with input.
     InformPlatformProcessWillSuspend = 1 << 0,
     UseFullySynchronousModeForTesting = 1 << 1,
+    ProcessIncomingSyncMessagesWhenWaitingForSyncReply = 1 << 2,
 };
 
 enum class WaitForOption {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (247821 => 247822)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-07-25 15:42:11 UTC (rev 247822)
@@ -40,6 +40,7 @@
 #include "ShouldGrandfatherStatistics.h"
 #include "StorageAccessStatus.h"
 #include "WebCompiledContentRuleList.h"
+#include "WebPageMessages.h"
 #include "WebPageProxy.h"
 #include "WebProcessMessages.h"
 #include "WebProcessPool.h"
@@ -268,7 +269,7 @@
     if (dispatchSyncMessage(connection, decoder, replyEncoder))
         return;
 
-    ASSERT_NOT_REACHED();
+    didReceiveSyncNetworkProcessProxyMessage(connection, decoder, replyEncoder);
 }
 
 void NetworkProcessProxy::didClose(IPC::Connection&)
@@ -1203,6 +1204,18 @@
     m_uploadAssertion = nullptr;
 }
 
+void NetworkProcessProxy::testProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebCore::PageIdentifier webPageID, Messages::NetworkProcessProxy::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&& reply)
+{
+    auto* page = WebProcessProxy::webPage(webPageID);
+    if (!page)
+        return reply(false);
+
+    bool handled = false;
+    if (!page->sendSync(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(), Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::Reply(handled)))
+        return reply(false);
+    reply(handled);
+}
+
 #if ENABLE(INDEXED_DATABASE)
 void NetworkProcessProxy::createSymLinkForFileUpgrade(const String& indexedDatabaseDirectory)
 {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (247821 => 247822)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -163,6 +163,8 @@
     void syncAllCookies();
     void didSyncAllCookies();
 
+    void testProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebCore::PageIdentifier, Messages::NetworkProcessProxy::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&&);
+
     ProcessThrottler& throttler() { return m_throttler; }
     WebProcessPool& processPool() { return m_processPool; }
 
@@ -203,6 +205,7 @@
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
     void didClose(IPC::Connection&) override;
     void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
+    void didReceiveSyncNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
 
     // Message handlers
     void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (247821 => 247822)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2019-07-25 15:42:11 UTC (rev 247822)
@@ -31,6 +31,8 @@
 
     DidSyncAllCookies()
 
+    TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(WebCore::PageIdentifier webPageID) -> (bool handled) Synchronous
+
     ProcessReadyToSuspend()
     SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (247821 => 247822)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2019-07-25 15:42:11 UTC (rev 247822)
@@ -36,6 +36,8 @@
 #include "InjectedBundleNavigationAction.h"
 #include "InjectedBundleNodeHandle.h"
 #include "NavigationActionData.h"
+#include "NetworkConnectionToWebProcessMessages.h"
+#include "NetworkProcessConnection.h"
 #include "PageBanner.h"
 #include "UserData.h"
 #include "WebColorChooser.h"
@@ -303,6 +305,14 @@
     return webProcess.webPage(*newPageID)->corePage();
 }
 
+bool WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply()
+{
+    bool handled = false;
+    if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(m_page.pageID()), Messages::NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::Reply(handled), 0, Seconds::infinity(), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
+        return false;
+    return handled;
+}
+
 void WebChromeClient::show()
 {
     m_page.show();
@@ -458,7 +468,7 @@
 
     HangDetectionDisabler hangDetectionDisabler;
 
-    m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply());
+    m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply);
 }
 
 bool WebChromeClient::runJavaScriptConfirm(Frame& frame, const String& message)
@@ -475,7 +485,7 @@
     HangDetectionDisabler hangDetectionDisabler;
 
     bool result = false;
-    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result)))
+    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
         return false;
 
     return result;
@@ -494,7 +504,7 @@
 
     HangDetectionDisabler hangDetectionDisabler;
 
-    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result)))
+    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
         return false;
 
     return !result.isNull();

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (247821 => 247822)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -222,6 +222,8 @@
 
     void contentRuleListNotification(const URL&, const WebCore::ContentRuleListResults&) final;
 
+    bool testProcessIncomingSyncMessagesWhenWaitingForSyncReply() final;
+
 #if PLATFORM(WIN)
     void setLastSetCursorToCurrentCursor() final { }
     void AXStartFrameLoad() final { }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (247821 => 247822)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-07-25 15:42:11 UTC (rev 247822)
@@ -5885,6 +5885,11 @@
 #endif
 }
 
+void WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&& reply)
+{
+    reply(true);
+}
+
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
 static const int primarySnapshottedPlugInSearchLimit = 3000;
 static const float primarySnapshottedPlugInSearchBucketSize = 1.1;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (247821 => 247822)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2019-07-25 15:42:11 UTC (rev 247822)
@@ -49,6 +49,7 @@
 #include "SharedMemory.h"
 #include "UserData.h"
 #include "WebBackForwardListProxy.h"
+#include "WebPageMessages.h"
 #include "WebURLSchemeHandler.h"
 #include "WebUndoStepID.h"
 #include "WebUserContentController.h"
@@ -1166,10 +1167,10 @@
     void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&);
 
     template<typename T>
-    bool sendSyncWithDelayedReply(T&& message, typename T::Reply&& reply)
+    bool sendSyncWithDelayedReply(T&& message, typename T::Reply&& reply, OptionSet<IPC::SendSyncOption> sendSyncOptions = { })
     {
         cancelGesturesBlockedOnSynchronousReplies();
-        return sendSync(WTFMove(message), WTFMove(reply), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
+        return sendSync(WTFMove(message), WTFMove(reply), Seconds::infinity(), sendSyncOptions | IPC::SendSyncOption::InformPlatformProcessWillSuspend);
     }
 
     WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String& originIdentifier);
@@ -1291,6 +1292,8 @@
     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
 #endif
 
+    void testProcessIncomingSyncMessagesWhenWaitingForSyncReply(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&&);
+
     void updateDrawingAreaLayerTreeFreezeState();
     bool markLayersVolatileImmediatelyIfPossible();
     void layerVolatilityTimerFired();

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (247821 => 247822)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-07-25 15:37:09 UTC (rev 247821)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2019-07-25 15:42:11 UTC (rev 247822)
@@ -31,6 +31,8 @@
     SendCSPViolationReport(uint64_t frameID, URL reportURL, IPC::FormDataReference reportData)
     EnqueueSecurityPolicyViolationEvent(uint64_t frameID, WebCore::SecurityPolicyViolationEvent::Init eventInit)
 
+    TestProcessIncomingSyncMessagesWhenWaitingForSyncReply() -> (bool handled) Synchronous
+
 #if PLATFORM(COCOA)
     SetTopContentInsetFenced(float contentInset, IPC::Attachment fencePort)
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to