mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
Add direct script to embedder channel (#39039)
This PR **removes** `ScriptToConstellationMessage::ForwardToEmbedder`, and replaces it with an explicit `ScriptToEmbedderChannel`. This new channel is based on `GenericCallback` and in single-process mode will directly send the message the to the embedder and wake it. In multi-process mode, the message is routed via the ROUTER, since waking is only possible from the same process currently. This means in multi-process mode there are likely no direct perf benefits, since we still need to hop the message over the ROUTER (instead of over the constellation). In single-process mode we can directly send the message to the embedder, which should provide a noticable latency improvement in all cases where script is blocked waiting on the embedder to reply. This does not change the way the embedder receives messages - the receiving end is unchanged. ## How was sending messages to the embedder working before? 1. Script wraps it's message to the embedder in `ScriptToConstellationMessage::ForwardToEmbedder` and sends it to constellation. 2. The [constellation event loop] receives the message in [handle_request] 3. If deserialization fails, [an error is logged and the message is ignored] 4. Since our message came from script, it is handle in [handle_request_from_script] 5. The message is logged with trace log level 6. If the pipeline is closed, [a warning is logged and the message ignored] 7. The wrapped `EmbedderMsg` [is forwarded to the embedder]. Sending the message also invokes `wake()` on the embedder eventloop waker. [constellation event loop]:2e1b2e7260/components/constellation/constellation.rs (L755)
[handle request]:2e1b2e7260/components/constellation/constellation.rs (L1182)
[an error is logged and the message is ignored]:2e1b2e7260/components/constellation/constellation.rs (L1252)
[handle_request_from_script]: https://github.com/servo/servo/blob/main/components/constellation/constellation.rs#L1590 [a warning is logged and the message ignored]:2e1b2e7260/components/constellation/constellation.rs (L1599)
[is forwarded to the embedder]:2e1b2e7260/components/constellation/constellation.rs (L1701)
Testing: Communication between Script and Embedder is extensive, so this should be covered by existing tests. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
97c8c83cbb
commit
f4dd2960b8
21 changed files with 120 additions and 113 deletions
|
@ -781,6 +781,10 @@ impl ScriptThread {
|
|||
.senders
|
||||
.pipeline_to_constellation_sender
|
||||
.clone(),
|
||||
to_embedder_sender: script_thread
|
||||
.senders
|
||||
.pipeline_to_embedder_sender
|
||||
.clone(),
|
||||
image_cache,
|
||||
#[cfg(feature = "webgpu")]
|
||||
gpu_id_hub: script_thread.gpu_id_hub.clone(),
|
||||
|
@ -941,6 +945,7 @@ impl ScriptThread {
|
|||
bluetooth_sender: state.bluetooth_sender,
|
||||
constellation_sender: state.constellation_sender,
|
||||
pipeline_to_constellation_sender: state.pipeline_to_constellation_sender.sender.clone(),
|
||||
pipeline_to_embedder_sender: state.pipeline_to_embedder_sender.clone(),
|
||||
image_cache_sender: ipc_image_cache_sender,
|
||||
time_profiler_sender: state.time_profiler_sender,
|
||||
memory_profiler_sender: state.memory_profiler_sender,
|
||||
|
@ -966,6 +971,7 @@ impl ScriptThread {
|
|||
senders.memory_profiler_sender.clone(),
|
||||
senders.time_profiler_sender.clone(),
|
||||
script_to_constellation_chan,
|
||||
senders.pipeline_to_embedder_sender.clone(),
|
||||
state.resource_threads.clone(),
|
||||
#[cfg(feature = "webgpu")]
|
||||
gpu_id_hub.clone(),
|
||||
|
@ -3312,6 +3318,7 @@ impl ScriptThread {
|
|||
self.senders.time_profiler_sender.clone(),
|
||||
self.senders.devtools_server_sender.clone(),
|
||||
script_to_constellation_chan,
|
||||
self.senders.pipeline_to_embedder_sender.clone(),
|
||||
self.senders.constellation_sender.clone(),
|
||||
incomplete.pipeline_id,
|
||||
incomplete.parent_info,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue