Changeset 273204 in webkit
- Timestamp:
- Feb 20, 2021 12:33:25 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 42 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r273203 r273204 1 2021-02-20 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 WebGL GPU process IPC should use shared memory for asynchronous messages 4 https://bugs.webkit.org/show_bug.cgi?id=219641 5 <rdar://problem/72340651> 6 7 Reviewed by Geoff Garen. 8 9 Mark few tests as not timing out now that the implementation is not so slow. 10 11 * gpu-process/TestExpectations: 12 1 13 2021-02-19 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/LayoutTests/gpu-process/TestExpectations
r273149 r273204 36 36 fast/canvas/webgl/context-update-on-display-configuration.html [ Timeout ] 37 37 fast/canvas/webgl/texImage2D-video-flipY-false.html [ Timeout ] 38 fast/canvas/webgl/uniform-samplers-test.html [ Timeout ]39 38 fast/canvas/webgl/webglcontextchangedevent.html [ Timeout ] 39 40 fast/canvas/webgl/uniform-samplers-test.html [ Slow ] 41 webgl/2.0.0/conformance/attribs/gl-vertexattribpointer.html [ Slow ] 42 webgl/2.0.0/conformance2/rendering/blitframebuffer-filter-outofbounds.html [ Slow ] 43 40 44 fast/images/animated-image-mp4-crash.html [ Timeout ] 41 45 fast/images/animated-image-mp4.html [ Timeout ] … … 181 185 webgl/1.0.3/conformance/extensions/oes-texture-half-float-with-canvas.html [ Failure ] 182 186 webgl/1.0.3/conformance/extensions/oes-texture-half-float-with-video.html [ Failure ] 183 webgl/1.0.3/conformance/rendering/many-draw-calls.html [ Timeout ]184 187 webgl/1.0.3/conformance/state/gl-object-get-calls.html [ Timeout ] 185 188 webgl/1.0.3/conformance/textures/tex-image-and-sub-image-2d-with-canvas-rgb565.html [ Failure ] … … 195 198 webgl/1.0.3/conformance/textures/texture-active-bind-2.html [ Failure ] 196 199 webgl/1.0.3/conformance/textures/texture-active-bind.html [ Failure ] 197 webgl/1.0.3/conformance/uniforms/uniform-samplers-test.html [ Timeout]200 webgl/1.0.3/conformance/uniforms/uniform-samplers-test.html [ Slow ] 198 201 webgl/2.0.0/conformance/extensions/oes-texture-float-with-canvas.html [ Failure ] 199 202 webgl/2.0.0/conformance/extensions/oes-texture-float-with-video.html [ Failure ] … … 201 204 webgl/2.0.0/conformance/extensions/oes-texture-half-float-with-video.html [ Failure ] 202 205 webgl/2.0.0/conformance/reading/read-pixels-test.html [ Failure ] 203 webgl/2.0.0/conformance/rendering/many-draw-calls.html [ Timeout ]204 206 webgl/2.0.0/conformance/state/gl-object-get-calls.html [ Timeout ] 205 207 webgl/2.0.0/conformance/textures/canvas/tex-2d-rgb-rgb-unsigned_byte.html [ Failure ] … … 221 223 webgl/2.0.0/conformance/textures/video/tex-2d-rgba-rgba-unsigned_short_4_4_4_4.html [ Failure ] 222 224 webgl/2.0.0/conformance/textures/video/tex-2d-rgba-rgba-unsigned_short_5_5_5_1.html [ Failure ] 223 webgl/2.0.0/conformance/uniforms/uniform-samplers-test.html [ Timeout]225 webgl/2.0.0/conformance/uniforms/uniform-samplers-test.html [ Slow ] 224 226 webgl/2.0.0/conformance2/reading/read-pixels-pack-parameters.html [ Failure ] 225 227 webgl/2.0.0/conformance2/state/gl-object-get-calls.html [ Timeout ] -
trunk/Source/WebKit/ChangeLog
r273202 r273204 1 2021-02-20 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 WebGL GPU process IPC should use shared memory for asynchronous messages 4 https://bugs.webkit.org/show_bug.cgi?id=219641 5 <rdar://problem/72340651> 6 7 Reviewed by Geoff Garen. 8 9 Implement a concept of a message buffer. This is a similar concept as 10 "command buffer" or "display list" in some graphics APIs. Messages 11 can be added to the buffer by a client and then played back by a 12 server. 13 14 Current implementation adds a specific pseudo-infinite, 15 semi-duplex message buffer type IPC::StreamConnectionBuffer. This 16 is a buffer that can be attached to stream connection, an object 17 that can deliver IPC messages either through the message buffer 18 or through normal IPC::Connection. The stream connection is 19 implemented as IPC::StreamClientConnection and IPC::StreamServerConnection. 20 The connection has server and client distinction, similar to 21 IPC::Connection. Unlike IPC::Connection, a stream connection is asymmetric 22 in features: the client can send messages and receive replies, where 23 as the server can receive messages and send replies. 24 25 Messages received through IPC::StreamServerConnection can be 26 processed by StreamConnectionWorkQueue. 27 28 Currently asynchronous messages are added to the stream. Synchronous messages 29 and their replies are dispatched through normal IPC. 30 31 WebGL is implemented by having one StreamConnectionWorkQueue for all WebGL 32 in the browser. Currently each web process WebGL context in has one 33 StreamClientConnection attached to one 2mb StreamConnectionBuffer. 34 35 Later on, there will be only one WebGL stream connection and connection 36 buffer shared between all contexts in particular thread in Web process. 37 The implementation is "optimized" for the later on case. Due to single- 38 process nature of each page, it does not make much sense to have buffer 39 per context. However, it is anticipated that many of the successive calls 40 are to same context. The SHM message format implements an optimization 41 where the destination id is maintained as part of the stream connection 42 state. 43 44 In GPU process side, all WebGL is processed in one task queue, 45 "RemoteGraphicsContextGL task queue". It will process up to 1000 commands 46 per connection per iteration. 47 48 Implemented as follows: 49 Sender shares the shared memory area with the destination when creating 50 the destination. 51 52 If the message fits to the stream shared memory area, write it there. 53 Otherwise send it via normal IPC as out of line message. 54 55 Messages to the destination arrive as before, in order. For each out of line 56 message, an entry is pushed to the stream. Receiver will stop processing the 57 stream and processing will continue once the out-of-line 58 message has been processed. 59 60 Sender can write messages to the stream simultaneous to the receiver reading 61 the messages. This is implemented as a ring buffer with atomic sender and receiver 62 pointers. 63 64 Stream connection processing is implemented as a shared semaphore. This semaphore 65 is notified if the receiver is waiting on it. 66 67 Performance impact (iMac Pro): 68 - MotionMark triangles: 300 points -> 4000 points 69 (~7000 points no-GPUP) 70 - WebGL samples Aquarium: 1000 fish ~60fps -> 5000 fish ~60fps 71 (~5000 fish with no-GPUP) 72 73 No new tests, tested by existing tests. 74 75 * GPUProcess/GPUConnectionToWebProcess.cpp: 76 (WebKit::GPUConnectionToWebProcess::createGraphicsContextGL): 77 * GPUProcess/GPUConnectionToWebProcess.h: 78 * GPUProcess/GPUConnectionToWebProcess.messages.in: 79 * GPUProcess/graphics/RemoteGraphicsContextGL.cpp: 80 (WebKit::remoteGraphicsContextGLStreamWorkQueue): 81 (WebKit::RemoteGraphicsContextGL::create): 82 (WebKit::RemoteGraphicsContextGL::RemoteGraphicsContextGL): 83 (WebKit::RemoteGraphicsContextGL::~RemoteGraphicsContextGL): 84 (WebKit::RemoteGraphicsContextGL::initialize): 85 (WebKit::RemoteGraphicsContextGL::connectWebProcessConnection): 86 (WebKit::RemoteGraphicsContextGL::disconnectWebProcessConnection): 87 (WebKit::RemoteGraphicsContextGL::workQueueInitialize): 88 (WebKit::RemoteGraphicsContextGL::workQueueUninitialize): 89 Initialize the OpenGL context in the work queue, since OpenGL 90 has various limitations wrt thread mobility. 91 92 (WebKit::RemoteGraphicsContextGL::forceContextLost): 93 (WebKit::RemoteGraphicsContextGL::dispatchContextChangedNotification): 94 * GPUProcess/graphics/RemoteGraphicsContextGL.h: 95 (WebKit::RemoteGraphicsContextGL::platformWorkQueueInitialize): 96 (WebKit::RemoteGraphicsContextGL::send const): 97 * GPUProcess/graphics/RemoteGraphicsContextGL.messages.in: 98 * GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp: 99 (WebKit::RemoteGraphicsContextGL::create): 100 (WebKit::RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa): 101 (WebKit::RemoteGraphicsContextGLCocoa::platformWorkQueueInitialize): 102 * NetworkProcess/webrtc/NetworkRTCProvider.h: 103 * Platform/IPC/ArgumentCoder.h: 104 * Platform/IPC/ArgumentCoders.cpp: 105 * Platform/IPC/ArgumentCoders.h: 106 Make it possible to use multiple different Encoder classes to encode 107 the IPC data. 108 109 * Platform/IPC/Connection.cpp: 110 (IPC::Connection::processIncomingMessage): 111 (IPC::Connection::dispatchDidReceiveInvalidMessage): 112 * Platform/IPC/Connection.h: 113 Add possibility for the stream decoding logic to send the didReceiveInvalidMessage 114 notification to the connection client. 115 116 * Platform/IPC/Decoder.cpp: 117 (IPC::Decoder::Decoder): 118 (IPC::m_bufferDeallocator): 119 (IPC::m_destinationID): 120 * Platform/IPC/Decoder.h: 121 Add a constructor for Decoder for constructing a decoder in place in 122 the stream buffer. 123 124 * Platform/IPC/HandleMessage.h: 125 (IPC::handleMessageSynchronous): 126 Adds a stream-specific handleMessageSynchronous. 127 The old ones are unneccessarily complex, as they need redundant calls through redundant 128 generated send functions. 129 The old ones need the reply encoder passed in, which is redundant and problematic 130 for the upcoming case where the stream messaging will mainly reply through the stream itself, 131 constructing the IPC::StreamConnectionEncoder instead of normal IPC::Encoder. 132 133 * Platform/IPC/StreamClientConnection.cpp: Copied from Source/WebKit/Platform/IPC/cocoa/MachPort.h. 134 (IPC::StreamClientConnection::StreamClientConnection): 135 (IPC::StreamClientConnection::setWakeUpSemaphore): 136 Add function to set the connection receive side wakeup semaphore. 137 Currently the semaphore is the semaphore that StreamConnectionWorkQueue 138 waits on. All streams processed by the same work queue will receive the same 139 semaphore and will notify it when they have written new data. 140 141 (IPC::StreamClientConnection::wakeUpReceiver): 142 * Platform/IPC/StreamClientConnection.h: Added. 143 (IPC::StreamClientConnection::send): 144 (IPC::StreamClientConnection::sendSync): 145 (IPC::StreamClientConnection::trySendDestinationIDIfNeeded): 146 (IPC::StreamClientConnection::sendProcessOutOfStreamMessage): 147 (IPC::StreamClientConnection::tryAcquire): 148 (IPC::StreamClientConnection::release): 149 (IPC::StreamClientConnection::alignedSpan): 150 (IPC::StreamClientConnection::size): 151 (IPC::StreamClientConnection::clampedLimit const): 152 Add the implementation for sending data through the shared memory. 153 154 155 * Platform/IPC/StreamConnectionBuffer.cpp: Added. 156 (IPC::createMemory): 157 (IPC::StreamConnectionBuffer::StreamConnectionBuffer): 158 (IPC::StreamConnectionBuffer::operator=): 159 (IPC::StreamConnectionBuffer::encode const): 160 (IPC::StreamConnectionBuffer::decode): 161 * Platform/IPC/StreamConnectionBuffer.h: Added. 162 (IPC::StreamConnectionBuffer::wrapOffset const): 163 (IPC::StreamConnectionBuffer::alignOffset const): 164 (IPC::StreamConnectionBuffer::senderOffset): 165 (IPC::StreamConnectionBuffer::receiverOffset): 166 (IPC::StreamConnectionBuffer::data const): 167 (IPC::StreamConnectionBuffer::dataSize const): 168 (IPC::StreamConnectionBuffer::senderWaitSemaphore): 169 (IPC::StreamConnectionBuffer::header const): 170 (IPC::StreamConnectionBuffer::headerSize): 171 Add the common implementation for the shared memory ring buffer. 172 This is the common implementation used by both the sender side 173 as well as the receiver side. 174 Due to the selection of how the size is marked up, the 175 common implementation does not contain all the non-trivial code. 176 The "algorithm" uses a "hole indicator" to differentiate between 177 cases of "buffer is empty" and "buffer is full". The other 178 alternative could be better and maybe explored later. 179 180 * Platform/IPC/StreamConnectionEncoder.h: Added. 181 * Platform/IPC/StreamConnectionWorkQueue.cpp: Added. 182 (IPC::StreamConnectionWorkQueue::StreamConnectionWorkQueue): 183 (IPC::StreamConnectionWorkQueue::dispatch): 184 (IPC::StreamConnectionWorkQueue::addStreamConnection): 185 (IPC::StreamConnectionWorkQueue::removeStreamConnection): 186 (IPC::StreamConnectionWorkQueue::stop): 187 (IPC::StreamConnectionWorkQueue::wakeUp): 188 (IPC::StreamConnectionWorkQueue::wakeUpSemaphore): 189 (IPC::StreamConnectionWorkQueue::wakeUpProcessingThread): 190 (IPC::StreamConnectionWorkQueue::processStreams): 191 Work queue contains multiple StreamServerConnection instances. 192 For each iteration of the work queue thread, it will process 193 1000 items from each connection. If none of the connections contain 194 work, the queue will sleep on the work queue semaphore. 195 The senders will send through StreamClientConnection which 196 will wake up the work queue by signaling the semaphore. 197 198 * Platform/IPC/StreamConnectionWorkQueue.h: Copied from Source/WebKit/Platform/IPC/cocoa/MachPort.h. 199 * Platform/IPC/StreamServerConnection.cpp: Added. 200 (IPC::StreamServerConnectionBase::StreamServerConnectionBase): 201 (IPC::StreamServerConnectionBase::startReceivingMessagesImpl): 202 (IPC::StreamServerConnectionBase::stopReceivingMessagesImpl): 203 (IPC::StreamServerConnectionBase::enqueueMessage): 204 (IPC::StreamServerConnectionBase::tryAquire): 205 (IPC::StreamServerConnectionBase::release): 206 (IPC::StreamServerConnectionBase::alignedSpan): 207 (IPC::StreamServerConnectionBase::size): 208 (IPC::StreamServerConnectionBase::clampedLimit const): 209 * Platform/IPC/StreamServerConnection.h: Added. 210 (IPC::StreamServerConnectionBase::connection): 211 (IPC::StreamServerConnectionBase::wrapOffset const): 212 (IPC::StreamServerConnectionBase::alignOffset const): 213 (IPC::StreamServerConnectionBase::sharedSenderOffset): 214 (IPC::StreamServerConnectionBase::sharedReceiverOffset): 215 (IPC::StreamServerConnectionBase::data const): 216 (IPC::StreamServerConnectionBase::dataSize const): 217 (IPC::StreamServerConnectionBase::sendSyncReply): 218 (IPC::StreamServerConnection<Receiver>::startReceivingMessages): 219 (IPC::StreamServerConnection<Receiver>::stopReceivingMessages): 220 (IPC::StreamServerConnection<Receiver>::dispatchStreamMessages): 221 (IPC::StreamServerConnection<Receiver>::processSetStreamDestinationID): 222 (IPC::StreamServerConnection<Receiver>::dispatchStreamMessage): 223 (IPC::StreamServerConnection<Receiver>::dispatchOutOfStreamMessage): 224 StreamServerConnection will process the message buffer and dispatch 225 messages based on the buffer contents. The class is a template so 226 that the message data decode switch (generated by the normal IPC 227 generator) is perhaps inlined to the message unpack loop. 228 * Platform/IPC/cocoa/MachPort.h: 229 230 * Scripts/webkit/messages.py: 231 * Scripts/webkit/messages_unittest.py: 232 Implements a 'Stream' attribute for the message receiver. When marked as 233 'Stream', the receiver message handler is didReceiveStreamMessage and it 234 will be called for all messages, stream or normal IPC, sync or async. 235 236 * Scripts/webkit/model.py: 237 Adds IPC control message ProcessOutOfStreamMessage that is acted on if 238 it is part of the stream messages. It means that the stream processing 239 should stop until one normal IPC message, sync or non-synch, should be 240 processed. 241 242 Adds IPC control message SetStreamDestinationID that is acted on if it 243 is part of the stream messages. It will set the destination ID for all 244 the subsequent stream messages, until another SetStreamDestinationID 245 message is seen. 246 247 * Scripts/webkit/tests/Makefile: 248 * Scripts/webkit/tests/MessageNames.cpp: 249 (IPC::description): 250 (IPC::receiverName): 251 (IPC::isValidMessageName): 252 * Scripts/webkit/tests/MessageNames.h: 253 * Scripts/webkit/tests/TestWithStream.messages.in: Copied from Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in. 254 * Scripts/webkit/tests/TestWithStreamBuffer.messages.in: Copied from Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in. 255 * Scripts/webkit/tests/TestWithStreamBufferMessageReceiver.cpp: Added. 256 (WebKit::TestWithStreamBuffer::didReceiveMessage): 257 * Scripts/webkit/tests/TestWithStreamBufferMessages.h: Added. 258 (Messages::TestWithStreamBuffer::messageReceiverName): 259 (Messages::TestWithStreamBuffer::SendStreamBuffer::name): 260 (Messages::TestWithStreamBuffer::SendStreamBuffer::SendStreamBuffer): 261 (Messages::TestWithStreamBuffer::SendStreamBuffer::arguments const): 262 * Scripts/webkit/tests/TestWithStreamBufferMessagesReplies.h: Added. 263 * Scripts/webkit/tests/TestWithStreamMessageReceiver.cpp: Added. 264 (WebKit::TestWithStream::didReceiveStreamMessage): 265 * Scripts/webkit/tests/TestWithStreamMessages.h: Added. 266 (Messages::TestWithStream::messageReceiverName): 267 (Messages::TestWithStream::SendString::name): 268 (Messages::TestWithStream::SendString::SendString): 269 (Messages::TestWithStream::SendString::arguments const): 270 (Messages::TestWithStream::SendStringSynchronized::name): 271 (Messages::TestWithStream::SendStringSynchronized::SendStringSynchronized): 272 (Messages::TestWithStream::SendStringSynchronized::arguments const): 273 * Scripts/webkit/tests/TestWithStreamMessagesReplies.h: Added. 274 * Sources.txt: 275 * UIProcess/Downloads/DownloadProxy.h: 276 * UIProcess/ProvisionalPageProxy.cpp: 277 * WebKit.xcodeproj/project.pbxproj: 278 * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp: 279 (WebKit::RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy): 280 (WebKit::RemoteGraphicsContextGLProxy::wasCreated): 281 Send the work queue wakeup semaphore as a result of the context creation. 282 283 284 * Platform/IPC/ScopedActiveMessageReceiveQueue.h: Added. 285 (IPC::ScopedActiveMessageReceiveQueue::ScopedActiveMessageReceiveQueue): 286 (IPC::ScopedActiveMessageReceiveQueue::operator=): 287 (IPC::ScopedActiveMessageReceiveQueue::~ScopedActiveMessageReceiveQueue): 288 (IPC::ScopedActiveMessageReceiveQueue::reset): 289 (IPC::ScopedActiveMessageReceiveQueue::get const): 290 (IPC::ScopedActiveMessageReceiveQueue::stopListeningForIPCAndRelease): 291 Add a holder to replace previous RemoteRenderingBackendWrapper. 292 Now other classes can be held similarly. 293 294 * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h: 295 * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in: 296 * WebProcess/Network/webrtc/LibWebRTCNetwork.h: 297 1 298 2021-02-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 299 -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
r273080 r273204 316 316 { 317 317 auto addResult = m_remoteRenderingBackendMap.ensure(identifier, [&]() { 318 return makeUnique<RemoteRenderingBackendWrapper>(RemoteRenderingBackend::create(*this, identifier, WTFMove(resumeDisplayListSemaphore)));318 return IPC::ScopedActiveMessageReceiveQueue { RemoteRenderingBackend::create(*this, identifier, WTFMove(resumeDisplayListSemaphore)) }; 319 319 }); 320 320 ASSERT_UNUSED(addResult, addResult.isNewEntry); … … 327 327 } 328 328 329 GPUConnectionToWebProcess::RemoteRenderingBackendWrapper::RemoteRenderingBackendWrapper(Ref<RemoteRenderingBackend>&& remoteRenderingBackend)330 : m_remoteRenderingBackend(WTFMove(remoteRenderingBackend))331 {332 }333 334 GPUConnectionToWebProcess::RemoteRenderingBackendWrapper::~RemoteRenderingBackendWrapper()335 {336 m_remoteRenderingBackend->disconnect();337 }338 339 329 #if ENABLE(WEBGL) 340 void GPUConnectionToWebProcess::createGraphicsContextGL(WebCore::GraphicsContextGLAttributes attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RenderingBackendIdentifier renderingBackendIdentifier )341 { 342 auto * renderingBackend = m_remoteRenderingBackendMap.get(renderingBackendIdentifier);343 if ( !renderingBackend)330 void GPUConnectionToWebProcess::createGraphicsContextGL(WebCore::GraphicsContextGLAttributes attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RenderingBackendIdentifier renderingBackendIdentifier, IPC::StreamConnectionBuffer&& stream) 331 { 332 auto it = m_remoteRenderingBackendMap.find(renderingBackendIdentifier); 333 if (it == m_remoteRenderingBackendMap.end()) 344 334 return; 335 auto* renderingBackend = it->value.get(); 345 336 346 337 auto addResult = m_remoteGraphicsContextGLMap.ensure(graphicsContextGLIdentifier, [&]() { 347 return RemoteGraphicsContextGL::create(attributes, *this, graphicsContextGLIdentifier, renderingBackend->get());338 return IPC::ScopedActiveMessageReceiveQueue { RemoteGraphicsContextGL::create(*this, WTFMove(attributes), graphicsContextGLIdentifier, *renderingBackend, WTFMove(stream)) }; 348 339 }); 349 340 ASSERT_UNUSED(addResult, addResult.isNewEntry); -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h
r273080 r273204 35 35 #include "RemoteRemoteCommandListenerIdentifier.h" 36 36 #include "RenderingBackendIdentifier.h" 37 #include "ScopedActiveMessageReceiveQueue.h" 37 38 38 39 #include <WebCore/LibWebRTCEnumTraits.h> … … 139 140 140 141 #if ENABLE(WEBGL) 141 void createGraphicsContextGL(WebCore::GraphicsContextGLAttributes, GraphicsContextGLIdentifier, RenderingBackendIdentifier );142 void createGraphicsContextGL(WebCore::GraphicsContextGLAttributes, GraphicsContextGLIdentifier, RenderingBackendIdentifier, IPC::StreamConnectionBuffer&&); 142 143 void releaseGraphicsContextGL(GraphicsContextGLIdentifier); 143 144 #endif … … 207 208 #endif 208 209 209 class RemoteRenderingBackendWrapper { 210 WTF_MAKE_FAST_ALLOCATED; 211 public: 212 RemoteRenderingBackendWrapper(Ref<RemoteRenderingBackend>&&); 213 ~RemoteRenderingBackendWrapper(); 214 RemoteRenderingBackend& get() const { return m_remoteRenderingBackend.get(); } 215 private: 216 Ref<RemoteRenderingBackend> m_remoteRenderingBackend; 217 }; 218 219 using RemoteRenderingBackendMap = HashMap<RenderingBackendIdentifier, std::unique_ptr<RemoteRenderingBackendWrapper>>; 210 using RemoteRenderingBackendMap = HashMap<RenderingBackendIdentifier, IPC::ScopedActiveMessageReceiveQueue<RemoteRenderingBackend>>; 220 211 RemoteRenderingBackendMap m_remoteRenderingBackendMap; 221 212 #if ENABLE(WEBGL) 222 using RemoteGraphicsContextGLMap = HashMap<GraphicsContextGLIdentifier, std::unique_ptr<RemoteGraphicsContextGL>>;213 using RemoteGraphicsContextGLMap = HashMap<GraphicsContextGLIdentifier, IPC::ScopedActiveMessageReceiveQueue<RemoteGraphicsContextGL>>; 223 214 RemoteGraphicsContextGLMap m_remoteGraphicsContextGLMap; 224 215 #endif -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in
r273080 r273204 27 27 void ReleaseRenderingBackend(WebKit::RenderingBackendIdentifier renderingBackendIdentifier) 28 28 #if ENABLE(WEBGL) 29 void CreateGraphicsContextGL(struct WebCore::GraphicsContextGLAttributes attributes, WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier, WebKit::RenderingBackendIdentifier renderingBackendIdentifier )29 void CreateGraphicsContextGL(struct WebCore::GraphicsContextGLAttributes attributes, WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier, WebKit::RenderingBackendIdentifier renderingBackendIdentifier, IPC::StreamConnectionBuffer stream) 30 30 void ReleaseGraphicsContextGL(WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier) 31 31 #endif -
trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp
r273080 r273204 32 32 #include "RemoteGraphicsContextGLMessages.h" 33 33 #include "RemoteGraphicsContextGLProxyMessages.h" 34 #include "StreamConnectionWorkQueue.h" 34 35 #include <WebCore/GraphicsContextGLOpenGL.h> 35 36 #include <WebCore/NotImplemented.h> 36 37 #include <wtf/NeverDestroyed.h> 37 38 38 39 namespace WebKit { 40 39 41 using namespace WebCore; 40 42 43 // Currently we have one global WebGL processing instance. 44 static IPC::StreamConnectionWorkQueue& remoteGraphicsContextGLStreamWorkQueue() 45 { 46 static NeverDestroyed<IPC::StreamConnectionWorkQueue> instance("RemoteGraphicsContextGL work queue"); 47 return instance.get(); 48 } 49 41 50 #if !PLATFORM(COCOA) 42 std::unique_ptr<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(const WebCore::GraphicsContextGLAttributes&, GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&)51 Ref<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLAttributes&& attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream) 43 52 { 44 53 ASSERT_NOT_REACHED(); 45 return nullptr; 54 auto instance = adoptRef(*new RemoteGraphicsContextGL(gpuConnectionToWebProcess, graphicsContextGLIdentifier, renderingBackend, WTFMove(stream))); 55 instance->initialize(WTFMove(attributes)); 56 return instance; 46 57 } 47 58 #endif 48 59 49 RemoteGraphicsContextGL::RemoteGraphicsContextGL(const WebCore::GraphicsContextGLAttributes& attributes, GPUConnectionToWebProcess& connection, GraphicsContextGLIdentifier identifier, Ref<GraphicsContextGLOpenGL> context, RemoteRenderingBackend& renderingBackend) 50 : m_context(WTFMove(context)) 51 , m_gpuConnectionToWebProcess(makeWeakPtr(connection)) 52 , m_graphicsContextGLIdentifier(identifier) 60 RemoteGraphicsContextGL::RemoteGraphicsContextGL(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream) 61 : m_streamConnection(IPC::StreamServerConnection<RemoteGraphicsContextGL>::create(gpuConnectionToWebProcess.connection(), WTFMove(stream), remoteGraphicsContextGLStreamWorkQueue())) 62 , m_graphicsContextGLIdentifier(graphicsContextGLIdentifier) 53 63 , m_renderingBackend(makeRef(renderingBackend)) 54 64 { 55 if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get()) 56 gpuConnectionToWebProcess->messageReceiverMap().addMessageReceiver(Messages::RemoteGraphicsContextGL::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64(), *this); 57 m_context->addClient(*this); 58 String extensions = m_context->getString(GraphicsContextGL::EXTENSIONS); 59 String requestableExtensions = m_context->getString(ExtensionsGL::REQUESTABLE_EXTENSIONS_ANGLE); 60 send(Messages::RemoteGraphicsContextGLProxy::WasCreated(true, extensions, requestableExtensions), m_graphicsContextGLIdentifier); 65 ASSERT(RunLoop::isMain()); 61 66 } 62 67 63 68 RemoteGraphicsContextGL::~RemoteGraphicsContextGL() 64 69 { 65 if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get()) 66 gpuConnectionToWebProcess->messageReceiverMap().removeMessageReceiver(Messages::RemoteGraphicsContextGL::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64()); 67 } 68 69 GPUConnectionToWebProcess* RemoteGraphicsContextGL::gpuConnectionToWebProcess() const 70 { 71 return m_gpuConnectionToWebProcess.get(); 72 } 73 74 IPC::Connection* RemoteGraphicsContextGL::messageSenderConnection() const 75 { 76 if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get()) 77 return &gpuConnectionToWebProcess->connection(); 78 return nullptr; 79 } 80 81 uint64_t RemoteGraphicsContextGL::messageSenderDestinationID() const 82 { 83 return m_graphicsContextGLIdentifier.toUInt64(); 70 ASSERT(!m_streamConnection); 71 ASSERT(!m_context); 72 } 73 74 void RemoteGraphicsContextGL::initialize(GraphicsContextGLAttributes&& attributes) 75 { 76 ASSERT(RunLoop::isMain()); 77 remoteGraphicsContextGLStreamWorkQueue().dispatch([attributes = WTFMove(attributes), protectedThis = makeRef(*this)]() mutable { 78 protectedThis->workQueueInitialize(WTFMove(attributes)); 79 }); 80 m_streamConnection->startReceivingMessages(*this, Messages::RemoteGraphicsContextGL::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64()); 81 } 82 83 void RemoteGraphicsContextGL::stopListeningForIPC(Ref<RemoteGraphicsContextGL>&& refFromConnection) 84 { 85 ASSERT(RunLoop::isMain()); 86 m_streamConnection->stopReceivingMessages(Messages::RemoteGraphicsContextGL::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64()); 87 remoteGraphicsContextGLStreamWorkQueue().dispatch([protectedThis = WTFMove(refFromConnection)]() { 88 protectedThis->workQueueUninitialize(); 89 }); 90 } 91 92 void RemoteGraphicsContextGL::workQueueInitialize(WebCore::GraphicsContextGLAttributes&& attributes) 93 { 94 platformWorkQueueInitialize(WTFMove(attributes)); 95 if (m_context) { 96 m_context->addClient(*this); 97 String extensions = m_context->getString(GraphicsContextGL::EXTENSIONS); 98 String requestableExtensions = m_context->getString(ExtensionsGL::REQUESTABLE_EXTENSIONS_ANGLE); 99 send(Messages::RemoteGraphicsContextGLProxy::WasCreated(true, remoteGraphicsContextGLStreamWorkQueue().wakeUpSemaphore(), extensions, requestableExtensions)); 100 } else 101 send(Messages::RemoteGraphicsContextGLProxy::WasCreated(false, IPC::Semaphore { }, "", "")); 102 } 103 104 void RemoteGraphicsContextGL::workQueueUninitialize() 105 { 106 m_context = nullptr; 107 m_streamConnection = nullptr; 84 108 } 85 109 … … 90 114 void RemoteGraphicsContextGL::forceContextLost() 91 115 { 92 send(Messages::RemoteGraphicsContextGLProxy::WasLost() , m_graphicsContextGLIdentifier);116 send(Messages::RemoteGraphicsContextGLProxy::WasLost()); 93 117 } 94 118 … … 100 124 void RemoteGraphicsContextGL::dispatchContextChangedNotification() 101 125 { 102 send(Messages::RemoteGraphicsContextGLProxy::WasChanged() , m_graphicsContextGLIdentifier);126 send(Messages::RemoteGraphicsContextGLProxy::WasChanged()); 103 127 } 104 128 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h
r273080 r273204 29 29 30 30 #include "Connection.h" 31 #include "GPUConnectionToWebProcess.h" 31 32 #include "GraphicsContextGLIdentifier.h" 32 #include "MessageReceiver.h"33 #include "MessageSender.h"34 33 #include "RemoteRenderingBackend.h" 34 #include "StreamServerConnection.h" 35 35 #include <WebCore/ExtensionsGL.h> 36 36 #include <WebCore/GraphicsContextGLOpenGL.h> … … 50 50 namespace WebKit { 51 51 52 class GPUConnectionToWebProcess;53 54 52 // GPU process side implementation of that receives messages about GraphicsContextGL calls 55 53 // and issues real GraphicsContextGL calls based on the received messages. 56 54 // The implementation is largely generated by running Tools/Scripts/generate-gpup-webgl. 57 class RemoteGraphicsContextGL 58 : public IPC::MessageSender 59 , private IPC::MessageReceiver 60 , private WebCore::GraphicsContextGL::Client { 55 class RemoteGraphicsContextGL : public ThreadSafeRefCounted<RemoteGraphicsContextGL>, private WebCore::GraphicsContextGL::Client { 61 56 WTF_MAKE_FAST_ALLOCATED; 62 57 public: 63 static std::unique_ptr<RemoteGraphicsContextGL> create(const WebCore::GraphicsContextGLAttributes&, GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&);58 static Ref<RemoteGraphicsContextGL> create(GPUConnectionToWebProcess&, WebCore::GraphicsContextGLAttributes&&, GraphicsContextGLIdentifier, RemoteRenderingBackend&, IPC::StreamConnectionBuffer&&); 64 59 ~RemoteGraphicsContextGL() override; 60 void stopListeningForIPC(Ref<RemoteGraphicsContextGL>&& refFromConnection); 65 61 66 GPUConnectionToWebProcess* gpuConnectionToWebProcess() const; 62 // IPC::StreamServerConnection<RemoteGraphicsContextGL> template contract implementation. 63 void didReceiveStreamMessage(IPC::StreamServerConnectionBase&, IPC::Decoder&); 67 64 68 65 protected: 69 RemoteGraphicsContextGL(const WebCore::GraphicsContextGLAttributes&, GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, Ref<WebCore::GraphicsContextGLOpenGL>, RemoteRenderingBackend&); 66 RemoteGraphicsContextGL(GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&, IPC::StreamConnectionBuffer&&); 67 void initialize(WebCore::GraphicsContextGLAttributes&&); 70 68 71 // IPC::MessageSender overrides. 72 IPC::Connection* messageSenderConnection() const final; 73 uint64_t messageSenderDestinationID() const final; 74 75 // IPC::MessageReceiver overrides. 76 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 77 void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final; 69 void workQueueInitialize(WebCore::GraphicsContextGLAttributes&&); 70 virtual void platformWorkQueueInitialize(WebCore::GraphicsContextGLAttributes&&) { }; 71 void workQueueUninitialize(); 72 template<typename T> 73 bool send(T&& message) const { return m_streamConnection->connection().send(WTFMove(message), m_graphicsContextGLIdentifier); } 78 74 79 75 // GraphicsContextGL::Client overrides. … … 101 97 void paintImageDataToImageBuffer(RefPtr<WebCore::ImageData>&&, WebCore::RenderingResourceIdentifier, CompletionHandler<void()>&&); 102 98 103 Ref <WebCore::GraphicsContextGLOpenGL> m_context;104 WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess;99 RefPtr<IPC::StreamServerConnection<RemoteGraphicsContextGL>> m_streamConnection; 100 RefPtr<WebCore::GraphicsContextGLOpenGL> m_context; 105 101 GraphicsContextGLIdentifier m_graphicsContextGLIdentifier; 106 102 Ref<RemoteRenderingBackend> m_renderingBackend; -
trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.messages.in
r273080 r273204 25 25 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) 26 26 27 messages -> RemoteGraphicsContextGL NotRefCounted {27 messages -> RemoteGraphicsContextGL NotRefCounted Stream { 28 28 void Reshape(int32_t width, int32_t height) 29 29 #if PLATFORM(COCOA) -
trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp
r273080 r273204 40 40 class RemoteGraphicsContextGLCocoa final : public RemoteGraphicsContextGL { 41 41 public: 42 RemoteGraphicsContextGLCocoa( const WebCore::GraphicsContextGLAttributes&, GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&);42 RemoteGraphicsContextGLCocoa(GPUConnectionToWebProcess&, GraphicsContextGLIdentifier, RemoteRenderingBackend&, IPC::StreamConnectionBuffer&&); 43 43 ~RemoteGraphicsContextGLCocoa() final = default; 44 44 45 45 // RemoteGraphicsContextGL overrides. 46 void platformWorkQueueInitialize(WebCore::GraphicsContextGLAttributes&&) final; 46 47 void prepareForDisplay(CompletionHandler<void(WTF::MachSendRight&&)>&&) final; 47 48 private: … … 51 52 } 52 53 53 std::unique_ptr<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(const WebCore::GraphicsContextGLAttributes& attributes, GPUConnectionToWebProcess& connection, GraphicsContextGLIdentifier identifier, RemoteRenderingBackend& renderingBackend)54 Ref<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLAttributes&& attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream) 54 55 { 55 return makeUnique<RemoteGraphicsContextGLCocoa>(attributes, connection, identifier, renderingBackend); 56 auto instance = adoptRef(*new RemoteGraphicsContextGLCocoa(gpuConnectionToWebProcess, graphicsContextGLIdentifier, renderingBackend, WTFMove(stream))); 57 instance->initialize(WTFMove(attributes)); 58 return instance; 56 59 } 57 60 58 RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa( const WebCore::GraphicsContextGLAttributes& attributes, GPUConnectionToWebProcess& connection, GraphicsContextGLIdentifier identifier, RemoteRenderingBackend& renderingBackend)59 : RemoteGraphicsContextGL( attributes, connection, identifier, GraphicsContextGLOpenGL::createForGPUProcess(attributes, &m_swapChain), renderingBackend)61 RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream) 62 : RemoteGraphicsContextGL(gpuConnectionToWebProcess, graphicsContextGLIdentifier, renderingBackend, WTFMove(stream)) 60 63 { 64 } 65 66 void RemoteGraphicsContextGLCocoa::platformWorkQueueInitialize(WebCore::GraphicsContextGLAttributes&& attributes) 67 { 68 m_context = GraphicsContextGLOpenGL::createForGPUProcess(WTFMove(attributes), &m_swapChain); 61 69 } 62 70 -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
r273139 r273204 90 90 } 91 91 92 void RemoteRenderingBackend:: disconnect()92 void RemoteRenderingBackend::stopListeningForIPC() 93 93 { 94 94 ASSERT(RunLoop::isMain()); -
trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h
r273139 r273204 67 67 static Ref<RemoteRenderingBackend> create(GPUConnectionToWebProcess&, RenderingBackendIdentifier, IPC::Semaphore&& resumeDisplayListSemaphore); 68 68 virtual ~RemoteRenderingBackend(); 69 void stopListeningForIPC(); 69 70 70 71 RemoteResourceCache& remoteResourceCache() { return m_remoteResourceCache; } … … 78 79 79 80 void setNextItemBufferToRead(WebCore::DisplayList::ItemBufferIdentifier, WebCore::RenderingResourceIdentifier destination); 80 81 void disconnect();82 81 83 82 // Runs Function in RemoteRenderingBackend task queue. -
trunk/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h
r268261 r273204 26 26 #pragma once 27 27 28 #include "DataReference.h" 28 29 #include "DownloadID.h" 29 30 #include "MessageSender.h" -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h
r273074 r273204 29 29 30 30 #include "Connection.h" 31 #include "DataReference.h" 31 32 #include "LibWebRTCResolverIdentifier.h" 32 33 #include "NetworkRTCMonitor.h" -
trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h
r272058 r273204 28 28 #include "Decoder.h" 29 29 #include "Encoder.h" 30 #include <wtf/EnumTraits.h> 30 31 #include <wtf/Optional.h> 31 32 … … 76 77 template<typename T> 77 78 struct ArgumentCoder<T, typename std::enable_if_t<std::is_arithmetic_v<T>>> { 79 template<typename Encoder> 78 80 static void encode(Encoder& encoder, T value) 79 81 { … … 92 94 template<typename T> 93 95 struct ArgumentCoder<T, typename std::enable_if_t<std::is_enum_v<T>>> { 96 template<typename Encoder> 94 97 static void encode(Encoder& encoder, T value) 95 98 { -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp
r259940 r273204 28 28 29 29 #include "DataReference.h" 30 #include "StreamConnectionEncoder.h" 30 31 #include <wtf/text/CString.h> 31 32 #include <wtf/text/WTFString.h> … … 112 113 } 113 114 114 115 template<typename Encoder> 115 116 void ArgumentCoder<String>::encode(Encoder& encoder, const String& string) 116 117 { … … 131 132 encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters16()), length * sizeof(UChar), alignof(UChar)); 132 133 } 134 template 135 void ArgumentCoder<String>::encode<Encoder>(Encoder&, const String&); 136 template 137 void ArgumentCoder<String>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const String&); 133 138 134 139 template <typename CharacterType> -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h
r272058 r273204 56 56 template<typename T, size_t Extent> struct ArgumentCoder<ArrayReference<T, Extent>> { 57 57 using ArrayReferenceType = ArrayReference<T, Extent>; 58 template<typename Encoder> 58 59 static void encode(Encoder& encoder, const ArrayReferenceType& arrayReference) 59 60 { … … 75 76 template<typename T> struct ArgumentCoder<ArrayReference<T, arrayReferenceDynamicExtent>> { 76 77 using ArrayReferenceType = ArrayReference<T, arrayReferenceDynamicExtent>; 78 template<typename Encoder> 77 79 static void encode(Encoder& encoder, const ArrayReferenceType& arrayReference) 78 80 { … … 267 269 template<size_t index, typename... Elements> 268 270 struct TupleEncoder { 271 template<typename Encoder> 269 272 static void encode(Encoder& encoder, const std::tuple<Elements...>& tuple) 270 273 { … … 276 279 template<typename... Elements> 277 280 struct TupleEncoder<0, Elements...> { 281 template<typename Encoder> 278 282 static void encode(Encoder&, const std::tuple<Elements...>&) 279 283 { … … 339 343 340 344 template<typename... Elements> struct ArgumentCoder<std::tuple<Elements...>> { 345 template<typename Encoder> 341 346 static void encode(Encoder& encoder, const std::tuple<Elements...>& tuple) 342 347 { … … 375 380 376 381 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity> struct VectorArgumentCoder<false, T, inlineCapacity, OverflowHandler, minCapacity> { 382 template<typename Encoder> 377 383 static void encode(Encoder& encoder, const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector) 378 384 { … … 412 418 413 419 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity> struct VectorArgumentCoder<true, T, inlineCapacity, OverflowHandler, minCapacity> { 420 template<typename Encoder> 414 421 static void encode(Encoder& encoder, const Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector) 415 422 { … … 754 761 755 762 template<> struct ArgumentCoder<String> { 763 template<typename Encoder> 756 764 static void encode(Encoder&, const String&); 757 765 static WARN_UNUSED_RETURN bool decode(Decoder&, String&); -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r273183 r273204 27 27 #include "Connection.h" 28 28 29 #include "ArgumentCoder.h" 29 30 #include "Logging.h" 30 31 #include "MessageFlags.h" … … 931 932 void Connection::dispatchDidReceiveInvalidMessage(MessageName messageName) 932 933 { 933 ASSERT(RunLoop::isMain()); 934 934 if (!RunLoop::isMain()) { 935 RunLoop::main().dispatch([protectedThis = makeRef(*this), messageName]() mutable { 936 if (!protectedThis->isValid()) 937 return; 938 protectedThis->m_client.didReceiveInvalidMessage(protectedThis, messageName); 939 }); 940 } 935 941 if (!isValid()) 936 942 return; -
trunk/Source/WebKit/Platform/IPC/Connection.h
r272916 r273204 31 31 #include "Decoder.h" 32 32 #include "Encoder.h" 33 #include "HandleMessage.h"34 33 #include "MessageReceiveQueueMap.h" 35 34 #include "MessageReceiver.h" 36 #include < atomic>35 #include <wtf/CompletionHandler.h> 37 36 #include <wtf/Condition.h> 38 37 #include <wtf/Deque.h> … … 313 312 314 313 void dispatchMessageReceiverMessage(MessageReceiver&, std::unique_ptr<Decoder>&&); 314 // Can be called from any thread. 315 void dispatchDidReceiveInvalidMessage(MessageName); 315 316 private: 316 317 Connection(Identifier, bool isServer, Client&); … … 340 341 void dispatchMessage(Decoder&); 341 342 void dispatchSyncMessage(Decoder&); 342 void dispatchDidReceiveInvalidMessage(MessageName);343 343 void didFailToSendSyncMessage(); 344 344 -
trunk/Source/WebKit/Platform/IPC/Decoder.cpp
r273196 r273204 111 111 } 112 112 113 Decoder::Decoder(const uint8_t* stream, size_t streamSize, uint64_t destinationID) 114 : m_buffer { stream } 115 , m_bufferPos { m_buffer } 116 , m_bufferEnd { m_buffer + streamSize } 117 , m_bufferDeallocator([] (const uint8_t*, size_t) { }) 118 , m_destinationID(destinationID) 119 { 120 if (!decode(m_messageName)) 121 return; 122 } 123 113 124 Decoder::~Decoder() 114 125 { -
trunk/Source/WebKit/Platform/IPC/Decoder.h
r273196 r273204 51 51 public: 52 52 static std::unique_ptr<Decoder> create(const uint8_t* buffer, size_t bufferSize, void (*bufferDeallocator)(const uint8_t*, size_t), Vector<Attachment>&&); 53 Decoder(const uint8_t* stream, size_t streamSize, uint64_t destinationID); 54 53 55 ~Decoder(); 54 56 -
trunk/Source/WebKit/Platform/IPC/HandleMessage.h
r272873 r273204 28 28 #include "ArgumentCoders.h" 29 29 #include "DataReference.h" 30 #include "StreamServerConnection.h" 30 31 #include <wtf/CompletionHandler.h> 31 32 #include <wtf/StdLibExtras.h> … … 163 164 }; 164 165 callMemberFunction(connection, WTFMove(*arguments), WTFMove(completionHandler), object, function); 166 } 167 168 template<typename T, typename C, typename MF> 169 void handleMessageSynchronous(StreamServerConnectionBase& connection, Decoder& decoder, C* object, MF function) 170 { 171 uint64_t syncRequestID = 0; 172 if (!decoder.decode(syncRequestID) || !syncRequestID) { 173 decoder.markInvalid(); 174 return; 175 } 176 177 Optional<typename CodingType<typename T::Arguments>::Type> arguments; 178 decoder >> arguments; 179 if (!arguments) { 180 decoder.markInvalid(); 181 return; 182 } 183 184 typename T::DelayedReply completionHandler = [syncRequestID, connection = makeRef(connection)] (auto&&... args) mutable { 185 connection->sendSyncReply(syncRequestID, args...); 186 }; 187 callMemberFunction(WTFMove(*arguments), WTFMove(completionHandler), object, function); 165 188 } 166 189 -
trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp
r273203 r273204 1 1 /* 2 * Copyright (C) 20 10 Apple Inc. All rights reserved.2 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #pragma once 27 28 #include "Attachment.h" 29 #include "Decoder.h" 30 #include "Encoder.h" 26 #include "config.h" 27 #include "StreamClientConnection.h" 31 28 32 29 namespace IPC { 33 30 34 class MachPort { 35 public: 36 MachPort() 37 : m_port(MACH_PORT_NULL) 38 , m_disposition(0) 39 { 40 } 31 StreamClientConnection::StreamClientConnection(Connection& connection, size_t size) 32 : m_connection(connection) 33 , m_buffer(size) 34 { 35 // Read starts from 0 with limit of 0 and reader sleeping. 36 sharedSenderOffset().store(StreamConnectionBuffer::senderOffsetReceiverIsSleepingTag, std::memory_order_relaxed); 37 // Write starts from 0 with a limit of the whole buffer. 38 sharedReceiverOffset().store(0, std::memory_order_relaxed); 39 } 41 40 42 MachPort(mach_port_name_t port, mach_msg_type_name_t disposition) 43 : m_port(port) 44 , m_disposition(disposition) 45 { 46 } 41 void StreamClientConnection::setWakeUpSemaphore(IPC::Semaphore&& semaphore) 42 { 43 #if PLATFORM(COCOA) 44 m_wakeUpSemaphore = WTFMove(semaphore); 45 #endif 46 wakeUpReceiver(); 47 } 47 48 48 void encode(Encoder& encoder) const 49 { 50 encoder << Attachment(m_port, m_disposition); 51 } 49 void StreamClientConnection::wakeUpReceiver() 50 { 51 #if PLATFORM(COCOA) 52 if (m_wakeUpSemaphore) 53 m_wakeUpSemaphore->signal(); 54 #endif 55 } 52 56 53 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, MachPort& p) 54 { 55 Attachment attachment; 56 if (!decoder.decode(attachment)) 57 return false; 58 59 p.m_port = attachment.port(); 60 p.m_disposition = attachment.disposition(); 61 return true; 62 } 63 64 mach_port_name_t port() const { return m_port; } 65 mach_msg_type_name_t disposition() const { return m_disposition; } 66 67 private: 68 mach_port_name_t m_port; 69 mach_msg_type_name_t m_disposition; 70 }; 71 72 } // namespace IPC 57 } -
trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.h
r273203 r273204 1 1 /* 2 * Copyright (C) 20 10Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include "Attachment.h" 29 #include "Decoder.h" 30 #include "Encoder.h" 28 #include "IPCSemaphore.h" 29 #include "StreamServerConnection.h" 30 #include <atomic> 31 #include <wtf/Deque.h> 32 #include <wtf/FunctionDispatcher.h> 33 #include <wtf/HashSet.h> 34 #include <wtf/Lock.h> 35 #include <wtf/Threading.h> 31 36 32 37 namespace IPC { 33 38 34 class MachPort{39 class StreamConnectionWorkQueue final : public FunctionDispatcher { 35 40 public: 36 MachPort() 37 : m_port(MACH_PORT_NULL) 38 , m_disposition(0) 39 { 40 } 41 StreamConnectionWorkQueue(const char*); 42 ~StreamConnectionWorkQueue() = default; 43 void addStreamConnection(StreamServerConnectionBase&); 44 void removeStreamConnection(StreamServerConnectionBase&); 41 45 42 MachPort(mach_port_name_t port, mach_msg_type_name_t disposition) 43 : m_port(port) 44 , m_disposition(disposition) 45 { 46 } 46 void dispatch(WTF::Function<void()>&&) final; 47 void stop(); 47 48 48 void encode(Encoder& encoder) const 49 { 50 encoder << Attachment(m_port, m_disposition); 51 } 49 void wakeUp(); 52 50 53 static WARN_UNUSED_RETURN bool decode(Decoder& decoder, MachPort& p) 54 { 55 Attachment attachment; 56 if (!decoder.decode(attachment)) 57 return false; 58 59 p.m_port = attachment.port(); 60 p.m_disposition = attachment.disposition(); 61 return true; 62 } 51 Semaphore& wakeUpSemaphore(); 52 private: 53 void wakeUpProcessingThread(); 54 void processStreams(); 63 55 64 mach_port_name_t port() const { return m_port; } 65 mach_msg_type_name_t disposition() const { return m_disposition; } 56 const char* const m_name; 57 Semaphore m_wakeUpSemaphore; 58 RefPtr<Thread> m_processingThread; 66 59 67 private: 68 mach_port_name_t m_port; 69 mach_msg_type_name_t m_disposition; 60 std::atomic<bool> m_shouldQuit { false }; 61 62 Lock m_lock; 63 Deque<Function<void()>> m_functions; 64 HashSet<Ref<StreamServerConnectionBase>> m_connections; 70 65 }; 71 66 72 } // namespace IPC67 } -
trunk/Source/WebKit/Platform/IPC/cocoa/MachPort.h
r259847 r273204 26 26 #pragma once 27 27 28 #include "ArgumentCoder.h" 28 29 #include "Attachment.h" 29 #include "Decoder.h"30 #include "Encoder.h"31 30 32 31 namespace IPC { -
trunk/Source/WebKit/Platform/IPC/win/ConnectionWin.cpp
r273196 r273204 27 27 #include "Connection.h" 28 28 29 #include "ArgumentCoder.h" 29 30 #include "DataReference.h" 30 31 #include <wtf/HexNumber.h> -
trunk/Source/WebKit/Scripts/webkit/messages.py
r273143 r273204 25 25 import sys 26 26 27 from model import MessageReceiver, Message 27 28 from webkit import parser 28 from webkit.model import BUILTIN_ATTRIBUTE, ASYNC_ATTRIBUTE, SYNCHRONOUS_ATTRIBUTE, MAINTHREADCALLBACK_ATTRIBUTE 29 from webkit.model import BUILTIN_ATTRIBUTE, ASYNC_ATTRIBUTE, SYNCHRONOUS_ATTRIBUTE, MAINTHREADCALLBACK_ATTRIBUTE, STREAM_ATTRIBUTE, WANTS_CONNECTION_ATTRIBUTE 29 30 30 31 _license_header = """/* … … 54 55 """ 55 56 56 WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection'57 57 WANTS_DISPATCH_MESSAGE_ATTRIBUTE = 'WantsDispatchMessage' 58 58 WANTS_ASYNC_DISPATCH_MESSAGE_ATTRIBUTE = 'WantsAsyncDispatchMessage' 59 59 LEGACY_RECEIVER_ATTRIBUTE = 'LegacyReceiver' 60 60 NOT_REFCOUNTED_RECEIVER_ATTRIBUTE = 'NotRefCounted' 61 62 61 63 62 def receiver_enumerator_order_key(receiver_name): … … 214 213 else: 215 214 result.append(' static constexpr auto callbackThread = WTF::CompletionHandlerCallThread::ConstructionThread;\n') 216 if message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE):215 if (message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE)) and not receiver.has_attribute(STREAM_ATTRIBUTE): 217 216 result.append(' static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&') 218 217 if len(send_parameters): … … 262 261 'IPC::DataReference', 263 262 'IPC::FontReference', 263 'IPC::Semaphore', 264 264 'MachSendRight', 265 265 'MediaTime', … … 574 574 575 575 wants_connection = message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(WANTS_CONNECTION_ATTRIBUTE) 576 maybe_reply_encoder = ", *replyEncoder" 577 if receiver.has_attribute(STREAM_ATTRIBUTE): 578 maybe_reply_encoder = '' 579 elif message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE): 580 maybe_reply_encoder = ', replyEncoder' 576 581 577 582 result = [] 578 583 result.append(' if (decoder.messageName() == Messages::%s::%s::name()) {\n' % (receiver.name, message.name)) 579 result.append(' IPC::%s<Messages::%s::%s>(%sdecoder , %sreplyEncoder, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if wants_connection else '', '' if message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE) else '*', handler_function(receiver, message)))584 result.append(' IPC::%s<Messages::%s::%s>(%sdecoder%s, this, &%s);\n' % (dispatch_function, receiver.name, message.name, 'connection, ' if wants_connection else '', maybe_reply_encoder, handler_function(receiver, message))) 580 585 result.append(' return;\n') 581 586 result.append(' }\n') … … 876 881 delayed_or_async_messages.append(message) 877 882 878 if delayed_or_async_messages :883 if delayed_or_async_messages and not receiver.has_attribute(STREAM_ATTRIBUTE): 879 884 result.append('namespace Messages {\n\nnamespace %s {\n\n' % receiver.name) 880 885 … … 924 929 async_messages.append(message) 925 930 926 if async_messages or receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE) or receiver.has_attribute(WANTS_ASYNC_DISPATCH_MESSAGE_ATTRIBUTE):927 result.append('void %s::didReceive %sMessage(IPC::Connection& connection, IPC::Decoder& decoder)\n' % (receiver.name, receiver.name if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE) else ''))931 if receiver.has_attribute(STREAM_ATTRIBUTE): 932 result.append('void %s::didReceiveStreamMessage(IPC::StreamServerConnectionBase& connection, IPC::Decoder& decoder)\n' % (receiver.name)) 928 933 result.append('{\n') 929 if not receiver.has_attribute(NOT_REFCOUNTED_RECEIVER_ATTRIBUTE): 934 assert(receiver.has_attribute(NOT_REFCOUNTED_RECEIVER_ATTRIBUTE)) 935 assert(not receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE)) 936 assert(not receiver.has_attribute(WANTS_ASYNC_DISPATCH_MESSAGE_ATTRIBUTE)) 937 938 result += [async_message_statement(receiver, message) for message in async_messages] 939 result += [sync_message_statement(receiver, message) for message in sync_messages] 940 941 if (receiver.superclass): 942 result.append(' %s::didReceiveStreamMessage(connection, decoder);\n' % (receiver.superclass)) 943 else: 944 result.append(' UNUSED_PARAM(decoder);\n') 945 result.append(' UNUSED_PARAM(connection);\n') 946 result.append(' ASSERT_NOT_REACHED();\n') 947 result.append('}\n') 948 elif async_messages or receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE) or receiver.has_attribute(WANTS_ASYNC_DISPATCH_MESSAGE_ATTRIBUTE): 949 receive_variant = receiver.name if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE) else '' 950 result.append('void %s::didReceive%sMessage(IPC::Connection& connection, IPC::Decoder& decoder)\n' % (receiver.name, receive_variant)) 951 result.append('{\n') 952 if not (receiver.has_attribute(NOT_REFCOUNTED_RECEIVER_ATTRIBUTE) or receiver.has_attribute(STREAM_ATTRIBUTE)): 930 953 result.append(' auto protectedThis = makeRef(*this);\n') 931 954 932 955 result += [async_message_statement(receiver, message) for message in async_messages] 956 933 957 if receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE) or receiver.has_attribute(WANTS_ASYNC_DISPATCH_MESSAGE_ATTRIBUTE): 934 958 result.append(' if (dispatchMessage(connection, decoder))\n') 935 959 result.append(' return;\n') 936 960 if (receiver.superclass): 937 result.append(' %s::didReceive Message(connection, decoder);\n' % (receiver.superclass))961 result.append(' %s::didReceive%sMessage(connection, decoder);\n' % (receiver.superclass, receive_variant)) 938 962 else: 939 963 result.append(' UNUSED_PARAM(connection);\n') … … 942 966 result.append('}\n') 943 967 944 if sync_messages or receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE):968 if not receiver.has_attribute(STREAM_ATTRIBUTE) and (sync_messages or receiver.has_attribute(WANTS_DISPATCH_MESSAGE_ATTRIBUTE)): 945 969 result.append('\n') 946 970 result.append('void %s::didReceiveSync%sMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)\n' % (receiver.name, receiver.name if receiver.has_attribute(LEGACY_RECEIVER_ATTRIBUTE) else '')) -
trunk/Source/WebKit/Scripts/webkit/messages_unittest.py
r272786 r273204 47 47 'TestWithSemaphore', 48 48 'TestWithImageData', 49 'TestWithStream', 50 'TestWithStreamBuffer' 49 51 ] 50 52 -
trunk/Source/WebKit/Scripts/webkit/model.py
r272873 r273204 29 29 MAINTHREADCALLBACK_ATTRIBUTE = "MainThreadCallback" 30 30 SYNCHRONOUS_ATTRIBUTE = 'Synchronous' 31 STREAM_ATTRIBUTE = "Stream" 32 WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection' 31 33 32 34 class MessageReceiver(object): … … 74 76 Message('SyncMessageReply', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 75 77 Message('InitializeConnection', [], [], attributes=[BUILTIN_ATTRIBUTE], condition="PLATFORM(COCOA)"), 76 Message('LegacySessionState', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None) 78 Message('LegacySessionState', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 79 Message('SetStreamDestinationID', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None), 80 Message('ProcessOutOfStreamMessage', [], [], attributes=[BUILTIN_ATTRIBUTE], condition=None) 77 81 ], condition=None) 78 82 -
trunk/Source/WebKit/Scripts/webkit/tests/Makefile
r272786 r273204 7 7 TestWithSemaphore \ 8 8 TestWithImageData \ 9 TestWithStream \ 10 TestWithStreamBuffer \ 9 11 # 10 12 -
trunk/Source/WebKit/Scripts/webkit/tests/MessageNames.cpp
r272786 r273204 135 135 case MessageName::LegacySessionState: 136 136 return "LegacySessionState"; 137 case MessageName::ProcessOutOfStreamMessage: 138 return "ProcessOutOfStreamMessage"; 139 case MessageName::SetStreamDestinationID: 140 return "SetStreamDestinationID"; 137 141 case MessageName::SyncMessageReply: 138 142 return "SyncMessageReply"; … … 225 229 case MessageName::InitializeConnection: 226 230 case MessageName::LegacySessionState: 231 case MessageName::ProcessOutOfStreamMessage: 232 case MessageName::SetStreamDestinationID: 227 233 case MessageName::SyncMessageReply: 228 234 return ReceiverName::IPC; … … 402 408 if (messageName == IPC::MessageName::LegacySessionState) 403 409 return true; 410 if (messageName == IPC::MessageName::ProcessOutOfStreamMessage) 411 return true; 412 if (messageName == IPC::MessageName::SetStreamDestinationID) 413 return true; 404 414 if (messageName == IPC::MessageName::SyncMessageReply) 405 415 return true; -
trunk/Source/WebKit/Scripts/webkit/tests/MessageNames.h
r272786 r273204 94 94 , InitializeConnection 95 95 , LegacySessionState 96 , ProcessOutOfStreamMessage 97 , SetStreamDestinationID 96 98 , SyncMessageReply 97 99 , TestWithSuperclass_TestAsyncMessageReply -
trunk/Source/WebKit/Scripts/webkit/tests/TestWithStream.messages.in
r273203 r273204 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) 24 25 messages -> RemoteGraphicsContextGLProxy NotRefCounted { 26 void WasCreated(bool didSucceed, String availableExtensions, String requestableExtensions) 27 void WasLost() 28 void WasChanged() 23 # Tests Stream receiver attribute. 24 messages -> TestWithStream NotRefCounted Stream { 25 void SendString(String url) 26 void SendStringSynchronized(String url) -> (int64_t return) 29 27 } 30 31 #endif -
trunk/Source/WebKit/Scripts/webkit/tests/TestWithStreamBuffer.messages.in
r273203 r273204 21 21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 22 23 #if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) 24 25 messages -> RemoteGraphicsContextGLProxy NotRefCounted { 26 void WasCreated(bool didSucceed, String availableExtensions, String requestableExtensions) 27 void WasLost() 28 void WasChanged() 23 # Tests Stream receiver attribute. 24 messages -> TestWithStreamBuffer { 25 void SendStreamBuffer(IPC::StreamConnectionBuffer stream) 29 26 } 30 31 #endif -
trunk/Source/WebKit/Sources.txt
r272916 r273204 151 151 Platform/IPC/SharedBufferCopy.cpp @no-unify 152 152 Platform/IPC/SharedBufferDataReference.cpp @no-unify 153 Platform/IPC/StreamClientConnection.cpp @no-unify 154 Platform/IPC/StreamConnectionBuffer.cpp @no-unify 155 Platform/IPC/StreamConnectionWorkQueue.cpp @no-unify 156 Platform/IPC/StreamServerConnection.cpp @no-unify 153 157 Platform/IPC/StringReference.cpp @no-unify 154 158 -
trunk/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
r270638 r273204 28 28 #include "APIObject.h" 29 29 #include "Connection.h" 30 #include "DataReference.h" 30 31 #include "DownloadID.h" 31 32 #include "SandboxExtension.h" -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
r273183 r273204 31 31 #include "DrawingAreaProxy.h" 32 32 #include "FormDataReference.h" 33 #include "HandleMessage.h" 33 34 #include "Logging.h" 34 35 #include "PageClient.h" -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h
r267885 r273204 26 26 #pragma once 27 27 28 #include "DataReference.h" 28 29 #include "MessageReceiver.h" 29 30 #include "MessageSender.h" -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r273184 r273204 1336 1336 7B483F2125CDDA9C00120486 /* MessageReceiveQueueMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B483F1D25CDDA9B00120486 /* MessageReceiveQueueMap.cpp */; }; 1337 1337 7B483F2225CDDA9C00120486 /* MessageReceiveQueues.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B483F1E25CDDA9B00120486 /* MessageReceiveQueues.h */; }; 1338 7B73123A25CC8525003B2796 /* StreamConnectionBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B73123125CC8523003B2796 /* StreamConnectionBuffer.h */; }; 1339 7B73123B25CC8525003B2796 /* StreamConnectionWorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B73123225CC8523003B2796 /* StreamConnectionWorkQueue.cpp */; }; 1340 7B73123C25CC8525003B2796 /* StreamClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B73123325CC8523003B2796 /* StreamClientConnection.h */; }; 1341 7B73123D25CC8525003B2796 /* StreamConnectionBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B73123425CC8524003B2796 /* StreamConnectionBuffer.cpp */; }; 1342 7B73123E25CC8525003B2796 /* StreamConnectionWorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B73123525CC8524003B2796 /* StreamConnectionWorkQueue.h */; }; 1343 7B73123F25CC8525003B2796 /* StreamClientConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B73123625CC8524003B2796 /* StreamClientConnection.cpp */; }; 1344 7B73124025CC8525003B2796 /* StreamServerConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B73123725CC8524003B2796 /* StreamServerConnection.cpp */; }; 1345 7B73124125CC8525003B2796 /* StreamServerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B73123825CC8524003B2796 /* StreamServerConnection.h */; }; 1346 7B73124225CC8525003B2796 /* StreamConnectionEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B73123925CC8525003B2796 /* StreamConnectionEncoder.h */; }; 1347 7BAB111025DD02B3008FC479 /* ScopedActiveMessageReceiveQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BAB110F25DD02B2008FC479 /* ScopedActiveMessageReceiveQueue.h */; }; 1338 1348 7C065F2C1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C065F2A1C8CD95F00C2D950 /* WebUserContentControllerDataTypes.h */; }; 1339 1349 7C135AA9173B0BCA00586AE2 /* WKPluginInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C135AA7173B0BCA00586AE2 /* WKPluginInformation.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4546 4556 7B483F1E25CDDA9B00120486 /* MessageReceiveQueues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageReceiveQueues.h; sourceTree = "<group>"; }; 4547 4557 7B64C0B6254C5C250006B4AF /* GraphicsContextGLIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLIdentifier.h; sourceTree = "<group>"; }; 4558 7B73123125CC8523003B2796 /* StreamConnectionBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamConnectionBuffer.h; sourceTree = "<group>"; }; 4559 7B73123225CC8523003B2796 /* StreamConnectionWorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamConnectionWorkQueue.cpp; sourceTree = "<group>"; }; 4560 7B73123325CC8523003B2796 /* StreamClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamClientConnection.h; sourceTree = "<group>"; }; 4561 7B73123425CC8524003B2796 /* StreamConnectionBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamConnectionBuffer.cpp; sourceTree = "<group>"; }; 4562 7B73123525CC8524003B2796 /* StreamConnectionWorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamConnectionWorkQueue.h; sourceTree = "<group>"; }; 4563 7B73123625CC8524003B2796 /* StreamClientConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamClientConnection.cpp; sourceTree = "<group>"; }; 4564 7B73123725CC8524003B2796 /* StreamServerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamServerConnection.cpp; sourceTree = "<group>"; }; 4565 7B73123825CC8524003B2796 /* StreamServerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamServerConnection.h; sourceTree = "<group>"; }; 4566 7B73123925CC8525003B2796 /* StreamConnectionEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamConnectionEncoder.h; sourceTree = "<group>"; }; 4548 4567 7B904165254AFDEA006EEB8C /* RemoteGraphicsContextGLProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxy.cpp; sourceTree = "<group>"; }; 4549 4568 7B904166254AFDEB006EEB8C /* RemoteGraphicsContextGLProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteGraphicsContextGLProxy.h; sourceTree = "<group>"; }; … … 4553 4572 7B90416A254AFEA7006EEB8C /* RemoteGraphicsContextGL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteGraphicsContextGL.h; sourceTree = "<group>"; }; 4554 4573 7B90416D2550108C006EEB8C /* RemoteGraphicsContextGLFunctionsGenerated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteGraphicsContextGLFunctionsGenerated.h; sourceTree = "<group>"; }; 4574 7BAB110F25DD02B2008FC479 /* ScopedActiveMessageReceiveQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScopedActiveMessageReceiveQueue.h; sourceTree = "<group>"; }; 4555 4575 7BE726572574F67200E85D98 /* RemoteGraphicsContextGLProxyFunctionsGenerated.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLProxyFunctionsGenerated.cpp; sourceTree = "<group>"; }; 4556 4576 7BE72668257680EF00E85D98 /* RemoteGraphicsContextGLCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteGraphicsContextGLCocoa.cpp; sourceTree = "<group>"; }; … … 6988 7008 1AAB0377185A7C6A00EDF501 /* MessageSender.cpp */, 6989 7009 1AAB0378185A7C6A00EDF501 /* MessageSender.h */, 7010 7BAB110F25DD02B2008FC479 /* ScopedActiveMessageReceiveQueue.h */, 6990 7011 2DC18001D90DDD15FC6991A9 /* SharedBufferCopy.cpp */, 6991 7012 5CC5DB9121488E16006CB8A8 /* SharedBufferCopy.h */, 6992 7013 2DC1855EDBFB850BA0B6D06D /* SharedBufferDataReference.cpp */, 6993 7014 2DC1881ACBCAB5D57C5C6EF0 /* SharedBufferDataReference.h */, 7015 7B73123625CC8524003B2796 /* StreamClientConnection.cpp */, 7016 7B73123325CC8523003B2796 /* StreamClientConnection.h */, 7017 7B73123425CC8524003B2796 /* StreamConnectionBuffer.cpp */, 7018 7B73123125CC8523003B2796 /* StreamConnectionBuffer.h */, 7019 7B73123925CC8525003B2796 /* StreamConnectionEncoder.h */, 7020 7B73123225CC8523003B2796 /* StreamConnectionWorkQueue.cpp */, 7021 7B73123525CC8524003B2796 /* StreamConnectionWorkQueue.h */, 7022 7B73123725CC8524003B2796 /* StreamServerConnection.cpp */, 7023 7B73123825CC8524003B2796 /* StreamServerConnection.h */, 6994 7024 1AE00D6918327C1200087DD7 /* StringReference.cpp */, 6995 7025 1AE00D6A18327C1200087DD7 /* StringReference.h */, … … 12016 12046 1AAB4A8D1296F0A20023952F /* SandboxExtension.h in Headers */, 12017 12047 E1E552C516AE065F004ED653 /* SandboxInitializationParameters.h in Headers */, 12048 7BAB111025DD02B3008FC479 /* ScopedActiveMessageReceiveQueue.h in Headers */, 12018 12049 E4D54D0421F1D72D007E3C36 /* ScrollingTreeFrameScrollingNodeRemoteIOS.h in Headers */, 12019 12050 0F931C1C18C5711900DBA7C3 /* ScrollingTreeOverflowScrollingNodeIOS.h in Headers */, … … 12065 12096 9368EEDF2303A9ED00BDB11A /* StorageManagerSetMessages.h in Headers */, 12066 12097 465F4E06230B2E95003CEDB7 /* StorageNamespaceIdentifier.h in Headers */, 12098 7B73123C25CC8525003B2796 /* StreamClientConnection.h in Headers */, 12099 7B73123A25CC8525003B2796 /* StreamConnectionBuffer.h in Headers */, 12100 7B73124225CC8525003B2796 /* StreamConnectionEncoder.h in Headers */, 12101 7B73123E25CC8525003B2796 /* StreamConnectionWorkQueue.h in Headers */, 12102 7B73124125CC8525003B2796 /* StreamServerConnection.h in Headers */, 12067 12103 1AE00D6C18327C1200087DD7 /* StringReference.h in Headers */, 12068 12104 296BD85D15019BC30071F424 /* StringUtilities.h in Headers */, … … 13891 13927 1A334DED16DE8F88006A8E38 /* StorageAreaMapMessageReceiver.cpp in Sources */, 13892 13928 9368EEDE2303A90200BDB11A /* StorageManagerSetMessageReceiver.cpp in Sources */, 13929 7B73123F25CC8525003B2796 /* StreamClientConnection.cpp in Sources */, 13930 7B73123D25CC8525003B2796 /* StreamConnectionBuffer.cpp in Sources */, 13931 7B73123B25CC8525003B2796 /* StreamConnectionWorkQueue.cpp in Sources */, 13932 7B73124025CC8525003B2796 /* StreamServerConnection.cpp in Sources */, 13893 13933 2D92A783212B6A7100F493FD /* StringReference.cpp in Sources */, 13894 13934 2D11B7512126A282006F8878 /* UnifiedSource1-mm.mm in Sources */, -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp
r273080 r273204 50 50 } 51 51 52 static constexpr size_t defaultStreamSize = 1 << 21; 53 52 54 RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy(GPUProcessConnection& gpuProcessConnection, const GraphicsContextGLAttributes& attributes, RenderingBackendIdentifier renderingBackend) 53 55 : RemoteGraphicsContextGLProxyBase(attributes) 54 56 , m_gpuProcessConnection(&gpuProcessConnection) 57 , m_streamConnection(gpuProcessConnection.connection(), defaultStreamSize) 55 58 { 56 59 m_gpuProcessConnection->addClient(*this); 57 60 m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::RemoteGraphicsContextGLProxy::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64(), *this); 58 connection().send(Messages::GPUConnectionToWebProcess::CreateGraphicsContextGL(attributes, m_graphicsContextGLIdentifier, renderingBackend ), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);61 connection().send(Messages::GPUConnectionToWebProcess::CreateGraphicsContextGL(attributes, m_graphicsContextGLIdentifier, renderingBackend, m_streamConnection.streamBuffer()), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply); 59 62 } 60 63 … … 185 188 } 186 189 187 void RemoteGraphicsContextGLProxy::wasCreated(bool didSucceed, String&& availableExtensions, String&& requestedExtensions)190 void RemoteGraphicsContextGLProxy::wasCreated(bool didSucceed, IPC::Semaphore&& semaphore, String&& availableExtensions, String&& requestedExtensions) 188 191 { 189 192 if (isContextLost()) … … 194 197 } 195 198 ASSERT(!m_didInitialize); 199 m_streamConnection.setWakeUpSemaphore(WTFMove(semaphore)); 196 200 m_didInitialize = true; 197 201 initialize(availableExtensions, requestedExtensions); -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h
r273080 r273204 30 30 #include "GPUProcessConnection.h" 31 31 #include "GraphicsContextGLIdentifier.h" 32 #include "IPCSemaphore.h" 32 33 #include "MessageReceiver.h" 33 #include "MessageSender.h"34 34 #include "RemoteGraphicsContextGLMessages.h" 35 35 #include "RemoteResourceCacheProxy.h" 36 36 #include "RenderingBackendIdentifier.h" 37 #include "StreamClientConnection.h" 37 38 #include "WebCoreArgumentCoders.h" 38 39 #include <WebCore/NotImplemented.h> … … 336 337 WARN_UNUSED_RETURN bool send(T&& message) 337 338 { 338 connection().send(WTFMove(message), m_graphicsContextGLIdentifier.toUInt64(), IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply); 339 return true; 339 return m_streamConnection.send(WTFMove(message), m_graphicsContextGLIdentifier, defaultSendTimeout); 340 340 } 341 341 template<typename T> 342 342 WARN_UNUSED_RETURN IPC::Connection::SendSyncResult sendSync(T&& message, typename T::Reply&& reply) 343 343 { 344 return connection().sendSync(WTFMove(message), WTFMove(reply), m_graphicsContextGLIdentifier.toUInt64(), defaultSendTimeout);344 return m_streamConnection.sendSync(WTFMove(message), WTFMove(reply), m_graphicsContextGLIdentifier, defaultSendTimeout); 345 345 } 346 346 IPC::Connection& connection() const { return m_gpuProcessConnection->connection(); } … … 348 348 private: 349 349 // Messages to be received. 350 void wasCreated(bool didSucceed, String&& availableExtensions, String&& requestedExtensions);350 void wasCreated(bool didSucceed, IPC::Semaphore&&, String&& availableExtensions, String&& requestedExtensions); 351 351 void wasLost(); 352 352 void wasChanged(); … … 362 362 bool m_didInitialize { false }; 363 363 GCGLenum m_errorWhenContextIsLost = NO_ERROR; 364 365 364 GraphicsContextGLIdentifier m_graphicsContextGLIdentifier { GraphicsContextGLIdentifier::generate() }; 365 IPC::StreamClientConnection m_streamConnection; 366 366 }; 367 367 -
trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in
r272645 r273204 24 24 25 25 messages -> RemoteGraphicsContextGLProxy NotRefCounted { 26 void WasCreated(bool didSucceed, String availableExtensions, String requestableExtensions)26 void WasCreated(bool didSucceed, IPC::Semaphore streamWakeUpSemaphore, String availableExtensions, String requestableExtensions) 27 27 void WasLost() 28 28 void WasChanged() -
trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h
r272684 r273204 29 29 30 30 #include "Connection.h" 31 #include "DataReference.h" 31 32 #include "InspectorExtensionTypes.h" 32 33 #include "MessageReceiver.h" -
trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCNetwork.h
r273074 r273204 27 27 28 28 #include "Connection.h" 29 #include "DataReference.h" 29 30 #include "LibWebRTCProvider.h" 30 31 #include "LibWebRTCSocketFactory.h" -
trunk/Tools/ChangeLog
r273202 r273204 1 2021-02-20 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 WebGL GPU process IPC should use shared memory for asynchronous messages 4 https://bugs.webkit.org/show_bug.cgi?id=219641 5 <rdar://problem/72340651> 6 7 Reviewed by Geoff Garen. 8 9 Mark RemoteGraphicsContextGL message receiver as "Stream", 10 a new variant of receiver. 11 12 * Scripts/generate-gpup-webgl: 13 1 14 2021-02-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 15 -
trunk/Tools/Scripts/generate-gpup-webgl
r273080 r273204 90 90 + """#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL) 91 91 92 messages -> RemoteGraphicsContextGL NotRefCounted {{92 messages -> RemoteGraphicsContextGL NotRefCounted Stream {{ 93 93 void Reshape(int32_t width, int32_t height) 94 94 #if PLATFORM(COCOA)
Note: See TracChangeset
for help on using the changeset viewer.