[webkit-changes] [WebKit/WebKit] de2eda: Optimize postMessage between two MessageChannel po...

youennf noreply at github.com
Tue Oct 25 01:46:46 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: de2edaa00af9a1ba0f9e9caa0676c2ce4c3b73c8
      https://github.com/WebKit/WebKit/commit/de2edaa00af9a1ba0f9e9caa0676c2ce4c3b73c8
  Author: Youenn Fablet <youennf at gmail.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebMessagePortChannelProvider.h

  Log Message:
  -----------
  Optimize postMessage between two MessageChannel ports living in the same 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




More information about the webkit-changes mailing list