Use GenericChannel for script_chan (#38645)

Motivation: 
Using our GenericChannel abstraction allows us to optimize IPC in
single-process mode to just use cross-beam channel.
To keep the diff low, and get early feedback, this PR only tackles a
single channel, but the intention is to port all ipc channels to the
generic channel, which allows us to skip serializing and deserializing
messages in single process mode.

Based on: 
- https://github.com/servo/servo/pull/38638
- https://github.com/servo/servo/pull/38636

Testing: Covered by existing tests

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2025-08-19 11:59:20 +02:00 committed by GitHub
parent 73e0f2f7e6
commit 8587536755
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 36 additions and 22 deletions

View file

@ -17,6 +17,7 @@ use std::time::{Duration, Instant};
use app_units::Au;
use backtrace::Backtrace;
use base::cross_process_instant::CrossProcessInstant;
use base::generic_channel::GenericSender;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use base64::Engine;
#[cfg(feature = "bluetooth")]
@ -3043,7 +3044,7 @@ impl Window {
time_profiler_chan: TimeProfilerChan,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ScriptToConstellationChan,
control_chan: IpcSender<ScriptThreadMessage>,
control_chan: GenericSender<ScriptThreadMessage>,
pipeline_id: PipelineId,
parent_info: Option<PipelineId>,
viewport_details: ViewportDetails,
@ -3292,7 +3293,7 @@ impl Window {
#[derive(MallocSizeOf)]
pub(crate) struct CSSErrorReporter {
pub(crate) pipelineid: PipelineId,
pub(crate) script_chan: IpcSender<ScriptThreadMessage>,
pub(crate) script_chan: GenericSender<ScriptThreadMessage>,
}
unsafe_no_jsmanaged_fields!(CSSErrorReporter);

View file

@ -8,6 +8,7 @@ use std::cell::RefCell;
use std::option::Option;
use std::result::Result;
use base::generic_channel::GenericSender;
use base::id::PipelineId;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
@ -331,7 +332,7 @@ pub(crate) struct ScriptThreadSenders {
/// A [`Sender`] that sends messages to the `Constellation`.
#[no_trace]
pub(crate) constellation_sender: IpcSender<ScriptThreadMessage>,
pub(crate) constellation_sender: GenericSender<ScriptThreadMessage>,
/// A [`Sender`] that sends messages to the `Constellation` associated with
/// particular pipelines.

View file

@ -871,9 +871,7 @@ impl ScriptThread {
JS_AddInterruptCallback(cx, Some(interrupt_callback));
}
// Ask the router to proxy IPC messages from the control port to us.
let constellation_receiver =
ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(state.constellation_receiver);
let constellation_receiver = state.constellation_receiver.into_inner();
// Ask the router to proxy IPC messages from the devtools to us.
let devtools_server_sender = state.devtools_server_sender;