Modified: trunk/Source/WebKit/ChangeLog (249834 => 249835)
--- trunk/Source/WebKit/ChangeLog 2019-09-13 15:42:28 UTC (rev 249834)
+++ trunk/Source/WebKit/ChangeLog 2019-09-13 16:03:17 UTC (rev 249835)
@@ -1,3 +1,16 @@
+2019-09-13 Alex Christensen <achristen...@webkit.org>
+
+ AuxiliaryProcessProxy::sendWithAsyncReply should queue up messages if sent while the process is starting like it does messages without replies
+ https://bugs.webkit.org/show_bug.cgi?id=201746
+
+ Reviewed by Youenn Fablet.
+
+ * UIProcess/AuxiliaryProcessProxy.cpp:
+ (WebKit::AuxiliaryProcessProxy::sendMessage):
+ (WebKit::AuxiliaryProcessProxy::didFinishLaunching):
+ * UIProcess/AuxiliaryProcessProxy.h:
+ (WebKit::AuxiliaryProcessProxy::sendWithAsyncReply):
+
2019-09-13 Youenn Fablet <you...@apple.com>
Use WebProcess processIdentifier to identify Service Worker connections
Modified: trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp (249834 => 249835)
--- trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp 2019-09-13 15:42:28 UTC (rev 249834)
+++ trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp 2019-09-13 16:03:17 UTC (rev 249835)
@@ -140,21 +140,29 @@
#endif
}
-bool AuxiliaryProcessProxy::sendMessage(std::unique_ptr<IPC::Encoder> encoder, OptionSet<IPC::SendOption> sendOptions)
+bool AuxiliaryProcessProxy::sendMessage(std::unique_ptr<IPC::Encoder> encoder, OptionSet<IPC::SendOption> sendOptions, Optional<std::pair<CompletionHandler<void(IPC::Decoder*)>, uint64_t>>&& asyncReplyInfo)
{
switch (state()) {
case State::Launching:
// If we're waiting for the child process to launch, we need to stash away the messages so we can send them once we have a connection.
- m_pendingMessages.append(std::make_pair(WTFMove(encoder), sendOptions));
+ m_pendingMessages.append({ WTFMove(encoder), sendOptions, WTFMove(asyncReplyInfo) });
return true;
case State::Running:
- return connection()->sendMessage(WTFMove(encoder), sendOptions);
+ if (connection()->sendMessage(WTFMove(encoder), sendOptions)) {
+ if (asyncReplyInfo)
+ IPC::addAsyncReplyHandler(*connection(), asyncReplyInfo->second, WTFMove(asyncReplyInfo->first));
+ return true;
+ }
+ break;
case State::Terminated:
- return false;
+ break;
}
+ if (asyncReplyInfo)
+ asyncReplyInfo->first(nullptr);
+
return false;
}
@@ -200,13 +208,13 @@
connectionWillOpen(*m_connection);
m_connection->open();
- for (size_t i = 0; i < m_pendingMessages.size(); ++i) {
- std::unique_ptr<IPC::Encoder> message = WTFMove(m_pendingMessages[i].first);
- OptionSet<IPC::SendOption> sendOptions = m_pendingMessages[i].second;
+ for (auto&& pendingMessage : std::exchange(m_pendingMessages, { })) {
+ auto encoder = WTFMove(pendingMessage.encoder);
+ auto sendOptions = pendingMessage.sendOptions;
#if HAVE(SANDBOX_ISSUE_MACH_EXTENSION_TO_PROCESS_BY_PID)
- if (message->messageName() == "LoadRequestWaitingForPID") {
- auto buffer = message->buffer();
- auto bufferSize = message->bufferSize();
+ if (encoder->messageName() == "LoadRequestWaitingForPID") {
+ auto buffer = encoder->buffer();
+ auto bufferSize = encoder->bufferSize();
std::unique_ptr<IPC::Decoder> decoder = makeUnique<IPC::Decoder>(buffer, bufferSize, nullptr, Vector<IPC::Attachment> { });
LoadParameters loadParameters;
String sandboxExtensionPath;
@@ -217,10 +225,10 @@
}
}
#endif
- m_connection->sendMessage(WTFMove(message), sendOptions);
+ if (pendingMessage.asyncReplyInfo)
+ IPC::addAsyncReplyHandler(*connection(), pendingMessage.asyncReplyInfo->second, WTFMove(pendingMessage.asyncReplyInfo->first));
+ m_connection->sendMessage(WTFMove(encoder), sendOptions);
}
-
- m_pendingMessages.clear();
}
void AuxiliaryProcessProxy::shutDownProcess()
Modified: trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h (249834 => 249835)
--- trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h 2019-09-13 15:42:28 UTC (rev 249834)
+++ trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h 2019-09-13 16:03:17 UTC (rev 249835)
@@ -50,7 +50,7 @@
template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions = { });
template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, Seconds timeout = 1_s, OptionSet<IPC::SendSyncOption> sendSyncOptions = { });
- template<typename T, typename... Args> void sendWithAsyncReply(T&&, CompletionHandler<void(Args...)>&&);
+ template<typename T, typename... Args> void sendWithAsyncReply(T&&, CompletionHandler<void(Args...)>&&, uint64_t destinationID = 0, OptionSet<IPC::SendOption> = { });
template<typename T, typename U>
bool send(T&& message, ObjectIdentifier<U> destinationID, OptionSet<IPC::SendOption> sendOptions = { })
@@ -102,7 +102,7 @@
ProcessID processIdentifier() const { return m_processLauncher ? m_processLauncher->processIdentifier() : 0; }
bool canSendMessage() const { return state() != State::Terminated;}
- bool sendMessage(std::unique_ptr<IPC::Encoder>, OptionSet<IPC::SendOption>);
+ bool sendMessage(std::unique_ptr<IPC::Encoder>, OptionSet<IPC::SendOption>, Optional<std::pair<CompletionHandler<void(IPC::Decoder*)>, uint64_t>>&& asyncReplyInfo = WTF::nullopt);
void shutDownProcess();
@@ -125,7 +125,13 @@
virtual void processWillShutDown(IPC::Connection&) = 0;
static bool isRunningProcessPID(ProcessID);
- Vector<std::pair<std::unique_ptr<IPC::Encoder>, OptionSet<IPC::SendOption>>> m_pendingMessages;
+ struct PendingMessage {
+ std::unique_ptr<IPC::Encoder> encoder;
+ OptionSet<IPC::SendOption> sendOptions;
+ Optional<std::pair<CompletionHandler<void(IPC::Decoder*)>, uint64_t>> asyncReplyInfo;
+ };
+
+ Vector<PendingMessage> m_pendingMessages;
RefPtr<ProcessLauncher> m_processLauncher;
RefPtr<IPC::Connection> m_connection;
IPC::MessageReceiverMap m_messageReceiverMap;
@@ -158,14 +164,20 @@
}
template<typename T, typename... Args>
-void AuxiliaryProcessProxy::sendWithAsyncReply(T&& message, CompletionHandler<void(Args...)>&& completionHandler)
+void AuxiliaryProcessProxy::sendWithAsyncReply(T&& message, CompletionHandler<void(Args...)>&& completionHandler, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions)
{
- if (!m_connection) {
- T::cancelReply(WTFMove(completionHandler));
- return;
- }
+ COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
- connection()->sendWithAsyncReply(std::forward<T>(message), WTFMove(completionHandler));
+ auto encoder = makeUnique<IPC::Encoder>(T::receiverName(), T::name(), destinationID);
+ uint64_t listenerID = IPC::nextAsyncReplyHandlerID();
+ encoder->encode(listenerID);
+ encoder->encode(message.arguments());
+ sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
+ if (decoder && !decoder->isInvalid())
+ T::callReply(*decoder, WTFMove(completionHandler));
+ else
+ T::cancelReply(WTFMove(completionHandler));
+ }, listenerID }});
}
} // namespace WebKit