Diff
Modified: trunk/Source/WebKit/ChangeLog (292802 => 292803)
--- trunk/Source/WebKit/ChangeLog 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/ChangeLog 2022-04-13 07:29:16 UTC (rev 292803)
@@ -1,3 +1,102 @@
+2022-04-13 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ RemoteRenderingBackend should have dedicated IPC::Connection for out-of-stream messages
+ https://bugs.webkit.org/show_bug.cgi?id=238516
+
+ Reviewed by Simon Fraser.
+
+ Use dedicated IPC::Connection for RemoteRenderingBackend IPC stream connection instead
+ of using the WP-GPUP main connection. RemoteDisplayListRecorder starts listening to
+ its messages in the worker thread. At that point, some out-of-stream message for that
+ id might already have been dispatched to main thread, causing missing message and assert.
+
+ Instead, use dedicated connection and route all the messages to the StreamServerConnection
+ in a "message queue". This way when each out-of-stream message marker is processed, the
+ message will be, directly or eventually, found from the message queue.
+
+ Remove workarounds:
+ - Adding a listener to the main WP-GPUP connection for all RemoteDisplayListRecorder messages
+ and routing them to particular StreamServerConnection. This was problematic since
+ there are many RRB StreamServerConnection instances, one per Page, but only one WP-GPUP
+ connection.
+ - RELEASE_LOG in MessageReceiveQueueMap about warning for the above. Turn this back into an
+ ASSERT.
+
+ Since IPC::StreamClientConnection and IPC::StreamServerConnection are like IPC::Connection,
+ add open() and invalidate() calls. These have same contract as with IPC::Connection:
+ open() should be called if connection is to be used, invalidate() must be called if open() was called.
+ These calls have an effect currently only with dedicated connections, but these are added to all
+ IPC::Stream*Connection clients for consistency and future uses.
+
+ Changes semantics of IPC::Connection slightly:
+ Before, there was no untrusted holders of "server" IPC::Connection, e.g. the IPC::Connection instances
+ were never instantiated by WP.
+ After, untrusted WP instantiates these IPC stream dedicated connections.
+ This is accounted in the case where IPC::Connection ensures that IPC::MessageNames::InitializeConnection
+ message is not acted on twice.
+
+ Tested by imported/w3c/web-platform-tests/html/semantics/links/links-created-by-a-and-area-elements/target_blank_implicit_noopener.html
+ --child-processes=1 --experimental-feature=UseGPUProcessForDOMRenderingEnabled=true --iterations=100 --force --simulator
+
+ * GPUProcess/GPUConnectionToWebProcess.cpp:
+ (WebKit::GPUConnectionToWebProcess::createRenderingBackend):
+ * GPUProcess/GPUConnectionToWebProcess.h:
+ * GPUProcess/GPUConnectionToWebProcess.messages.in:
+ * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+ (WebKit::RemoteGraphicsContextGL::initialize):
+ (WebKit::RemoteGraphicsContextGL::stopListeningForIPC):
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::create):
+ (WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
+ (WebKit::RemoteRenderingBackend::startListeningForIPC):
+ (WebKit::RemoteRenderingBackend::stopListeningForIPC):
+ (WebKit::RemoteRenderingBackend::messageSenderConnection const):
+ * GPUProcess/graphics/RemoteRenderingBackend.h:
+ * GPUProcess/graphics/WebGPU/RemoteGPU.cpp:
+ (WebKit::RemoteGPU::initialize):
+ (WebKit::RemoteGPU::stopListeningForIPC):
+ * Platform/IPC/MessageReceiveQueueMap.cpp:
+ (IPC::MessageReceiveQueueMap::addImpl):
+ (IPC::MessageReceiveQueueMap::remove):
+ * Platform/IPC/StreamClientConnection.cpp:
+ (IPC::StreamClientConnection::createWithDedicatedConnection):
+ (IPC::StreamClientConnection::StreamClientConnection):
+ (IPC::StreamClientConnection::~StreamClientConnection):
+ (IPC::StreamClientConnection::open):
+ (IPC::StreamClientConnection::invalidate):
+ (IPC::StreamClientConnection::connectionForTesting):
+ * Platform/IPC/StreamClientConnection.h:
+ (IPC::StreamClientConnection::send):
+ (IPC::StreamClientConnection::sendSync):
+ (IPC::StreamClientConnection::waitForAndDispatchImmediately):
+ (IPC::StreamClientConnection::trySendSyncStream):
+ * Platform/IPC/StreamServerConnection.cpp:
+ (IPC::StreamServerConnection::create):
+ (IPC::StreamServerConnection::createWithDedicatedConnection):
+ (IPC::StreamServerConnectionBase::StreamServerConnectionBase):
+ (IPC::StreamServerConnectionBase::~StreamServerConnectionBase):
+ (IPC::StreamServerConnectionBase::open):
+ (IPC::StreamServerConnectionBase::invalidate):
+ (IPC::StreamServerConnectionBase::startReceivingMessagesImpl):
+ (IPC::StreamServerConnectionBase::stopReceivingMessagesImpl):
+ * Platform/IPC/StreamServerConnection.h:
+ * Shared/IPCStreamTester.cpp:
+ (WebKit::IPCStreamTester::initialize):
+ (WebKit::IPCStreamTester::stopListeningForIPC):
+ * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
+ (WebKit::RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy):
+ (WebKit::RemoteGraphicsContextGLProxy::disconnectGpuProcessIfNeeded):
+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
+ (WebKit::RemoteRenderingBackendProxy::ensureGPUProcessConnection):
+ (WebKit::RemoteRenderingBackendProxy::disconnectGPUProcess):
+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
+ * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:
+ (WebKit::RemoteGPUProxy::RemoteGPUProxy):
+ (WebKit::RemoteGPUProxy::abandonGPUProcess):
+ * WebProcess/WebPage/IPCTestingAPI.cpp:
+ (WebKit::IPCTestingAPI::JSIPCStreamClientConnection::sendMessage):
+ (WebKit::IPCTestingAPI::JSIPCStreamClientConnection::sendSyncMessage):
+
2022-04-12 Wenson Hsieh <wenson_hs...@apple.com>
Remove support for drawing cropped image overlays when hovering over "Copy Cropped Image"
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -538,10 +538,10 @@
}
#endif
-void GPUConnectionToWebProcess::createRenderingBackend(RemoteRenderingBackendCreationParameters&& creationParameters, IPC::StreamConnectionBuffer&& streamBuffer)
+void GPUConnectionToWebProcess::createRenderingBackend(RemoteRenderingBackendCreationParameters&& creationParameters, IPC::Attachment&& connectionIdentifier, IPC::StreamConnectionBuffer&& streamBuffer)
{
auto addResult = m_remoteRenderingBackendMap.ensure(creationParameters.identifier, [&]() {
- return IPC::ScopedActiveMessageReceiveQueue { RemoteRenderingBackend::create(*this, WTFMove(creationParameters), WTFMove(streamBuffer)) };
+ return IPC::ScopedActiveMessageReceiveQueue { RemoteRenderingBackend::create(*this, WTFMove(creationParameters), WTFMove(connectionIdentifier), WTFMove(streamBuffer)) };
});
ASSERT_UNUSED(addResult, addResult.isNewEntry);
}
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2022-04-13 07:29:16 UTC (rev 292803)
@@ -224,7 +224,7 @@
RemoteMediaRecorderManager& mediaRecorderManager();
#endif
- void createRenderingBackend(RemoteRenderingBackendCreationParameters&&, IPC::StreamConnectionBuffer&&);
+ void createRenderingBackend(RemoteRenderingBackendCreationParameters&&, IPC::Attachment&&, IPC::StreamConnectionBuffer&&);
void releaseRenderingBackend(RenderingBackendIdentifier);
#if ENABLE(WEBGL)
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in 2022-04-13 07:29:16 UTC (rev 292803)
@@ -23,7 +23,7 @@
#if ENABLE(GPU_PROCESS)
messages -> GPUConnectionToWebProcess WantsDispatchMessage {
- void CreateRenderingBackend(struct WebKit::RemoteRenderingBackendCreationParameters creationParameters, IPC::StreamConnectionBuffer streamBuffer)
+ void CreateRenderingBackend(struct WebKit::RemoteRenderingBackendCreationParameters creationParameters, IPC::Attachment connectionIdentifier, IPC::StreamConnectionBuffer streamBuffer)
void ReleaseRenderingBackend(WebKit::RenderingBackendIdentifier renderingBackendIdentifier)
#if ENABLE(WEBGL)
void CreateGraphicsContextGL(struct WebCore::GraphicsContextGLAttributes attributes, WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier, WebKit::RenderingBackendIdentifier renderingBackendIdentifier, IPC::StreamConnectionBuffer stream)
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -86,6 +86,7 @@
void RemoteGraphicsContextGL::initialize(GraphicsContextGLAttributes&& attributes)
{
assertIsMainRunLoop();
+ m_streamConnection->open();
remoteGraphicsContextGLStreamWorkQueue().dispatch([attributes = WTFMove(attributes), protectedThis = Ref { *this }]() mutable {
protectedThis->workQueueInitialize(WTFMove(attributes));
});
@@ -95,6 +96,7 @@
void RemoteGraphicsContextGL::stopListeningForIPC(Ref<RemoteGraphicsContextGL>&& refFromConnection)
{
assertIsMainRunLoop();
+ m_streamConnection->invalidate();
m_streamConnection->stopReceivingMessages(Messages::RemoteGraphicsContextGL::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64());
remoteGraphicsContextGLStreamWorkQueue().dispatch([protectedThis = WTFMove(refFromConnection)]() {
protectedThis->workQueueUninitialize();
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -80,16 +80,16 @@
namespace WebKit {
using namespace WebCore;
-Ref<RemoteRenderingBackend> RemoteRenderingBackend::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& creationParameters, IPC::StreamConnectionBuffer&& streamBuffer)
+Ref<RemoteRenderingBackend> RemoteRenderingBackend::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& creationParameters, IPC::Attachment&& connectionIdentifier, IPC::StreamConnectionBuffer&& streamBuffer)
{
- auto instance = adoptRef(*new RemoteRenderingBackend(gpuConnectionToWebProcess, WTFMove(creationParameters), WTFMove(streamBuffer)));
+ auto instance = adoptRef(*new RemoteRenderingBackend(gpuConnectionToWebProcess, WTFMove(creationParameters), WTFMove(connectionIdentifier), WTFMove(streamBuffer)));
instance->startListeningForIPC();
return instance;
}
-RemoteRenderingBackend::RemoteRenderingBackend(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& creationParameters, IPC::StreamConnectionBuffer&& streamBuffer)
+RemoteRenderingBackend::RemoteRenderingBackend(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& creationParameters, IPC::Attachment&& connectionIdentifier, IPC::StreamConnectionBuffer&& streamBuffer)
: m_workQueue(IPC::StreamConnectionWorkQueue::create("RemoteRenderingBackend work queue"))
- , m_streamConnection(IPC::StreamServerConnection::create(gpuConnectionToWebProcess.connection(), WTFMove(streamBuffer), m_workQueue.get()))
+ , m_streamConnection(IPC::StreamServerConnection::createWithDedicatedConnection(WTFMove(connectionIdentifier), WTFMove(streamBuffer), m_workQueue.get()))
, m_remoteResourceCache(gpuConnectionToWebProcess.webProcessIdentifier())
, m_gpuConnectionToWebProcess(gpuConnectionToWebProcess)
, m_resourceOwner(gpuConnectionToWebProcess.webProcessIdentity())
@@ -110,17 +110,14 @@
Locker locker { m_remoteDisplayListsLock };
m_canRegisterRemoteDisplayLists = true;
}
-
m_streamConnection->startReceivingMessages(*this, Messages::RemoteRenderingBackend::messageReceiverName(), m_renderingBackendIdentifier.toUInt64());
- // RemoteDisplayListRecorder messages depend on RemoteRenderingBackend, because RemoteRenderingBackend creates RemoteDisplayListRecorder and
- // makes a receive queue for it. In order to guarantee correct ordering, ensure that all RemoteDisplayListRecorder messages are processed in
- // the same sequence as RemoteRenderingBackend messages.
- m_streamConnection->startReceivingMessages(Messages::RemoteDisplayListRecorder::messageReceiverName());
+ m_streamConnection->open();
}
void RemoteRenderingBackend::stopListeningForIPC()
{
ASSERT(RunLoop::isMain());
+ m_streamConnection->invalidate();
// This item is dispatched to the WorkQueue before calling stopAndWaitForCompletion() such that it will process it last, after any existing work.
m_workQueue->dispatch([&] {
@@ -132,7 +129,6 @@
m_workQueue->stopAndWaitForCompletion();
m_streamConnection->stopReceivingMessages(Messages::RemoteRenderingBackend::messageReceiverName(), m_renderingBackendIdentifier.toUInt64());
- m_streamConnection->stopReceivingMessages(Messages::RemoteDisplayListRecorder::messageReceiverName());
{
Locker locker { m_remoteDisplayListsLock };
@@ -149,7 +145,7 @@
IPC::Connection* RemoteRenderingBackend::messageSenderConnection() const
{
- return &m_gpuConnectionToWebProcess->connection();
+ return &m_streamConnection->connection();
}
uint64_t RemoteRenderingBackend::messageSenderDestinationID() const
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2022-04-13 07:29:16 UTC (rev 292803)
@@ -78,7 +78,7 @@
class RemoteRenderingBackend : private IPC::MessageSender, public IPC::StreamMessageReceiver {
public:
- static Ref<RemoteRenderingBackend> create(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&, IPC::StreamConnectionBuffer&&);
+ static Ref<RemoteRenderingBackend> create(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&, IPC::Attachment&&, IPC::StreamConnectionBuffer&&);
virtual ~RemoteRenderingBackend();
void stopListeningForIPC();
@@ -106,7 +106,7 @@
#endif
private:
- RemoteRenderingBackend(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&, IPC::StreamConnectionBuffer&&);
+ RemoteRenderingBackend(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&, IPC::Attachment&&, IPC::StreamConnectionBuffer&&);
void startListeningForIPC();
std::optional<SharedMemory::IPCHandle> updateSharedMemoryForGetPixelBufferHelper(size_t byteCount);
Modified: trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp (292802 => 292803)
--- trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -60,6 +60,7 @@
void RemoteGPU::initialize()
{
assertIsMainRunLoop();
+ m_streamConnection->open();
workQueue().dispatch([protectedThis = Ref { *this }]() mutable {
protectedThis->workQueueInitialize();
});
@@ -69,6 +70,7 @@
void RemoteGPU::stopListeningForIPC(Ref<RemoteGPU>&& refFromConnection)
{
assertIsMainRunLoop();
+ m_streamConnection->invalidate();
m_streamConnection->stopReceivingMessages(Messages::RemoteGPU::messageReceiverName(), m_identifier.toUInt64());
workQueue().dispatch([protectedThis = WTFMove(refFromConnection)]() {
protectedThis->workQueueUninitialize();
Modified: trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.cpp (292802 => 292803)
--- trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Platform/IPC/MessageReceiveQueueMap.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -39,10 +39,7 @@
uint8_t receiverName = static_cast<uint8_t>(*matcher.receiverName);
if (!matcher.destinationID.has_value()) {
auto result = m_anyIDQueues.add(receiverName, WTFMove(queue));
- if (!result.isNewEntry) {
- // FIXME: This should be an assertion. See webkit.org/b/237674 and webkit.org/b/238391.
- ALWAYS_LOG_WITH_STREAM(stream << "MessageReceiveQueueMap::addImpl - adding duplicate any id receiver " << static_cast<uint8_t>(receiverName));
- }
+ ASSERT_UNUSED(result, result.isNewEntry);
return;
}
auto result = m_queues.add(std::make_pair(receiverName, *matcher.destinationID), WTFMove(queue));
@@ -59,10 +56,7 @@
uint8_t receiverName = static_cast<uint8_t>(*matcher.receiverName);
if (!matcher.destinationID.has_value()) {
auto result = m_anyIDQueues.remove(receiverName);
- if (result) {
- // FIXME: This should be an assertion. See webkit.org/b/237674 and webkit.org/b/238391.
- ALWAYS_LOG_WITH_STREAM(stream << "MessageReceiveQueueMap::addImpl - adding duplicate any id receiver " << static_cast<uint8_t>(receiverName));
- }
+ ASSERT_UNUSED(result, result);
return;
}
auto result = m_queues.remove(std::make_pair(receiverName, *matcher.destinationID));
Modified: trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp (292802 => 292803)
--- trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -28,10 +28,46 @@
namespace IPC {
-StreamClientConnection::StreamClientConnection(Connection& connection, size_t size)
- : m_connection(connection)
- , m_buffer(size)
+// FIXME(http://webkit.org/b/238986): Workaround for not being able to deliver messages from the dedicated connection to the work queue the client uses.
+class StreamClientConnection::DedicatedConnectionClient final : public Connection::Client {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(DedicatedConnectionClient);
+public:
+ DedicatedConnectionClient(MessageReceiver& receiver)
+ : m_receiver(receiver)
+ {
+ }
+ // Connection::Client.
+ void didReceiveMessage(Connection& connection, Decoder& decoder) final { m_receiver.didReceiveMessage(connection, decoder); }
+ bool didReceiveSyncMessage(Connection& connection, Decoder& decoder, UniqueRef<Encoder>& replyEncoder) final { return m_receiver.didReceiveSyncMessage(connection, decoder, replyEncoder); }
+ void didClose(Connection&) final { } // Client is expected to listen to Connection::didClose() from the connection it sent to the dedicated connection to.
+ void didReceiveInvalidMessage(Connection&, MessageName) final { ASSERT_NOT_REACHED(); } // The sender is expected to be trusted, so all invalid messages are programming errors.
+private:
+ MessageReceiver& m_receiver;
+};
+
+StreamClientConnection::StreamConnectionWithDedicatedConnection StreamClientConnection::createWithDedicatedConnection(MessageReceiver& receiver, size_t bufferSize)
{
+ auto connectionIdentifiers = Connection::createConnectionIdentifierPair();
+ // Create StreamClientConnection with "server" type Connection. The caller will send the "client" type connection identifier via
+ // IPC to the other side, where StreamServerConnection will be created with "client" type Connection.
+ // For Connection, "server" means the connection which was created first, the connection which is not sent through IPC to other party.
+ // For Connection, "client" means the connection which was established by receiving it through IPC and creating IPC::Connection out from the identifier.
+ // The "Client" in StreamClientConnection means the party that mostly does sending, e.g. untrusted party.
+ // The "Server" in StreamServerConnection means the party that mostly does receiving, e.g. the trusted party which holds the destination object to communicate with.
+ auto dedicatedConnectionClient = makeUnique<DedicatedConnectionClient>(receiver);
+ auto dedicatedConnection = Connection::createServerConnection(connectionIdentifiers->server, *dedicatedConnectionClient);
+ std::unique_ptr<StreamClientConnection> streamConnection { new StreamClientConnection(WTFMove(dedicatedConnection), bufferSize, WTFMove(dedicatedConnectionClient)) };
+ // FIXME(http://webkit.org/b238944): Make IPC::Attachment really movable on OS(DARWIN).
+ return { WTFMove(streamConnection), WTFMove(connectionIdentifiers->client) };
+#
+}
+
+StreamClientConnection::StreamClientConnection(Ref<Connection>&& connection, size_t bufferSize, std::unique_ptr<DedicatedConnectionClient>&& dedicatedConnectionClient)
+ : m_connection(WTFMove(connection))
+ , m_dedicatedConnectionClient(WTFMove(dedicatedConnectionClient))
+ , m_buffer(bufferSize)
+{
// Read starts from 0 with limit of 0 and reader sleeping.
sharedClientOffset().store(ClientOffset::serverIsSleepingTag, std::memory_order_relaxed);
// Write starts from 0 with a limit of the whole buffer.
@@ -38,6 +74,28 @@
sharedClientLimit().store(static_cast<ClientLimit>(0), std::memory_order_relaxed);
}
+StreamClientConnection::StreamClientConnection(Connection& connection, size_t bufferSize)
+ : StreamClientConnection(Ref { connection }, bufferSize, { })
+{
+}
+
+StreamClientConnection::~StreamClientConnection()
+{
+ ASSERT(!m_dedicatedConnectionClient || !m_connection->isValid());
+}
+
+void StreamClientConnection::open()
+{
+ if (m_dedicatedConnectionClient)
+ m_connection->open();
+}
+
+void StreamClientConnection::invalidate()
+{
+ if (m_dedicatedConnectionClient)
+ m_connection->invalidate();
+}
+
void StreamClientConnection::setWakeUpSemaphore(IPC::Semaphore&& semaphore)
{
m_wakeUpSemaphore = WTFMove(semaphore);
@@ -83,4 +141,9 @@
return m_buffer;
}
+Connection& StreamClientConnection::connectionForTesting()
+{
+ return m_connection.get();
}
+
+}
Modified: trunk/Source/WebKit/Platform/IPC/StreamClientConnection.h (292802 => 292803)
--- trunk/Source/WebKit/Platform/IPC/StreamClientConnection.h 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Platform/IPC/StreamClientConnection.h 2022-04-13 07:29:16 UTC (rev 292803)
@@ -57,8 +57,31 @@
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(StreamClientConnection);
public:
+ // Creates StreamClientConnection where the out of stream messages and server replies are
+ // sent through the passed IPC::Connection. The messages from the server are delivered to
+ // the caller through the passed IPC::Connection.
+ // Note: This function should be used only in cases where the
+ // stream server starts listening to messages with new identifiers on the same thread as
+ // in which the server IPC::Connection dispatch messages. At the time of writing,
+ // IPC::Connection dispatches messages only in main thread.
StreamClientConnection(Connection&, size_t bufferSize);
+ struct StreamConnectionWithDedicatedConnection {
+ std::unique_ptr<StreamClientConnection> streamConnection;
+ Attachment connectionIdentifier;
+ // FIXME: Once IPC can treat handles as first class objects, add stream buffer as
+ // a handle here.
+ };
+
+ // Creates StreamClientConnection where the out of stream messages and server replies are
+ // sent through a dedidcated, new IPC::Connection. The messages from the server are delivered to
+ // the caller through the passed IPC::MessageReceiver.
+ // The caller should send StreamConnectionWithDedicatedConnection::connectionIdentifier and
+ // StreamClientConnection::streamBuffer() to the server via an existing IPC::Connection.
+ static StreamConnectionWithDedicatedConnection createWithDedicatedConnection(MessageReceiver&, size_t bufferSize);
+
+ ~StreamClientConnection();
+
StreamConnectionBuffer& streamBuffer() { return m_buffer; }
void setWakeUpSemaphore(IPC::Semaphore&&);
bool hasWakeUpSemaphore() const { return m_wakeUpSemaphore.has_value(); }
@@ -70,6 +93,9 @@
}
void sendDeferredWakeUpMessageIfNeeded();
+ void open();
+ void invalidate();
+
template<typename T, typename U> bool send(T&& message, ObjectIdentifier<U> destinationID, Timeout);
using SendSyncResult = Connection::SendSyncResult;
@@ -80,9 +106,11 @@
bool waitForAndDispatchImmediately(ObjectIdentifier<U> destinationID, Timeout, OptionSet<WaitForOption> = { });
StreamConnectionBuffer& bufferForTesting();
+ Connection& connectionForTesting();
private:
- friend class WebKit::IPCTestingAPI::JSIPCStreamClientConnection;
+ class DedicatedConnectionClient;
+ StreamClientConnection(Ref<Connection>&&, size_t bufferSize, std::unique_ptr<DedicatedConnectionClient>&&);
struct Span {
uint8_t* data;
@@ -122,14 +150,16 @@
uint8_t* data() const { return m_buffer.data(); }
size_t dataSize() const { return m_buffer.dataSize(); }
- Connection& m_connection;
+ Ref<Connection> m_connection;
+ std::unique_ptr<DedicatedConnectionClient> m_dedicatedConnectionClient;
uint64_t m_currentDestinationID { 0 };
-
size_t m_clientOffset { 0 };
StreamConnectionBuffer m_buffer;
std::optional<Semaphore> m_wakeUpSemaphore;
unsigned m_remainingMessageCountBeforeSendingWakeUp { 0 };
unsigned m_wakeUpMessageHysteresis { 0 };
+
+ friend class WebKit::IPCTestingAPI::JSIPCStreamClientConnection;
};
template<typename T, typename U>
@@ -146,7 +176,7 @@
return true;
}
sendProcessOutOfStreamMessage(WTFMove(*span));
- if (!m_connection.send(WTFMove(message), destinationID, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply))
+ if (!m_connection->send(WTFMove(message), destinationID, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply))
return false;
return true;
}
@@ -181,13 +211,13 @@
return WTFMove(*maybeSendResult);
}
sendProcessOutOfStreamMessage(WTFMove(*span));
- return m_connection.sendSync(WTFMove(message), WTFMove(reply), destinationID.toUInt64(), timeout);
+ return m_connection->sendSync(WTFMove(message), WTFMove(reply), destinationID.toUInt64(), timeout);
}
template<typename T, typename U>
bool StreamClientConnection::waitForAndDispatchImmediately(ObjectIdentifier<U> destinationID, Timeout timeout, OptionSet<WaitForOption> waitForOptions)
{
- return m_connection.waitForAndDispatchImmediately<T>(destinationID, timeout, waitForOptions);
+ return m_connection->waitForAndDispatchImmediately<T>(destinationID, timeout, waitForOptions);
}
template<typename T>
@@ -195,8 +225,8 @@
{
// In this function, SendSyncResult { } means error happened and caller should stop processing.
// std::nullopt means we couldn't send through the stream, so try sending out of stream.
- auto syncRequestID = m_connection.makeSyncRequestID();
- if (!m_connection.pushPendingSyncRequestID(syncRequestID))
+ auto syncRequestID = m_connection->makeSyncRequestID();
+ if (!m_connection->pushPendingSyncRequestID(syncRequestID))
return SendSyncResult { };
auto result = [&]() -> std::optional<SendSyncResult> {
@@ -220,9 +250,9 @@
}
} else
m_clientOffset = 0;
- return m_connection.waitForSyncReply(syncRequestID, T::name(), timeout, { });
+ return m_connection->waitForSyncReply(syncRequestID, T::name(), timeout, { });
}();
- m_connection.popPendingSyncRequestID(syncRequestID);
+ m_connection->popPendingSyncRequestID(syncRequestID);
if (result && *result) {
auto& decoder = **result;
std::optional<typename T::ReplyArguments> replyArguments;
Modified: trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp (292802 => 292803)
--- trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -28,16 +28,83 @@
#include "Connection.h"
#include "StreamConnectionWorkQueue.h"
-
+#include <mutex>
+#include <wtf/NeverDestroyed.h>
namespace IPC {
+namespace {
+// FIXME(http://webkit.org/b/238986): Workaround for not being able to deliver messages from the dedicated connection to the work queue the client uses.
+class DedicatedConnectionClient final : public Connection::Client {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(DedicatedConnectionClient);
+public:
+ DedicatedConnectionClient() = default;
+ // Connection::Client.
+ void didReceiveMessage(Connection& connection, Decoder& decoder) final { ASSERT_NOT_REACHED(); }
+ bool didReceiveSyncMessage(Connection& connection, Decoder& decoder, UniqueRef<Encoder>& replyEncoder) final { ASSERT_NOT_REACHED(); return false; }
+ void didClose(Connection&) final { } // Client is expected to listen to Connection::didClose() from the connection it sent to the dedicated connection to.
+ void didReceiveInvalidMessage(Connection&, MessageName) final { ASSERT_NOT_REACHED(); } // The sender is expected to be trusted, so all invalid messages are programming errors.
+private:
+};
-StreamServerConnection::StreamServerConnection(Connection& connection, StreamConnectionBuffer&& stream, StreamConnectionWorkQueue& workQueue)
- : m_connection(connection)
+}
+
+Ref<StreamServerConnection> StreamServerConnection::create(Connection& connection, StreamConnectionBuffer&& streamBuffer, StreamConnectionWorkQueue& workQueue)
+{
+ return adoptRef(*new StreamServerConnection(Ref { connection }, WTFMove(streamBuffer), workQueue, HasDedicatedConnection::No));
+}
+
+Ref<StreamServerConnection> StreamServerConnection::createWithDedicatedConnection(Attachment&& connectionIdentifier, StreamConnectionBuffer&& streamBuffer, StreamConnectionWorkQueue& workQueue)
+{
+#if USE(UNIX_DOMAIN_SOCKETS)
+ IPC::Connection::Identifier connectionHandle { connectionIdentifier.release().release() };
+#elif OS(DARWIN)
+ IPC::Connection::Identifier connectionHandle { connectionIdentifier.port() };
+#elif OS(WINDOWS)
+ IPC::Connection::Identifier connectionHandle { connectionIdentifier.handle() };
+#else
+ notImplemented();
+ IPC::Connection::Identifier connectionHandle { };
+#endif
+ static LazyNeverDestroyed<DedicatedConnectionClient> s_dedicatedConnectionClient;
+ static std::once_flag s_onceFlag;
+ std::call_once(s_onceFlag, [] {
+ s_dedicatedConnectionClient.construct();
+ });
+ auto connection = IPC::Connection::createClientConnection(connectionHandle, s_dedicatedConnectionClient.get());
+ auto streamConnection = adoptRef(*new StreamServerConnection(WTFMove(connection), WTFMove(streamBuffer), workQueue, HasDedicatedConnection::Yes));
+ return streamConnection;
+}
+
+StreamServerConnection::StreamServerConnection(Ref<Connection>&& connection, StreamConnectionBuffer&& stream, StreamConnectionWorkQueue& workQueue, HasDedicatedConnection hasDedicatedConnection)
+ : m_connection(WTFMove(connection))
, m_workQueue(workQueue)
, m_buffer(WTFMove(stream))
+ , m_hasDedicatedConnection(hasDedicatedConnection == HasDedicatedConnection::Yes)
{
}
+StreamServerConnection::~StreamServerConnection()
+{
+ ASSERT(!m_hasDedicatedConnection || !m_connection->isValid());
+}
+
+void StreamServerConnection::open()
+{
+ if (m_hasDedicatedConnection) {
+ // FIXME(http://webkit.org/b/238986): Workaround for not being able to deliver messages from the dedicated connection to the work queue the client uses.
+ m_connection->addMessageReceiveQueue(*this, { });
+ m_connection->open();
+ }
+}
+
+void StreamServerConnection::invalidate()
+{
+ if (m_hasDedicatedConnection) {
+ m_connection->removeMessageReceiveQueue({ });
+ m_connection->invalidate();
+ }
+}
+
void StreamServerConnection::startReceivingMessages(StreamMessageReceiver& receiver, ReceiverName receiverName, uint64_t destinationID)
{
{
@@ -47,30 +114,15 @@
m_receivers.add(key, receiver);
}
- // FIXME: Can we avoid synchronous dispatch here by adjusting the assertion in `Connection::enqueueMatchingMessagesToMessageReceiveQueue`?
- callOnMainRunLoopAndWait([&] {
+ if (!m_hasDedicatedConnection)
m_connection->addMessageReceiveQueue(*this, { receiverName, destinationID });
- });
m_workQueue.addStreamConnection(*this);
}
-void StreamServerConnection::startReceivingMessages(ReceiverName receiverName)
-{
- callOnMainRunLoopAndWait([&] {
- m_connection->addMessageReceiveQueue(*this, { receiverName });
- });
- m_workQueue.addStreamConnection(*this);
-}
-
-void StreamServerConnection::stopReceivingMessages(ReceiverName receiverName)
-{
- m_connection->removeMessageReceiveQueue({ receiverName });
- m_workQueue.removeStreamConnection(*this);
-}
-
void StreamServerConnection::stopReceivingMessages(ReceiverName receiverName, uint64_t destinationID)
{
- m_connection->removeMessageReceiveQueue({ receiverName, destinationID });
+ if (!m_hasDedicatedConnection)
+ m_connection->removeMessageReceiveQueue({ receiverName, destinationID });
m_workQueue.removeStreamConnection(*this);
auto key = std::make_pair(static_cast<uint8_t>(receiverName), destinationID);
Modified: trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h (292802 => 292803)
--- trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h 2022-04-13 07:29:16 UTC (rev 292803)
@@ -53,19 +53,25 @@
class StreamServerConnection final : public ThreadSafeRefCounted<StreamServerConnection>, private MessageReceiveQueue {
WTF_MAKE_NONCOPYABLE(StreamServerConnection);
public:
- static Ref<StreamServerConnection> create(Connection& connection, StreamConnectionBuffer&& streamBuffer, StreamConnectionWorkQueue& workQueue)
- {
- return adoptRef(*new StreamServerConnection(connection, WTFMove(streamBuffer), workQueue));
- }
- ~StreamServerConnection() final = default;
+ // Creates StreamClientConnection where the out of stream messages and server replies are
+ // received through the passed IPC::Connection. The messages from the server are sent to
+ // the passed IPC::Connection.
+ // Note: This function should be used only in cases where the
+ // stream server starts listening to messages with new identifiers on the same thread as
+ // in which the server IPC::Connection dispatch messages. At the time of writing,
+ // IPC::Connection dispatches messages only in main thread.
+ static Ref<StreamServerConnection> create(Connection&, StreamConnectionBuffer&&, StreamConnectionWorkQueue&);
+ // Creates StreamServerConnection where the out of stream messages and server replies are
+ // received through a dedidcated, new IPC::Connection. The messages from the server are sent to
+ // the dedicated conneciton.
+ static Ref<StreamServerConnection> createWithDedicatedConnection(Attachment&& connectionIdentifier, StreamConnectionBuffer&&, StreamConnectionWorkQueue&);
+ ~StreamServerConnection() final;
+
void startReceivingMessages(StreamMessageReceiver&, ReceiverName, uint64_t destinationID);
// Stops the message receipt. Note: already received messages might still be delivered.
void stopReceivingMessages(ReceiverName, uint64_t destinationID);
- void startReceivingMessages(ReceiverName);
- void stopReceivingMessages(ReceiverName);
-
Connection& connection() { return m_connection; }
enum DispatchResult : bool {
@@ -74,11 +80,15 @@
};
DispatchResult dispatchStreamMessages(size_t messageLimit);
+ void open();
+ void invalidate();
+
template<typename T, typename... Arguments>
void sendSyncReply(Connection::SyncRequestID, Arguments&&...);
private:
- StreamServerConnection(IPC::Connection&, StreamConnectionBuffer&&, StreamConnectionWorkQueue&);
+ enum class HasDedicatedConnection : bool { No, Yes };
+ StreamServerConnection(Ref<Connection>&&, StreamConnectionBuffer&&, StreamConnectionWorkQueue&, HasDedicatedConnection);
// MessageReceiveQueue
void enqueueMessage(Connection&, std::unique_ptr<Decoder>&&) final;
@@ -119,6 +129,7 @@
Deque<std::unique_ptr<Decoder>> m_outOfStreamMessages WTF_GUARDED_BY_LOCK(m_outOfStreamMessagesLock);
bool m_isDispatchingStreamMessage { false };
+ const bool m_hasDedicatedConnection;
Lock m_receiversLock;
using ReceiversMap = HashMap<std::pair<uint8_t, uint64_t>, Ref<StreamMessageReceiver>>;
ReceiversMap m_receivers WTF_GUARDED_BY_LOCK(m_receiversLock);
Modified: trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm (292802 => 292803)
--- trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm 2022-04-13 07:29:16 UTC (rev 292803)
@@ -27,6 +27,7 @@
#import "Connection.h"
#import "DataReference.h"
+#import "IPCTester.h"
#import "ImportanceAssertion.h"
#import "Logging.h"
#import "MachMessage.h"
@@ -558,11 +559,14 @@
#if PLATFORM(MAC)
decoder->setImportanceAssertion(ImportanceAssertion { header });
#endif
-
+
if (decoder->messageName() == MessageName::InitializeConnection) {
ASSERT(m_isServer);
- ASSERT(!m_isConnected);
ASSERT(!m_sendPort);
+ if (m_isConnected) {
+ ASSERT_IS_TESTING_IPC();
+ return;
+ }
MachPort port;
if (!decoder->decode(port)) {
Modified: trunk/Source/WebKit/Shared/IPCStreamTester.cpp (292802 => 292803)
--- trunk/Source/WebKit/Shared/IPCStreamTester.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Shared/IPCStreamTester.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -55,6 +55,7 @@
void IPCStreamTester::initialize()
{
m_streamConnection->startReceivingMessages(*this, Messages::IPCStreamTester::messageReceiverName(), m_identifier.toUInt64());
+ m_streamConnection->open();
workQueue().dispatch([this] {
m_streamConnection->connection().send(Messages::IPCStreamTesterProxy::WasCreated(workQueue().wakeUpSemaphore()), m_identifier);
});
@@ -62,6 +63,7 @@
void IPCStreamTester::stopListeningForIPC(Ref<IPCStreamTester>&& refFromConnection)
{
+ m_streamConnection->invalidate();
m_streamConnection->stopReceivingMessages(Messages::IPCStreamTester::messageReceiverName(), m_identifier.toUInt64());
workQueue().stopAndWaitForCompletion();
}
Modified: trunk/Source/WebKit/Shared/IPCTester.h (292802 => 292803)
--- trunk/Source/WebKit/Shared/IPCTester.h 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/Shared/IPCTester.h 2022-04-13 07:29:16 UTC (rev 292803)
@@ -44,7 +44,7 @@
namespace WebKit {
-#define ASSERT_IS_TESTING_IPC() ASSERT(isTestingIPC(), "Untrusted connection sent invalid data. Should only happen when testing IPC.")
+#define ASSERT_IS_TESTING_IPC() ASSERT(WebKit::isTestingIPC(), "Untrusted connection sent invalid data. Should only happen when testing IPC.")
#if ENABLE(IPC_TESTING_API)
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp (292802 => 292803)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -55,6 +55,7 @@
m_gpuProcessConnection->addClient(*this);
m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::RemoteGraphicsContextGLProxy::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64(), *this);
m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::CreateGraphicsContextGL(attributes, m_graphicsContextGLIdentifier, renderingBackend, m_streamConnection.streamBuffer()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_streamConnection.open();
// TODO: We must wait until initialized, because at the moment we cannot receive IPC messages
// during wait while in synchronous stream send. Should be fixed as part of https://bugs.webkit.org/show_bug.cgi?id=217211.
waitUntilInitialized();
@@ -337,6 +338,7 @@
void RemoteGraphicsContextGLProxy::disconnectGpuProcessIfNeeded()
{
if (auto gpuProcessConnection = std::exchange(m_gpuProcessConnection, nullptr)) {
+ m_streamConnection.invalidate();
gpuProcessConnection->removeClient(*this);
gpuProcessConnection->messageReceiverMap().removeMessageReceiver(Messages::RemoteGraphicsContextGLProxy::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64());
gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseGraphicsContextGL(m_graphicsContextGLIdentifier), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (292802 => 292803)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -70,13 +70,14 @@
GPUProcessConnection& RemoteRenderingBackendProxy::ensureGPUProcessConnection()
{
if (!m_gpuProcessConnection) {
- auto& gpuProcessConnection = WebProcess::singleton().ensureGPUProcessConnection();
- gpuProcessConnection.addClient(*this);
- gpuProcessConnection.messageReceiverMap().addMessageReceiver(Messages::RemoteRenderingBackendProxy::messageReceiverName(), renderingBackendIdentifier().toUInt64(), *this);
+ m_gpuProcessConnection = &WebProcess::singleton().ensureGPUProcessConnection();
+ m_gpuProcessConnection->addClient(*this);
+
static constexpr auto connectionBufferSize = 1 << 21;
- m_streamConnection = makeUnique<IPC::StreamClientConnection>(gpuProcessConnection.connection(), connectionBufferSize);
- gpuProcessConnection.connection().send(Messages::GPUConnectionToWebProcess::CreateRenderingBackend(m_parameters, m_streamConnection->streamBuffer()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
- m_gpuProcessConnection = gpuProcessConnection;
+ auto [streamConnection, dedicatedConnectionClientIdentifer] = IPC::StreamClientConnection::createWithDedicatedConnection(*this, connectionBufferSize);
+ m_streamConnection = WTFMove(streamConnection);
+ m_streamConnection->open();
+ m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::CreateRenderingBackend(m_parameters, dedicatedConnectionClientIdentifer, m_streamConnection->streamBuffer()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
}
return *m_gpuProcessConnection;
}
@@ -101,6 +102,7 @@
m_getPixelBufferSharedMemory = nullptr;
m_renderingUpdateID = { };
m_didRenderingUpdateID = { };
+ m_streamConnection->invalidate();
m_streamConnection = nullptr;
}
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h (292802 => 292803)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h 2022-04-13 07:29:16 UTC (rev 292803)
@@ -172,9 +172,10 @@
void didFlush(WebCore::GraphicsContextFlushIdentifier, WebCore::RenderingResourceIdentifier);
void didFinalizeRenderingUpdate(RenderingUpdateID didRenderingUpdateID);
+ GPUProcessConnection* m_gpuProcessConnection { nullptr };
+ RefPtr<IPC::Connection> m_connection;
std::unique_ptr<IPC::StreamClientConnection> m_streamConnection;
RemoteRenderingBackendCreationParameters m_parameters;
- WeakPtr<GPUProcessConnection> m_gpuProcessConnection;
RemoteResourceCacheProxy m_remoteResourceCacheProxy { *this };
RefPtr<SharedMemory> m_getPixelBufferSharedMemory;
WebCore::Timer m_destroyGetPixelBufferSharedMemoryTimer { *this, &RemoteRenderingBackendProxy::destroyGetPixelBufferSharedMemory };
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp (292802 => 292803)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -51,6 +51,7 @@
m_gpuProcessConnection->addClient(*this);
m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::RemoteGPUProxy::messageReceiverName(), identifier.toUInt64(), *this);
m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::CreateRemoteGPU(identifier, renderingBackend, m_streamConnection.streamBuffer()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_streamConnection.open();
// TODO: We must wait until initialized, because at the moment we cannot receive IPC messages
// during wait while in synchronous stream send. Should be fixed as part of https://bugs.webkit.org/show_bug.cgi?id=217211.
waitUntilInitialized();
@@ -68,6 +69,7 @@
void RemoteGPUProxy::abandonGPUProcess()
{
auto gpuProcessConnection = std::exchange(m_gpuProcessConnection, nullptr);
+ m_streamConnection.invalidate();
gpuProcessConnection->messageReceiverMap().removeMessageReceiver(Messages::RemoteGPUProxy::messageReceiverName(), m_backing.toUInt64());
m_gpuProcessConnection = nullptr;
m_lost = true;
Modified: trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp (292802 => 292803)
--- trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp 2022-04-13 07:29:16 UTC (rev 292803)
@@ -541,10 +541,11 @@
auto [destinationID, messageName, timeout] = *info;
auto& streamConnection = jsStreamConnection->connection();
+ auto& connection = streamConnection.connectionForTesting();
auto encoder = makeUniqueRef<IPC::Encoder>(messageName, destinationID);
if (prepareToSendOutOfStreamMessage(context, argumentCount, arguments, *jsStreamConnection->m_jsIPC, streamConnection, encoder.get(), destinationID, timeout, exception))
- streamConnection.m_connection.sendMessage(WTFMove(encoder), { });
+ connection.sendMessage(WTFMove(encoder), { });
return returnValue;
}
@@ -566,13 +567,14 @@
auto [destinationID, messageName, timeout] = *info;
auto& streamConnection = jsStreamConnection->connection();
+ auto& connection = streamConnection.connectionForTesting();
IPC::Connection::SyncRequestID syncRequestID;
- auto encoder = streamConnection.m_connection.createSyncMessageEncoder(messageName, destinationID, syncRequestID);
+ auto encoder = connection.createSyncMessageEncoder(messageName, destinationID, syncRequestID);
if (!prepareToSendOutOfStreamMessage(context, argumentCount, arguments, *jsStreamConnection->m_jsIPC, streamConnection, encoder.get(), destinationID, timeout, exception))
return JSValueMakeUndefined(context);
- if (auto replyDecoder = streamConnection.m_connection.sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, { })) {
+ if (auto replyDecoder = connection.sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, { })) {
auto scope = DECLARE_CATCH_SCOPE(globalObject->vm());
auto* jsResult = jsResultFromReplyDecoder(globalObject, messageName, *replyDecoder);
if (scope.exception()) {
Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (292802 => 292803)
--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm 2022-04-13 07:20:51 UTC (rev 292802)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm 2022-04-13 07:29:16 UTC (rev 292803)
@@ -379,7 +379,7 @@
Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree message(layerTransaction, scrollingTransaction);
auto commitEncoder = makeUniqueRef<IPC::Encoder>(Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree::name(), m_identifier.toUInt64());
- commitEncoder.get() << message.arguments();
+ commitEncoder.get() << WTFMove(message).arguments();
auto flushers = backingStoreCollection.didFlushLayers(layerTransaction);
RefPtr<BackingStoreFlusher> backingStoreFlusher = BackingStoreFlusher::create(WebProcess::singleton().parentProcessConnection(), WTFMove(commitEncoder), WTFMove(flushers));