Changeset 284695 in webkit
- Timestamp:
- Oct 22, 2021, 11:09:11 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
-
ChangeLog (modified) (1 diff)
-
GPUProcess/graphics/RemoteDisplayListRecorder.cpp (modified) (1 diff)
-
GPUProcess/graphics/RemoteRenderingBackend.cpp (modified) (3 diffs)
-
GPUProcess/graphics/RemoteRenderingBackend.h (modified) (1 diff)
-
GPUProcess/graphics/RemoteRenderingBackend.messages.in (modified) (1 diff)
-
Platform/IPC/StreamConnectionWorkQueue.cpp (modified) (1 diff)
-
Platform/IPC/StreamConnectionWorkQueue.h (modified) (2 diffs)
-
Platform/IPC/StreamServerConnection.cpp (modified) (1 diff)
-
Platform/IPC/StreamServerConnection.h (modified) (3 diffs)
-
WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r284692 r284695 1 2021-10-22 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 RemoteRenderingBackend::CreateImageBuffer should be an async IPC stream message 4 https://bugs.webkit.org/show_bug.cgi?id=231970 5 6 Reviewed by Kimmo Kinnunen. 7 8 This patch reverts the changes in r284476, which worked around a race when adding receive queues for newly 9 created IPC stream destinations and simultaneously dispatching IPC messages to those destinations. Rather than 10 making the IPC message that creates and adds the new image buffer's RemoteDisplayListRecorder synchronous, we 11 instead keep that message async and make adjustments to ensure that incoming out-of-stream IPC messages for 12 RemoteDisplayListRecorder can always be mapped to an appropriate receive queue. See below for more details. 13 14 * GPUProcess/graphics/RemoteDisplayListRecorder.cpp: 15 (WebKit::RemoteDisplayListRecorder::startListeningForIPC): 16 17 Move the main runloop bounce down to `StreamServerConnectionBase::startReceivingMessagesImpl()` instead (to deal 18 with the fact that `addMessageReceiveQueue` currently needs to be invoked on the main runloop). This allows us 19 to call `StreamServerConnection::startReceivingMessages()` from the processing queue while creating a remote 20 image buffer, which (in turn) ensures that incoming out-of-stream messages from the IPC thread will be sent to 21 the correct RemoteDisplayListRecorder destination by the time they're dispatched on the work queue thread. 22 23 * GPUProcess/graphics/RemoteRenderingBackend.cpp: 24 (WebKit::RemoteRenderingBackend::startListeningForIPC): 25 (WebKit::RemoteRenderingBackend::stopListeningForIPC): 26 27 Additionally register a "0-destination" receiver to ensure that all RemoteDisplayListRecorder messages (even 28 without pre-existing destinations) will be enqueued on the same IPC stream connection as this remote rendering 29 backend. 30 31 (WebKit::RemoteRenderingBackend::createImageBuffer): 32 * GPUProcess/graphics/RemoteRenderingBackend.h: 33 * GPUProcess/graphics/RemoteRenderingBackend.messages.in: 34 35 Make `CreateImageBuffer` an async stream message once again. 36 37 * Platform/IPC/StreamConnectionWorkQueue.cpp: 38 (IPC::StreamConnectionWorkQueue::processStreams): 39 * Platform/IPC/StreamConnectionWorkQueue.h: 40 41 Change `m_connections` into a HashCountedSet (from a HashSet), to ensure that the same server connection object 42 can be added to and removed from the work queue multiple times, without removing the connection from the map 43 early. 44 45 * Platform/IPC/StreamServerConnection.cpp: 46 (IPC::StreamServerConnectionBase::startReceivingMessagesImpl): 47 (IPC::StreamServerConnectionBase::stopReceivingMessagesImpl): 48 * Platform/IPC/StreamServerConnection.h: 49 (IPC::StreamServerConnection::startReceivingMessages): 50 (IPC::StreamServerConnection::stopReceivingMessages): 51 52 Add new methods to start and stop receiving all messages for a given ReceiverName, regardless of incoming 53 destination ID. RemoteRenderingBackend now uses this to register a "catch-all" listener for all 54 RemoteDisplayListRecorder messages. 55 56 * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: 57 (WebKit::RemoteRenderingBackendProxy::createRemoteImageBuffer): 58 1 59 2021-10-22 Sihui Liu <sihui_liu@apple.com> 2 60 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp
r284079 r284695 56 56 ASSERT(!m_isListeningForIPC); 57 57 m_isListeningForIPC = true; 58 // FIXME: Can we avoid synchronous dispatch here by adjusting the assertion in `Connection::enqueueMatchingMessagesToMessageReceiveQueue`? 59 callOnMainRunLoopAndWait([&] { 60 m_renderingBackend->streamConnection().startReceivingMessages(*this, Messages::RemoteDisplayListRecorder::messageReceiverName(), m_imageBufferIdentifier.object().toUInt64()); 61 }); 58 m_renderingBackend->streamConnection().startReceivingMessages(*this, Messages::RemoteDisplayListRecorder::messageReceiverName(), m_imageBufferIdentifier.object().toUInt64()); 62 59 } 63 60 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
r284681 r284695 93 93 { 94 94 m_streamConnection->startReceivingMessages(*this, Messages::RemoteRenderingBackend::messageReceiverName(), m_renderingBackendIdentifier.toUInt64()); 95 // RemoteDisplayListRecorder messages depend on RemoteRenderingBackend, because RemoteRenderingBackend creates RemoteDisplayListRecorder and 96 // makes a receive queue for it. In order to guarantee correct ordering, ensure that all RemoteDisplayListRecorder messages are processed in 97 // the same sequence as RemoteRenderingBackend messages. 98 m_streamConnection->startReceivingMessages(Messages::RemoteDisplayListRecorder::messageReceiverName()); 95 99 } 96 100 … … 107 111 ASSERT(RunLoop::isMain()); 108 112 m_streamConnection->stopReceivingMessages(Messages::RemoteRenderingBackend::messageReceiverName(), m_renderingBackendIdentifier.toUInt64()); 113 m_streamConnection->stopReceivingMessages(Messages::RemoteDisplayListRecorder::messageReceiverName()); 109 114 for (auto& remoteContext : std::exchange(m_remoteDisplayLists, { })) 110 115 remoteContext.stopListeningForIPC(); … … 139 144 } 140 145 141 void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, RenderingResourceIdentifier imageBufferResourceIdentifier , CompletionHandler<void()>&& completionHandler)146 void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, RenderingMode renderingMode, float resolutionScale, const DestinationColorSpace& colorSpace, PixelFormat pixelFormat, RenderingResourceIdentifier imageBufferResourceIdentifier) 142 147 { 143 148 // Immediately turn the RenderingResourceIdentifier (which is error-prone) to a QualifiedRenderingResourceIdentifier, 144 149 // and use a helper function to make sure that don't accidentally use the RenderingResourceIdentifier (because the helper function can't see it). 145 150 createImageBufferWithQualifiedIdentifier(logicalSize, renderingMode, resolutionScale, colorSpace, pixelFormat, { imageBufferResourceIdentifier, m_gpuConnectionToWebProcess->webProcessIdentifier() }); 146 completionHandler();147 151 } 148 152 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h
r284476 r284695 102 102 103 103 // Messages to be received. 104 void createImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, float resolutionScale, const WebCore::DestinationColorSpace&, WebCore::PixelFormat, WebCore::RenderingResourceIdentifier , CompletionHandler<void()>&&);104 void createImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, float resolutionScale, const WebCore::DestinationColorSpace&, WebCore::PixelFormat, WebCore::RenderingResourceIdentifier); 105 105 void updateSharedMemoryForGetPixelBuffer(uint32_t byteCount, CompletionHandler<void(const SharedMemory::IPCHandle&)>&&); 106 106 void semaphoreForGetPixelBuffer(CompletionHandler<void(const IPC::Semaphore&)>&&); -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in
r284476 r284695 24 24 25 25 messages -> RemoteRenderingBackend NotRefCounted Stream { 26 CreateImageBuffer(WebCore::FloatSize logicalSize, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::DestinationColorSpace colorSpace, enum:uint8_t WebCore::PixelFormat pixelFormat, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> () Synchronous26 CreateImageBuffer(WebCore::FloatSize logicalSize, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::DestinationColorSpace colorSpace, enum:uint8_t WebCore::PixelFormat pixelFormat, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) 27 27 UpdateSharedMemoryForGetPixelBuffer(uint32_t byteCount) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous NotStreamEncodableReply 28 28 SemaphoreForGetPixelBuffer() -> (IPC::Semaphore semaphore) Synchronous NotStreamEncodableReply -
trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.cpp
r284681 r284695 122 122 do { 123 123 Deque<WTF::Function<void()>> functions; 124 HashSet<Ref<StreamServerConnectionBase>> connections;124 Vector<Ref<StreamServerConnectionBase>> connections; 125 125 { 126 126 Locker locker { m_lock }; 127 127 functions.swap(m_functions); 128 connections = m_connections;128 connections = copyToVector(m_connections.values()); 129 129 } 130 130 for (auto& function : functions) -
trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.h
r284681 r284695 31 31 #include <wtf/Deque.h> 32 32 #include <wtf/FunctionDispatcher.h> 33 #include <wtf/Hash Set.h>33 #include <wtf/HashCountedSet.h> 34 34 #include <wtf/Lock.h> 35 35 #include <wtf/Threading.h> … … 67 67 RefPtr<Thread> m_processingThread WTF_GUARDED_BY_LOCK(m_lock); 68 68 Deque<Function<void()>> m_functions WTF_GUARDED_BY_LOCK(m_lock); 69 Hash Set<Ref<StreamServerConnectionBase>> m_connections WTF_GUARDED_BY_LOCK(m_lock);69 HashCountedSet<Ref<StreamServerConnectionBase>> m_connections WTF_GUARDED_BY_LOCK(m_lock); 70 70 }; 71 71 -
trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp
r283713 r284695 41 41 void StreamServerConnectionBase::startReceivingMessagesImpl(ReceiverName receiverName, uint64_t destinationID) 42 42 { 43 m_connection->addMessageReceiveQueue(*this, receiverName, destinationID); 43 // FIXME: Can we avoid synchronous dispatch here by adjusting the assertion in `Connection::enqueueMatchingMessagesToMessageReceiveQueue`? 44 callOnMainRunLoopAndWait([&] { 45 m_connection->addMessageReceiveQueue(*this, receiverName, destinationID); 46 }); 44 47 m_workQueue.addStreamConnection(*this); 48 } 49 50 void StreamServerConnectionBase::startReceivingMessagesImpl(ReceiverName receiverName) 51 { 52 callOnMainRunLoopAndWait([&] { 53 m_connection->addMessageReceiveQueue(*this, receiverName); 54 }); 55 m_workQueue.addStreamConnection(*this); 56 } 57 58 void StreamServerConnectionBase::stopReceivingMessagesImpl(ReceiverName receiverName) 59 { 60 m_connection->removeMessageReceiveQueue(receiverName); 61 m_workQueue.removeStreamConnection(*this); 45 62 } 46 63 -
trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h
r283713 r284695 62 62 void startReceivingMessagesImpl(ReceiverName, uint64_t destinationID); 63 63 void stopReceivingMessagesImpl(ReceiverName, uint64_t destinationID); 64 65 void startReceivingMessagesImpl(ReceiverName); 66 void stopReceivingMessagesImpl(ReceiverName); 64 67 65 68 // MessageReceiveQueue … … 145 148 void stopReceivingMessages(ReceiverName, uint64_t destinationID); 146 149 150 inline void startReceivingMessages(ReceiverName); 151 inline void stopReceivingMessages(ReceiverName); 152 147 153 // StreamServerConnectionBase overrides. 148 154 DispatchResult dispatchStreamMessages(size_t messageLimit) final; … … 162 168 }; 163 169 170 void StreamServerConnection::startReceivingMessages(ReceiverName receiverName) 171 { 172 StreamServerConnectionBase::startReceivingMessagesImpl(receiverName); 164 173 } 174 175 void StreamServerConnection::stopReceivingMessages(ReceiverName receiverName) 176 { 177 StreamServerConnectionBase::stopReceivingMessagesImpl(receiverName); 178 } 179 180 } -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp
r284476 r284695 128 128 void RemoteRenderingBackendProxy::createRemoteImageBuffer(ImageBuffer& imageBuffer) 129 129 { 130 // FIXME: This should be an normal (async) stream message. However, doing so may cause subsequent out-of-stream messages sent to the newly created image 131 // buffer to be dropped by the IPC connection. For the time being, work around this by using sync IPC (see <https://webkit.org/b/231681> for more details). 132 sendSyncToStream(Messages::RemoteRenderingBackend::CreateImageBuffer(imageBuffer.logicalSize(), imageBuffer.renderingMode(), imageBuffer.resolutionScale(), imageBuffer.colorSpace(), imageBuffer.pixelFormat(), imageBuffer.renderingResourceIdentifier()), Messages::RemoteRenderingBackend::CreateImageBuffer::Reply(), 3_s); 130 sendToStream(Messages::RemoteRenderingBackend::CreateImageBuffer(imageBuffer.logicalSize(), imageBuffer.renderingMode(), imageBuffer.resolutionScale(), imageBuffer.colorSpace(), imageBuffer.pixelFormat(), imageBuffer.renderingResourceIdentifier())); 133 131 } 134 132
Note:
See TracChangeset
for help on using the changeset viewer.