Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Optimize postMessage between two MessageChannel ports living in the s…
…ame process https://bugs.webkit.org/show_bug.cgi?id=246943 rdar://problem/101497189 Reviewed by Alex Christensen. Some objects may be heavy to transfer from one process to another (RTCDataChannel, encoded chunks, video frames...). It is best if we can use the same code path as when doing Worker::postMessage. This is feasible as long as we keep the order of the messages, since each MessagePort has its own event queue. We introduce a map of port id to messages in WebMessagePortChannelProvider. We fill the map whenever creating or whenever entangling a port in the process. When postMessaging to that port, we check whether it is in process and if so add messages to the local map. When taking messages, we still go to network process but complement any message we may find by adding the local messages. * Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp: (WebKit::WebMessagePortChannelProvider::createNewMessagePortChannel): (WebKit::WebMessagePortChannelProvider::entangleLocalPortInThisProcessToRemote): (WebKit::WebMessagePortChannelProvider::messagePortDisentangled): (WebKit::WebMessagePortChannelProvider::messagePortClosed): (WebKit::WebMessagePortChannelProvider::takeAllMessagesForPort): (WebKit::WebMessagePortChannelProvider::postMessageToRemote): (WebKit::WebMessagePortChannelProvider::checkRemotePortForActivity): * Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.h: Canonical link: https://commits.webkit.org/255948@main
- Loading branch information