mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
script: Do not set up an IPC route for every image load (#35041)
Instead of setting up a route for every image load in the DOM / Layout, route all incoming image cache responses through the `ScriptThread`. This avoids creating a set of file descriptor for every image that is loaded. This change requires having the `ImageCache` track the `PipelineId` of the original the listener so that the `ScriptThread` can route it properly to the correct `Window`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
2ce7709b8b
commit
37695c8c8c
17 changed files with 260 additions and 272 deletions
|
@ -32,14 +32,12 @@ use crate::task::TaskBox;
|
|||
use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue};
|
||||
use crate::task_source::TaskSourceName;
|
||||
|
||||
pub(crate) type ImageCacheMsg = (PipelineId, PendingImageResponse);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum MixedMessage {
|
||||
FromConstellation(ConstellationControlMsg),
|
||||
FromScript(MainThreadScriptMsg),
|
||||
FromDevtools(DevtoolScriptControlMsg),
|
||||
FromImageCache((PipelineId, PendingImageResponse)),
|
||||
FromImageCache(PendingImageResponse),
|
||||
#[cfg(feature = "webgpu")]
|
||||
FromWebGPUServer(WebGPUMsg),
|
||||
TimerFired,
|
||||
|
@ -101,7 +99,7 @@ impl MixedMessage {
|
|||
MainThreadScriptMsg::Inactive => None,
|
||||
MainThreadScriptMsg::WakeUp => None,
|
||||
},
|
||||
MixedMessage::FromImageCache((pipeline_id, _)) => Some(*pipeline_id),
|
||||
MixedMessage::FromImageCache(response) => Some(response.pipeline_id),
|
||||
MixedMessage::FromDevtools(_) | MixedMessage::TimerFired => None,
|
||||
#[cfg(feature = "webgpu")]
|
||||
MixedMessage::FromWebGPUServer(..) => None,
|
||||
|
@ -321,9 +319,11 @@ pub(crate) struct ScriptThreadSenders {
|
|||
#[no_trace]
|
||||
pub(crate) layout_to_constellation_ipc_sender: IpcSender<LayoutMsg>,
|
||||
|
||||
/// The [`Sender`] on which messages can be sent to the `ImageCache`.
|
||||
/// The shared [`IpcSender`] which is sent to the `ImageCache` when requesting an image. The
|
||||
/// messages on this channel are routed to crossbeam [`Sender`] on the router thread, which
|
||||
/// in turn sends messages to [`ScriptThreadReceivers::image_cache_receiver`].
|
||||
#[no_trace]
|
||||
pub(crate) image_cache_sender: Sender<ImageCacheMsg>,
|
||||
pub(crate) image_cache_sender: IpcSender<PendingImageResponse>,
|
||||
|
||||
/// For providing contact with the time profiler.
|
||||
#[no_trace]
|
||||
|
@ -352,7 +352,7 @@ pub(crate) struct ScriptThreadReceivers {
|
|||
|
||||
/// The [`Receiver`] which receives incoming messages from the `ImageCache`.
|
||||
#[no_trace]
|
||||
pub(crate) image_cache_receiver: Receiver<ImageCacheMsg>,
|
||||
pub(crate) image_cache_receiver: Receiver<PendingImageResponse>,
|
||||
|
||||
/// For receiving commands from an optional devtools server. Will be ignored if no such server
|
||||
/// exists. When devtools are not active this will be [`crossbeam_channel::never()`].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue