mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
script: Make timers per-process (#34581)
Before all timers were managed by the Constellation process, meaning that they had to trigger IPC calls to be scheduled and fired. Currently, timers are only used in the `ScriptThread`, so it makes sense that they are per-process. This change restores the timer thread functionality that existed before avoided entirely. Completion is done using a callback that is sent to the timer thread similarly to how fetch is done. This allows reusing the existing task queue without making any new channels. Fixes #15219. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
ff7626bfc6
commit
226299380d
21 changed files with 366 additions and 324 deletions
|
@ -110,7 +110,7 @@ use canvas_traits::ConstellationCanvasMsg;
|
|||
use compositing_traits::{
|
||||
CompositorMsg, CompositorProxy, ConstellationMsg as FromCompositorMsg, SendableFrameTree,
|
||||
};
|
||||
use crossbeam_channel::{after, never, select, unbounded, Receiver, Sender};
|
||||
use crossbeam_channel::{select, unbounded, Receiver, Sender};
|
||||
use devtools_traits::{
|
||||
ChromeToDevtoolsControlMsg, DevtoolsControlMsg, DevtoolsPageInfo, NavigationState,
|
||||
ScriptToDevtoolsControlMsg,
|
||||
|
@ -143,7 +143,7 @@ use script_traits::{
|
|||
LogEntry, MediaSessionActionType, MessagePortMsg, MouseEventType, NavigationHistoryBehavior,
|
||||
PortMessageTask, SWManagerMsg, SWManagerSenders, ScriptMsg as FromScriptMsg,
|
||||
ScriptToConstellationChan, ServiceWorkerManagerFactory, ServiceWorkerMsg,
|
||||
StructuredSerializedData, Theme, TimerSchedulerMsg, TraversalDirection, UpdatePipelineIdReason,
|
||||
StructuredSerializedData, Theme, TraversalDirection, UpdatePipelineIdReason,
|
||||
WebDriverCommandMsg, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -172,7 +172,6 @@ use crate::serviceworker::ServiceWorkerUnprivilegedContent;
|
|||
use crate::session_history::{
|
||||
JointSessionHistory, NeedsToReload, SessionHistoryChange, SessionHistoryDiff,
|
||||
};
|
||||
use crate::timer_scheduler::TimerScheduler;
|
||||
use crate::webview::WebViewManager;
|
||||
|
||||
type PendingApprovalNavigations = HashMap<PipelineId, (LoadData, NavigationHistoryBehavior)>;
|
||||
|
@ -381,15 +380,6 @@ pub struct Constellation<STF, SWF> {
|
|||
/// memory profiler thread.
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
|
||||
/// A channel for a pipeline to schedule timer events.
|
||||
scheduler_ipc_sender: IpcSender<TimerSchedulerMsg>,
|
||||
|
||||
/// The receiver to which the IPC requests from scheduler_chan will be forwarded.
|
||||
scheduler_receiver: Receiver<Result<TimerSchedulerMsg, IpcError>>,
|
||||
|
||||
/// The logic and data behing scheduling timer events.
|
||||
timer_scheduler: TimerScheduler,
|
||||
|
||||
/// A single WebRender document the constellation operates on.
|
||||
webrender_document: DocumentId,
|
||||
|
||||
|
@ -660,13 +650,6 @@ where
|
|||
namespace_ipc_receiver,
|
||||
);
|
||||
|
||||
let (scheduler_ipc_sender, scheduler_ipc_receiver) =
|
||||
ipc::channel().expect("ipc channel failure");
|
||||
let scheduler_receiver =
|
||||
route_ipc_receiver_to_new_crossbeam_receiver_preserving_errors(
|
||||
scheduler_ipc_receiver,
|
||||
);
|
||||
|
||||
let (background_hang_monitor_ipc_sender, background_hang_monitor_ipc_receiver) =
|
||||
ipc::channel().expect("ipc channel failure");
|
||||
let background_hang_monitor_receiver =
|
||||
|
@ -762,9 +745,6 @@ where
|
|||
window_size: initial_window_size,
|
||||
phantom: PhantomData,
|
||||
webdriver: WebDriverData::new(),
|
||||
timer_scheduler: TimerScheduler::new(),
|
||||
scheduler_ipc_sender,
|
||||
scheduler_receiver,
|
||||
document_states: HashMap::new(),
|
||||
webrender_document: state.webrender_document,
|
||||
#[cfg(feature = "webgpu")]
|
||||
|
@ -1015,7 +995,6 @@ where
|
|||
.clone(),
|
||||
layout_to_constellation_chan: self.layout_sender.clone(),
|
||||
layout_factory: self.layout_factory.clone(),
|
||||
scheduler_chan: self.scheduler_ipc_sender.clone(),
|
||||
compositor_proxy: self.compositor_proxy.clone(),
|
||||
devtools_sender: self.devtools_sender.clone(),
|
||||
bluetooth_thread: self.bluetooth_ipc_sender.clone(),
|
||||
|
@ -1187,16 +1166,7 @@ where
|
|||
Layout(FromLayoutMsg),
|
||||
NetworkListener((PipelineId, FetchResponseMsg)),
|
||||
FromSWManager(SWManagerMsg),
|
||||
Timer(TimerSchedulerMsg),
|
||||
}
|
||||
|
||||
// A timeout corresponding to the earliest scheduled timer event, if any.
|
||||
let scheduler_timeout = self
|
||||
.timer_scheduler
|
||||
.check_timers()
|
||||
.map(after)
|
||||
.unwrap_or(never());
|
||||
|
||||
// Get one incoming request.
|
||||
// This is one of the few places where the compositor is
|
||||
// allowed to panic. If one of the receiver.recv() calls
|
||||
|
@ -1236,14 +1206,6 @@ where
|
|||
recv(self.swmanager_receiver) -> msg => {
|
||||
msg.expect("Unexpected SW channel panic in constellation").map(Request::FromSWManager)
|
||||
}
|
||||
recv(self.scheduler_receiver) -> msg => {
|
||||
msg.expect("Unexpected schedule channel panic in constellation").map(Request::Timer)
|
||||
}
|
||||
recv(scheduler_timeout) -> _ => {
|
||||
// Note: by returning, we go back to the top,
|
||||
// where check_timers will be called.
|
||||
return;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1272,9 +1234,6 @@ where
|
|||
Request::FromSWManager(message) => {
|
||||
self.handle_request_from_swmanager(message);
|
||||
},
|
||||
Request::Timer(message) => {
|
||||
self.timer_scheduler.handle_timer_request(message);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue