mirror of
https://github.com/servo/servo
synced 2026-05-13 10:27:03 +02:00
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>
48 lines
1.4 KiB
TOML
48 lines
1.4 KiB
TOML
[package]
|
|
name = "script_traits"
|
|
version.workspace = true
|
|
authors.workspace = true
|
|
license.workspace = true
|
|
edition.workspace = true
|
|
publish.workspace = true
|
|
rust-version.workspace = true
|
|
|
|
[lib]
|
|
name = "script_traits"
|
|
path = "lib.rs"
|
|
|
|
[features]
|
|
bluetooth = ["bluetooth_traits"]
|
|
webgpu = ["webgpu_traits"]
|
|
|
|
[dependencies]
|
|
background_hang_monitor_api = { workspace = true }
|
|
base = { workspace = true }
|
|
bluetooth_traits = { workspace = true, optional = true }
|
|
canvas_traits = { workspace = true }
|
|
compositing_traits = { workspace = true }
|
|
constellation_traits = { workspace = true }
|
|
crossbeam-channel = { workspace = true }
|
|
devtools_traits = { workspace = true }
|
|
embedder_traits = { workspace = true }
|
|
euclid = { workspace = true }
|
|
ipc-channel = { workspace = true }
|
|
keyboard-types = { workspace = true }
|
|
malloc_size_of = { workspace = true }
|
|
malloc_size_of_derive = { workspace = true }
|
|
media = { path = "../../media" }
|
|
net_traits = { workspace = true }
|
|
pixels = { path = "../../pixels" }
|
|
profile_traits = { workspace = true }
|
|
serde = { workspace = true }
|
|
servo_config = { path = "../../config" }
|
|
servo_url = { path = "../../url" }
|
|
strum = { workspace = true, features = ["derive"] }
|
|
strum_macros = { workspace = true }
|
|
stylo_atoms = { workspace = true }
|
|
stylo_traits = { workspace = true }
|
|
webgpu_traits = { workspace = true, optional = true }
|
|
webrender_api = { workspace = true }
|
|
webxr-api = { workspace = true, features = ["ipc"] }
|
|
log = "0.4.27"
|