Diff
Modified: branches/safari-608.1-branch/LayoutTests/ChangeLog (248351 => 248352)
--- branches/safari-608.1-branch/LayoutTests/ChangeLog 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/LayoutTests/ChangeLog 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1,5 +1,99 @@
2019-08-06 Kocsen Chung <[email protected]>
+ Cherry-pick r247868. rdar://problem/54017876
+
+ [iOS] WebPage::TouchEventSync() & WebPage::GetPositionInformation() sync IPC causes UIProcess hangs
+ https://bugs.webkit.org/show_bug.cgi?id=200138
+ <rdar://problem/52698157>
+
+ Reviewed by Geoffrey Garen.
+
+ Source/WebKit:
+
+ Revert most of r247822 and use an alternative approach to address hangs. In this patch, the proposal
+ is to add a SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply flag on the
+ WebPage::TouchEventSync() & WebPage::GetPositionInformation() sendSync() calls in the UIProcess.
+ Those will cause this IPCs to get dispatched right away in the WebContent process, even if the
+ WebContent process is itself currently stuck on unbounded (i.e. potentially slow) synchronous IPC
+ (JS alerts / prompts & sync XHR). Because re-entering WebCore on sync IPC is generally unsafe, this
+ patch also updates the WebPage::getPositionInformation() & WebPage::touchEventSync() to return early
+ (i.e. cancelled) if they get called while the WebContent process is stuck on a slow sendSync.
+
+ This approach should address the UIProcess hangs caused by the WebPage::TouchEventSync() and
+ WebPage::GetPositionInformation() sync IPC messages when the WebContent process is busy on a slow XHR
+ or a JS prompt / alert. It should be safe because we do not re-enter WebCore. The only drawback is that
+ those IPCs will be cancelled (early return with default value) when the WebContent process is busy.
+ However, I am being told that this is likely acceptable in practice.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::SyncMessageState::processIncomingMessage):
+ (IPC::Connection::sendMessage):
+ (IPC::Connection::sendSyncMessage):
+ (IPC::Connection::dispatchMessage):
+ * Platform/IPC/Connection.h:
+ (IPC::UnboundedSynchronousIPCScope::UnboundedSynchronousIPCScope):
+ (IPC::UnboundedSynchronousIPCScope::~UnboundedSynchronousIPCScope):
+ (IPC::UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC):
+ * Platform/IPC/Decoder.cpp:
+ (IPC::Decoder::shouldDispatchMessageWhenWaitingForSyncReply const):
+ * Platform/IPC/Decoder.h:
+ * Platform/IPC/Encoder.cpp:
+ (IPC::Encoder::shouldDispatchMessageWhenWaitingForSyncReply const):
+ (IPC::Encoder::setShouldDispatchMessageWhenWaitingForSyncReply):
+ (IPC::Encoder::wrapForTesting):
+ * Platform/IPC/Encoder.h:
+ * Platform/IPC/MessageFlags.h:
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::handleTouchEventSynchronously):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView ensurePositionInformationIsUpToDate:]):
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ (WebKit::WebChromeClient::runJavaScriptAlert):
+ (WebKit::WebChromeClient::runJavaScriptConfirm):
+ (WebKit::WebChromeClient::runJavaScriptPrompt):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::layerVolatilityTimerFired):
+ (WebKit::WebPage::markLayersVolatile):
+ (WebKit::WebPage::cancelMarkLayersVolatile):
+ (WebKit::WebPage::touchEventSync):
+ (WebKit::WebPage::didCompletePageTransition):
+ (WebKit::WebPage::updatePreferences):
+ (WebKit::WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::sendSyncWithDelayedReply):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getPositionInformation):
+
+ LayoutTests:
+
+ Update existing layout test accordingly.
+
+ * fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply-expected.txt: Renamed from LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt.
+ * fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply.html: Renamed from LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-26 Chris Dumez <[email protected]>
+
+ [iOS] WebPage::TouchEventSync() & WebPage::GetPositionInformation() sync IPC causes UIProcess hangs
+ https://bugs.webkit.org/show_bug.cgi?id=200138
+ <rdar://problem/52698157>
+
+ Reviewed by Geoffrey Garen.
+
+ Update existing layout test accordingly.
+
+ * fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply-expected.txt: Renamed from LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt.
+ * fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply.html: Renamed from LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html.
+
+2019-08-06 Kocsen Chung <[email protected]>
+
Cherry-pick r247824. rdar://problem/54017900
Adding iOS-specific expectations for fast/text-indicator/text-indicator-with-low-contrast-text.html.
Deleted: branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt (248351 => 248352)
--- branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1,10 +0,0 @@
-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
-
Deleted: branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html (248351 => 248352)
--- branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<script src=""
-<script>
-description("Test for the SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply sendSync flag");
-
-shouldBeTrue("internals.testProcessIncomingSyncMessagesWhenWaitingForSyncReply()");
-</script>
-</body>
-</html>
Copied: branches/safari-608.1-branch/LayoutTests/fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply-expected.txt (from rev 248351, branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt) (0 => 248352)
--- branches/safari-608.1-branch/LayoutTests/fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply-expected.txt (rev 0)
+++ branches/safari-608.1-branch/LayoutTests/fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply-expected.txt 2019-08-07 06:52:44 UTC (rev 248352)
@@ -0,0 +1,10 @@
+Test for the SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply 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
+
Copied: branches/safari-608.1-branch/LayoutTests/fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply.html (from rev 248351, branches/safari-608.1-branch/LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html) (0 => 248352)
--- branches/safari-608.1-branch/LayoutTests/fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply.html (rev 0)
+++ branches/safari-608.1-branch/LayoutTests/fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply.html 2019-08-07 06:52:44 UTC (rev 248352)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test for the SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply sendSync flag");
+
+shouldBeTrue("internals.testProcessIncomingSyncMessagesWhenWaitingForSyncReply()");
+</script>
+</body>
+</html>
Modified: branches/safari-608.1-branch/Source/WebKit/ChangeLog (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/ChangeLog 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/ChangeLog 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1,5 +1,153 @@
2019-08-06 Kocsen Chung <[email protected]>
+ Cherry-pick r247868. rdar://problem/54017876
+
+ [iOS] WebPage::TouchEventSync() & WebPage::GetPositionInformation() sync IPC causes UIProcess hangs
+ https://bugs.webkit.org/show_bug.cgi?id=200138
+ <rdar://problem/52698157>
+
+ Reviewed by Geoffrey Garen.
+
+ Source/WebKit:
+
+ Revert most of r247822 and use an alternative approach to address hangs. In this patch, the proposal
+ is to add a SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply flag on the
+ WebPage::TouchEventSync() & WebPage::GetPositionInformation() sendSync() calls in the UIProcess.
+ Those will cause this IPCs to get dispatched right away in the WebContent process, even if the
+ WebContent process is itself currently stuck on unbounded (i.e. potentially slow) synchronous IPC
+ (JS alerts / prompts & sync XHR). Because re-entering WebCore on sync IPC is generally unsafe, this
+ patch also updates the WebPage::getPositionInformation() & WebPage::touchEventSync() to return early
+ (i.e. cancelled) if they get called while the WebContent process is stuck on a slow sendSync.
+
+ This approach should address the UIProcess hangs caused by the WebPage::TouchEventSync() and
+ WebPage::GetPositionInformation() sync IPC messages when the WebContent process is busy on a slow XHR
+ or a JS prompt / alert. It should be safe because we do not re-enter WebCore. The only drawback is that
+ those IPCs will be cancelled (early return with default value) when the WebContent process is busy.
+ However, I am being told that this is likely acceptable in practice.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::SyncMessageState::processIncomingMessage):
+ (IPC::Connection::sendMessage):
+ (IPC::Connection::sendSyncMessage):
+ (IPC::Connection::dispatchMessage):
+ * Platform/IPC/Connection.h:
+ (IPC::UnboundedSynchronousIPCScope::UnboundedSynchronousIPCScope):
+ (IPC::UnboundedSynchronousIPCScope::~UnboundedSynchronousIPCScope):
+ (IPC::UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC):
+ * Platform/IPC/Decoder.cpp:
+ (IPC::Decoder::shouldDispatchMessageWhenWaitingForSyncReply const):
+ * Platform/IPC/Decoder.h:
+ * Platform/IPC/Encoder.cpp:
+ (IPC::Encoder::shouldDispatchMessageWhenWaitingForSyncReply const):
+ (IPC::Encoder::setShouldDispatchMessageWhenWaitingForSyncReply):
+ (IPC::Encoder::wrapForTesting):
+ * Platform/IPC/Encoder.h:
+ * Platform/IPC/MessageFlags.h:
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::handleTouchEventSynchronously):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView ensurePositionInformationIsUpToDate:]):
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ (WebKit::WebChromeClient::runJavaScriptAlert):
+ (WebKit::WebChromeClient::runJavaScriptConfirm):
+ (WebKit::WebChromeClient::runJavaScriptPrompt):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::layerVolatilityTimerFired):
+ (WebKit::WebPage::markLayersVolatile):
+ (WebKit::WebPage::cancelMarkLayersVolatile):
+ (WebKit::WebPage::touchEventSync):
+ (WebKit::WebPage::didCompletePageTransition):
+ (WebKit::WebPage::updatePreferences):
+ (WebKit::WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::sendSyncWithDelayedReply):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getPositionInformation):
+
+ LayoutTests:
+
+ Update existing layout test accordingly.
+
+ * fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply-expected.txt: Renamed from LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply-expected.txt.
+ * fast/misc/{testProcessIncomingSyncMessagesWhenWaitingForUnboundedReply.html: Renamed from LayoutTests/fast/misc/testProcessIncomingSyncMessagesWhenWaitingForSyncReply.html.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-07-26 Chris Dumez <[email protected]>
+
+ [iOS] WebPage::TouchEventSync() & WebPage::GetPositionInformation() sync IPC causes UIProcess hangs
+ https://bugs.webkit.org/show_bug.cgi?id=200138
+ <rdar://problem/52698157>
+
+ Reviewed by Geoffrey Garen.
+
+ Revert most of r247822 and use an alternative approach to address hangs. In this patch, the proposal
+ is to add a SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply flag on the
+ WebPage::TouchEventSync() & WebPage::GetPositionInformation() sendSync() calls in the UIProcess.
+ Those will cause this IPCs to get dispatched right away in the WebContent process, even if the
+ WebContent process is itself currently stuck on unbounded (i.e. potentially slow) synchronous IPC
+ (JS alerts / prompts & sync XHR). Because re-entering WebCore on sync IPC is generally unsafe, this
+ patch also updates the WebPage::getPositionInformation() & WebPage::touchEventSync() to return early
+ (i.e. cancelled) if they get called while the WebContent process is stuck on a slow sendSync.
+
+ This approach should address the UIProcess hangs caused by the WebPage::TouchEventSync() and
+ WebPage::GetPositionInformation() sync IPC messages when the WebContent process is busy on a slow XHR
+ or a JS prompt / alert. It should be safe because we do not re-enter WebCore. The only drawback is that
+ those IPCs will be cancelled (early return with default value) when the WebContent process is busy.
+ However, I am being told that this is likely acceptable in practice.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::SyncMessageState::processIncomingMessage):
+ (IPC::Connection::sendMessage):
+ (IPC::Connection::sendSyncMessage):
+ (IPC::Connection::dispatchMessage):
+ * Platform/IPC/Connection.h:
+ (IPC::UnboundedSynchronousIPCScope::UnboundedSynchronousIPCScope):
+ (IPC::UnboundedSynchronousIPCScope::~UnboundedSynchronousIPCScope):
+ (IPC::UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC):
+ * Platform/IPC/Decoder.cpp:
+ (IPC::Decoder::shouldDispatchMessageWhenWaitingForSyncReply const):
+ * Platform/IPC/Decoder.h:
+ * Platform/IPC/Encoder.cpp:
+ (IPC::Encoder::shouldDispatchMessageWhenWaitingForSyncReply const):
+ (IPC::Encoder::setShouldDispatchMessageWhenWaitingForSyncReply):
+ (IPC::Encoder::wrapForTesting):
+ * Platform/IPC/Encoder.h:
+ * Platform/IPC/MessageFlags.h:
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::handleTouchEventSynchronously):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView ensurePositionInformationIsUpToDate:]):
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ (WebKit::WebChromeClient::runJavaScriptAlert):
+ (WebKit::WebChromeClient::runJavaScriptConfirm):
+ (WebKit::WebChromeClient::runJavaScriptPrompt):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::layerVolatilityTimerFired):
+ (WebKit::WebPage::markLayersVolatile):
+ (WebKit::WebPage::cancelMarkLayersVolatile):
+ (WebKit::WebPage::touchEventSync):
+ (WebKit::WebPage::didCompletePageTransition):
+ (WebKit::WebPage::updatePreferences):
+ (WebKit::WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply):
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::sendSyncWithDelayedReply):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getPositionInformation):
+
+2019-08-06 Kocsen Chung <[email protected]>
+
Cherry-pick r247822. rdar://problem/54017886
Avoid UI Process hangs when the WebContent process is showing JS prompts / alerts
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Connection.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Connection.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Connection.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -27,6 +27,7 @@
#include "Connection.h"
#include "Logging.h"
+#include "MessageFlags.h"
#include <memory>
#include <wtf/HashSet.h>
#include <wtf/NeverDestroyed.h>
@@ -49,6 +50,8 @@
const size_t maxPendingIncomingMessagesKillingThreshold { 50000 };
#endif
+std::atomic<unsigned> UnboundedSynchronousIPCScope::unboundedSynchronousIPCCount = 0;
+
struct Connection::ReplyHandler {
RefPtr<FunctionDispatcher> dispatcher;
Function<void (std::unique_ptr<Decoder>)> handler;
@@ -98,9 +101,6 @@
// 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&);
@@ -117,8 +117,6 @@
std::unique_ptr<Decoder> message;
};
Vector<ConnectionAndIncomingMessage> m_messagesToDispatchWhileWaitingForSyncReply;
-
- std::atomic<unsigned> m_processIncomingSyncMessagesWhenWaitingForSyncReplyCount { 0 };
};
Connection::SyncMessageState& Connection::SyncMessageState::singleton()
@@ -139,17 +137,16 @@
bool Connection::SyncMessageState::processIncomingMessage(Connection& connection, std::unique_ptr<Decoder>& message)
{
- 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)
+ switch (message->shouldDispatchMessageWhenWaitingForSyncReply()) {
+ case ShouldDispatchWhenWaitingForSyncReply::No:
return false;
+ case ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC:
+ if (!UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC())
+ return false;
+ break;
+ case ShouldDispatchWhenWaitingForSyncReply::Yes:
+ break;
+ }
ConnectionAndIncomingMessage connectionAndIncomingMessage { connection, WTFMove(message) };
@@ -433,7 +430,9 @@
if (sendOptions.contains(SendOption::DispatchMessageEvenWhenWaitingForSyncReply)
&& (!m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage
|| m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount))
- encoder->setShouldDispatchMessageWhenWaitingForSyncReply(true);
+ encoder->setShouldDispatchMessageWhenWaitingForSyncReply(ShouldDispatchWhenWaitingForSyncReply::Yes);
+ else if (sendOptions.contains(SendOption::DispatchMessageEvenWhenWaitingForUnboundedSyncReply))
+ encoder->setShouldDispatchMessageWhenWaitingForSyncReply(ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC);
{
std::lock_guard<Lock> lock(m_outgoingMessagesMutex);
@@ -577,10 +576,11 @@
++m_inSendSyncCount;
// First send the message.
- sendMessage(WTFMove(encoder), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+ OptionSet<SendOption> sendOptions = IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply;
+ if (sendSyncOptions.contains(SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply))
+ sendOptions = sendOptions | IPC::SendOption::DispatchMessageEvenWhenWaitingForUnboundedSyncReply;
- if (sendSyncOptions.contains(SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
- SyncMessageState::singleton().incrementProcessIncomingSyncMessagesWhenWaitingForSyncReplyCount();
+ sendMessage(WTFMove(encoder), sendOptions);
// 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.
@@ -587,9 +587,6 @@
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.
@@ -1040,8 +1037,11 @@
}
m_inDispatchMessageCount++;
+
+ bool isDispatchingMessageWhileWaitingForSyncReply = (message->shouldDispatchMessageWhenWaitingForSyncReply() == ShouldDispatchWhenWaitingForSyncReply::Yes)
+ || (message->shouldDispatchMessageWhenWaitingForSyncReply() == ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC && UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC());
- if (message->shouldDispatchMessageWhenWaitingForSyncReply())
+ if (isDispatchingMessageWhileWaitingForSyncReply)
m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount++;
bool oldDidReceiveInvalidMessage = m_didReceiveInvalidMessage;
@@ -1057,7 +1057,7 @@
// FIXME: For synchronous messages, we should not decrement the counter until we send a response.
// Otherwise, we would deadlock if processing the message results in a sync message back after we exit this function.
- if (message->shouldDispatchMessageWhenWaitingForSyncReply())
+ if (isDispatchingMessageWhileWaitingForSyncReply)
m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount--;
if (message->shouldUseFullySynchronousModeForTesting())
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Connection.h (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Connection.h 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Connection.h 2019-08-07 06:52:44 UTC (rev 248352)
@@ -61,7 +61,8 @@
// Whether this message should be dispatched when waiting for a sync reply.
// This is the default for synchronous messages.
DispatchMessageEvenWhenWaitingForSyncReply = 1 << 0,
- IgnoreFullySynchronousMode = 1 << 1,
+ DispatchMessageEvenWhenWaitingForUnboundedSyncReply = 1 << 1,
+ IgnoreFullySynchronousMode = 1 << 2,
};
enum class SendSyncOption {
@@ -68,7 +69,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,
+ ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply = 1 << 2,
};
enum class WaitForOption {
@@ -554,4 +555,28 @@
return true;
}
+class UnboundedSynchronousIPCScope {
+public:
+ UnboundedSynchronousIPCScope()
+ {
+ ASSERT(RunLoop::isMain());
+ ++unboundedSynchronousIPCCount;
+ }
+
+ ~UnboundedSynchronousIPCScope()
+ {
+ ASSERT(RunLoop::isMain());
+ ASSERT(unboundedSynchronousIPCCount);
+ --unboundedSynchronousIPCCount;
+ }
+
+ static bool hasOngoingUnboundedSyncIPC()
+ {
+ return unboundedSynchronousIPCCount.load() > 0;
+ }
+
+private:
+ static std::atomic<unsigned> unboundedSynchronousIPCCount;
+};
+
} // namespace IPC
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Decoder.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Decoder.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Decoder.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -88,9 +88,13 @@
return m_messageFlags & SyncMessage;
}
-bool Decoder::shouldDispatchMessageWhenWaitingForSyncReply() const
+ShouldDispatchWhenWaitingForSyncReply Decoder::shouldDispatchMessageWhenWaitingForSyncReply() const
{
- return m_messageFlags & DispatchMessageWhenWaitingForSyncReply;
+ if (m_messageFlags & DispatchMessageWhenWaitingForSyncReply)
+ return ShouldDispatchWhenWaitingForSyncReply::Yes;
+ if (m_messageFlags & DispatchMessageWhenWaitingForUnboundedSyncReply)
+ return ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC;
+ return ShouldDispatchWhenWaitingForSyncReply::No;
}
bool Decoder::shouldUseFullySynchronousModeForTesting() const
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Decoder.h (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Decoder.h 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Decoder.h 2019-08-07 06:52:44 UTC (rev 248352)
@@ -39,6 +39,7 @@
class DataReference;
class ImportanceAssertion;
+enum class ShouldDispatchWhenWaitingForSyncReply;
class Decoder {
WTF_MAKE_FAST_ALLOCATED;
@@ -54,7 +55,7 @@
uint64_t destinationID() const { return m_destinationID; }
bool isSyncMessage() const;
- bool shouldDispatchMessageWhenWaitingForSyncReply() const;
+ ShouldDispatchWhenWaitingForSyncReply shouldDispatchMessageWhenWaitingForSyncReply() const;
bool shouldUseFullySynchronousModeForTesting() const;
#if PLATFORM(MAC)
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Encoder.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Encoder.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Encoder.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -85,9 +85,13 @@
return *buffer() & SyncMessage;
}
-bool Encoder::shouldDispatchMessageWhenWaitingForSyncReply() const
+ShouldDispatchWhenWaitingForSyncReply Encoder::shouldDispatchMessageWhenWaitingForSyncReply() const
{
- return *buffer() & DispatchMessageWhenWaitingForSyncReply;
+ if (*buffer() & DispatchMessageWhenWaitingForSyncReply)
+ return ShouldDispatchWhenWaitingForSyncReply::Yes;
+ if (*buffer() & DispatchMessageWhenWaitingForUnboundedSyncReply)
+ return ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC;
+ return ShouldDispatchWhenWaitingForSyncReply::No;
}
void Encoder::setIsSyncMessage(bool isSyncMessage)
@@ -98,12 +102,21 @@
*buffer() &= ~SyncMessage;
}
-void Encoder::setShouldDispatchMessageWhenWaitingForSyncReply(bool shouldDispatchMessageWhenWaitingForSyncReply)
+void Encoder::setShouldDispatchMessageWhenWaitingForSyncReply(ShouldDispatchWhenWaitingForSyncReply shouldDispatchWhenWaitingForSyncReply)
{
- if (shouldDispatchMessageWhenWaitingForSyncReply)
+ switch (shouldDispatchWhenWaitingForSyncReply) {
+ case ShouldDispatchWhenWaitingForSyncReply::No:
+ *buffer() &= ~(DispatchMessageWhenWaitingForSyncReply | DispatchMessageWhenWaitingForUnboundedSyncReply);
+ break;
+ case ShouldDispatchWhenWaitingForSyncReply::Yes:
*buffer() |= DispatchMessageWhenWaitingForSyncReply;
- else
+ *buffer() &= ~DispatchMessageWhenWaitingForUnboundedSyncReply;
+ break;
+ case ShouldDispatchWhenWaitingForSyncReply::YesDuringUnboundedIPC:
+ *buffer() |= DispatchMessageWhenWaitingForUnboundedSyncReply;
*buffer() &= ~DispatchMessageWhenWaitingForSyncReply;
+ break;
+ }
}
void Encoder::setFullySynchronousModeForTesting()
@@ -116,7 +129,7 @@
ASSERT(isSyncMessage());
ASSERT(!original->isSyncMessage());
- original->setShouldDispatchMessageWhenWaitingForSyncReply(true);
+ original->setShouldDispatchMessageWhenWaitingForSyncReply(ShouldDispatchWhenWaitingForSyncReply::Yes);
encodeVariableLengthByteArray(DataReference(original->buffer(), original->bufferSize()));
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Encoder.h (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Encoder.h 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/Encoder.h 2019-08-07 06:52:44 UTC (rev 248352)
@@ -34,6 +34,7 @@
namespace IPC {
class DataReference;
+enum class ShouldDispatchWhenWaitingForSyncReply;
class Encoder final {
WTF_MAKE_FAST_ALLOCATED;
@@ -48,8 +49,8 @@
void setIsSyncMessage(bool);
bool isSyncMessage() const;
- void setShouldDispatchMessageWhenWaitingForSyncReply(bool);
- bool shouldDispatchMessageWhenWaitingForSyncReply() const;
+ void setShouldDispatchMessageWhenWaitingForSyncReply(ShouldDispatchWhenWaitingForSyncReply);
+ ShouldDispatchWhenWaitingForSyncReply shouldDispatchMessageWhenWaitingForSyncReply() const;
void setFullySynchronousModeForTesting();
Modified: branches/safari-608.1-branch/Source/WebKit/Platform/IPC/MessageFlags.h (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/Platform/IPC/MessageFlags.h 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/Platform/IPC/MessageFlags.h 2019-08-07 06:52:44 UTC (rev 248352)
@@ -31,9 +31,12 @@
enum MessageFlags {
SyncMessage = 1 << 0,
DispatchMessageWhenWaitingForSyncReply = 1 << 1,
- UseFullySynchronousModeForTesting = 1 << 2,
+ DispatchMessageWhenWaitingForUnboundedSyncReply = 1 << 2,
+ UseFullySynchronousModeForTesting = 1 << 3,
};
+enum class ShouldDispatchWhenWaitingForSyncReply { No, Yes, YesDuringUnboundedIPC };
+
} // namespace IPC
#endif // MessageFlags_h
Modified: branches/safari-608.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1211,7 +1211,7 @@
return reply(false);
bool handled = false;
- if (!page->sendSync(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(), Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::Reply(handled)))
+ if (!page->sendSync(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(), Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::Reply(handled), Seconds::infinity(), IPC::SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply))
return reply(false);
reply(handled);
}
Modified: branches/safari-608.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -2662,7 +2662,7 @@
m_process->responsivenessTimer().start();
bool handled = false;
- bool replyReceived = m_process->sendSync(Messages::WebPage::TouchEventSync(event), Messages::WebPage::TouchEventSync::Reply(handled), m_pageID, 1_s);
+ bool replyReceived = m_process->sendSync(Messages::WebPage::TouchEventSync(event), Messages::WebPage::TouchEventSync::Reply(handled), m_pageID, 1_s, IPC::SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply);
// If the sync request has timed out, we should consider the event handled. The Web Process is too busy to answer any questions, so the default action is also likely to have issues.
if (!replyReceived)
handled = true;
Modified: branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1998,7 +1998,7 @@
if ([self _hasValidOutstandingPositionInformationRequest:request])
return connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidReceivePositionInformation>(_page->pageID(), 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
- bool receivedResponse = _page->process().sendSync(Messages::WebPage::GetPositionInformation(request), Messages::WebPage::GetPositionInformation::Reply(_positionInformation), _page->pageID(), 1_s);
+ bool receivedResponse = _page->process().sendSync(Messages::WebPage::GetPositionInformation(request), Messages::WebPage::GetPositionInformation::Reply(_positionInformation), _page->pageID(), 1_s, IPC::SendSyncOption::ForceDispatchWhenDestinationIsWaitingForUnboundedSyncReply);
_hasValidPositionInformation = receivedResponse && _positionInformation.canBeValid;
// FIXME: We need to clean up these handlers in the event that we are not able to collect data, or if the WebProcess crashes.
Modified: branches/safari-608.1-branch/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -564,6 +564,7 @@
data.shrink(0);
HangDetectionDisabler hangDetectionDisabler;
+ IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
bool shouldNotifyOfUpload = request.hasUpload() && m_loadersWithUploads.isEmpty();
if (shouldNotifyOfUpload)
Modified: branches/safari-608.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -307,8 +307,9 @@
bool WebChromeClient::testProcessIncomingSyncMessagesWhenWaitingForSyncReply()
{
+ IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
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))
+ if (!WebProcess::singleton().ensureNetworkProcessConnection().connection().sendSync(Messages::NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply(m_page.pageID()), Messages::NetworkConnectionToWebProcess::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::Reply(handled), 0))
return false;
return handled;
}
@@ -467,8 +468,9 @@
m_page.injectedBundleUIClient().willRunJavaScriptAlert(&m_page, alertText, webFrame);
HangDetectionDisabler hangDetectionDisabler;
+ IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
- m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply);
+ m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply());
}
bool WebChromeClient::runJavaScriptConfirm(Frame& frame, const String& message)
@@ -483,9 +485,10 @@
m_page.injectedBundleUIClient().willRunJavaScriptConfirm(&m_page, message, webFrame);
HangDetectionDisabler hangDetectionDisabler;
+ IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
bool result = false;
- if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
+ if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result)))
return false;
return result;
@@ -503,8 +506,9 @@
m_page.injectedBundleUIClient().willRunJavaScriptPrompt(&m_page, message, defaultValue, webFrame);
HangDetectionDisabler hangDetectionDisabler;
+ IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
- if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), IPC::SendSyncOption::ProcessIncomingSyncMessagesWhenWaitingForSyncReply))
+ if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result)))
return false;
return !result.isNull();
Modified: branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-08-07 06:52:44 UTC (rev 248352)
@@ -316,8 +316,8 @@
static const Seconds initialLayerVolatilityTimerInterval { 20_ms };
static const Seconds maximumLayerVolatilityTimerInterval { 2_s };
-#define RELEASE_LOG_IF_ALLOWED(...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Layers, __VA_ARGS__)
-#define RELEASE_LOG_ERROR_IF_ALLOWED(...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), Layers, __VA_ARGS__)
+#define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), channel, "%p - WebPage::" fmt, this, ##__VA_ARGS__)
+#define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), channel, "%p - WebPage::" fmt, this, ##__VA_ARGS__)
class SendStopResponsivenessTimer {
public:
@@ -2551,14 +2551,14 @@
if (didSucceed || newInterval > maximumLayerVolatilityTimerInterval) {
m_layerVolatilityTimer.stop();
if (didSucceed)
- RELEASE_LOG_IF_ALLOWED("%p - WebPage - Succeeded in marking layers as volatile", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "layerVolatilityTimerFired: Succeeded in marking layers as volatile");
else
- RELEASE_LOG_IF_ALLOWED("%p - WebPage - Failed to mark layers as volatile within %gms", this, maximumLayerVolatilityTimerInterval.milliseconds());
+ RELEASE_LOG_IF_ALLOWED(Layers, "layerVolatilityTimerFired: Failed to mark layers as volatile within %gms", maximumLayerVolatilityTimerInterval.milliseconds());
callVolatilityCompletionHandlers(didSucceed);
return;
}
- RELEASE_LOG_ERROR_IF_ALLOWED("%p - WebPage - Failed to mark all layers as volatile, will retry in %g ms", this, newInterval.milliseconds());
+ RELEASE_LOG_ERROR_IF_ALLOWED(Layers, "layerVolatilityTimerFired: Failed to mark all layers as volatile, will retry in %g ms", newInterval.milliseconds());
m_layerVolatilityTimer.startRepeating(newInterval);
}
@@ -2569,7 +2569,7 @@
void WebPage::markLayersVolatile(WTF::Function<void (bool)>&& completionHandler)
{
- RELEASE_LOG_IF_ALLOWED("%p - WebPage::markLayersVolatile()", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "markLayersVolatile");
if (m_layerVolatilityTimer.isActive())
m_layerVolatilityTimer.stop();
@@ -2580,22 +2580,22 @@
bool didSucceed = markLayersVolatileImmediatelyIfPossible();
if (didSucceed || m_isSuspendedUnderLock) {
if (didSucceed)
- RELEASE_LOG_IF_ALLOWED("%p - WebPage - Successfully marked layers as volatile", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "markLayersVolatile: Successfully marked layers as volatile");
else {
// If we get suspended when locking the screen, it is expected that some IOSurfaces cannot be marked as purgeable so we do not keep retrying.
- RELEASE_LOG_IF_ALLOWED("%p - WebPage - Did what we could to mark IOSurfaces as purgeable after locking the screen", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "markLayersVolatile: Did what we could to mark IOSurfaces as purgeable after locking the screen");
}
callVolatilityCompletionHandlers(didSucceed);
return;
}
- RELEASE_LOG_IF_ALLOWED("%p - Failed to mark all layers as volatile, will retry in %g ms", this, initialLayerVolatilityTimerInterval.milliseconds());
+ RELEASE_LOG_IF_ALLOWED(Layers, "markLayersVolatile: Failed to mark all layers as volatile, will retry in %g ms", initialLayerVolatilityTimerInterval.milliseconds());
m_layerVolatilityTimer.startRepeating(initialLayerVolatilityTimerInterval);
}
void WebPage::cancelMarkLayersVolatile()
{
- RELEASE_LOG_IF_ALLOWED("%p - WebPage::cancelMarkLayersVolatile()", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "cancelMarkLayersVolatile");
m_layerVolatilityTimer.stop();
m_markLayersAsVolatileCompletionHandlers.clear();
}
@@ -2905,6 +2905,12 @@
void WebPage::touchEventSync(const WebTouchEvent& touchEvent, CompletionHandler<void(bool)>&& reply)
{
+ // Avoid UIProcess hangs when the WebContent process is stuck on a sync IPC.
+ if (IPC::UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC()) {
+ RELEASE_LOG_ERROR_IF_ALLOWED(Process, "touchEventSync - Not processing because the process is stuck on unbounded sync IPC");
+ return reply(true);
+ }
+
m_pendingSynchronousTouchEventReply = WTFMove(reply);
EventDispatcher::TouchEventQueue queuedEvents;
@@ -3274,7 +3280,7 @@
{
unfreezeLayerTree(LayerTreeFreezeReason::PageTransition);
- RELEASE_LOG_IF_ALLOWED("%p - WebPage - Did complete page transition", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "didCompletePageTransition: Did complete page transition");
bool isInitialEmptyDocument = !m_mainFrame;
if (!isInitialEmptyDocument)
@@ -3539,7 +3545,7 @@
#if !PLATFORM(GTK) && !PLATFORM(WIN)
if (!settings.acceleratedCompositingEnabled()) {
- RELEASE_LOG_IF_ALLOWED("%p - WebPage - acceleratedCompositingEnabled setting was false. WebKit cannot function in this mode; changing setting to true", this);
+ RELEASE_LOG_IF_ALLOWED(Layers, "updatePreferences: acceleratedCompositingEnabled setting was false. WebKit cannot function in this mode; changing setting to true");
settings.setAcceleratedCompositingEnabled(true);
}
#endif
@@ -5876,6 +5882,7 @@
void WebPage::testProcessIncomingSyncMessagesWhenWaitingForSyncReply(Messages::WebPage::TestProcessIncomingSyncMessagesWhenWaitingForSyncReply::DelayedReply&& reply)
{
+ RELEASE_ASSERT(IPC::UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC());
reply(true);
}
Modified: branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h 2019-08-07 06:52:44 UTC (rev 248352)
@@ -1167,10 +1167,10 @@
void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&);
template<typename T>
- bool sendSyncWithDelayedReply(T&& message, typename T::Reply&& reply, OptionSet<IPC::SendSyncOption> sendSyncOptions = { })
+ bool sendSyncWithDelayedReply(T&& message, typename T::Reply&& reply)
{
cancelGesturesBlockedOnSynchronousReplies();
- return sendSync(WTFMove(message), WTFMove(reply), Seconds::infinity(), sendSyncOptions | IPC::SendSyncOption::InformPlatformProcessWillSuspend);
+ return sendSync(WTFMove(message), WTFMove(reply), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
}
WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String& originIdentifier);
Modified: branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (248351 => 248352)
--- branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-08-07 06:52:39 UTC (rev 248351)
+++ branches/safari-608.1-branch/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-08-07 06:52:44 UTC (rev 248352)
@@ -132,6 +132,9 @@
#import <wtf/cocoa/Entitlements.h>
#import <wtf/text/TextStream.h>
+#define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), channel, "%p - WebPage::" fmt, this, ##__VA_ARGS__)
+#define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), channel, "%p - WebPage::" fmt, this, ##__VA_ARGS__)
+
namespace WebKit {
using namespace WebCore;
@@ -2542,6 +2545,12 @@
void WebPage::getPositionInformation(const InteractionInformationRequest& request, CompletionHandler<void(InteractionInformationAtPosition&&)>&& reply)
{
+ // Avoid UIProcess hangs when the WebContent process is stuck on a sync IPC.
+ if (IPC::UnboundedSynchronousIPCScope::hasOngoingUnboundedSyncIPC()) {
+ RELEASE_LOG_ERROR_IF_ALLOWED(Process, "getPositionInformation - Not processing because the process is stuck on unbounded sync IPC");
+ return reply({ });
+ }
+
m_pendingSynchronousPositionInformationReply = WTFMove(reply);
auto information = positionInformation(request);
@@ -4015,4 +4024,7 @@
} // namespace WebKit
+#undef RELEASE_LOG_IF_ALLOWED
+#undef RELEASE_LOG_ERROR_IF_ALLOWED
+
#endif // PLATFORM(IOS_FAMILY)