mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Make Background Hang Monitor Optional
This is done by wrapping all channels of communication and related objects inside Option which are configured using flag inside servo_config.
This commit is contained in:
parent
ada95b9878
commit
a05553f188
9 changed files with 126 additions and 74 deletions
|
@ -136,6 +136,9 @@ pub struct Opts {
|
||||||
/// Whether we're running in multiprocess mode.
|
/// Whether we're running in multiprocess mode.
|
||||||
pub multiprocess: bool,
|
pub multiprocess: bool,
|
||||||
|
|
||||||
|
/// Whether we want background hang monitor enabled or not
|
||||||
|
pub background_hang_monitor: bool,
|
||||||
|
|
||||||
/// Whether we're running inside the sandbox.
|
/// Whether we're running inside the sandbox.
|
||||||
pub sandbox: bool,
|
pub sandbox: bool,
|
||||||
|
|
||||||
|
@ -545,6 +548,7 @@ pub fn default_opts() -> Opts {
|
||||||
initial_window_size: Size2D::new(1024, 740),
|
initial_window_size: Size2D::new(1024, 740),
|
||||||
user_agent: default_user_agent_string(DEFAULT_USER_AGENT).into(),
|
user_agent: default_user_agent_string(DEFAULT_USER_AGENT).into(),
|
||||||
multiprocess: false,
|
multiprocess: false,
|
||||||
|
background_hang_monitor: false,
|
||||||
random_pipeline_closure_probability: None,
|
random_pipeline_closure_probability: None,
|
||||||
random_pipeline_closure_seed: None,
|
random_pipeline_closure_seed: None,
|
||||||
sandbox: false,
|
sandbox: false,
|
||||||
|
@ -669,6 +673,7 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR
|
||||||
"NCSA Mosaic/1.0 (X11;SunOS 4.1.4 sun4m)",
|
"NCSA Mosaic/1.0 (X11;SunOS 4.1.4 sun4m)",
|
||||||
);
|
);
|
||||||
opts.optflag("M", "multiprocess", "Run in multiprocess mode");
|
opts.optflag("M", "multiprocess", "Run in multiprocess mode");
|
||||||
|
opts.optflag("B", "bhm", "Background Hang Monitor enabled");
|
||||||
opts.optflag("S", "sandbox", "Run in a sandbox if multiprocess");
|
opts.optflag("S", "sandbox", "Run in a sandbox if multiprocess");
|
||||||
opts.optopt(
|
opts.optopt(
|
||||||
"",
|
"",
|
||||||
|
@ -965,6 +970,7 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR
|
||||||
initial_window_size: initial_window_size,
|
initial_window_size: initial_window_size,
|
||||||
user_agent: user_agent,
|
user_agent: user_agent,
|
||||||
multiprocess: opt_match.opt_present("M"),
|
multiprocess: opt_match.opt_present("M"),
|
||||||
|
background_hang_monitor: opt_match.opt_present("B"),
|
||||||
sandbox: opt_match.opt_present("S"),
|
sandbox: opt_match.opt_present("S"),
|
||||||
random_pipeline_closure_probability: random_pipeline_closure_probability,
|
random_pipeline_closure_probability: random_pipeline_closure_probability,
|
||||||
random_pipeline_closure_seed: random_pipeline_closure_seed,
|
random_pipeline_closure_seed: random_pipeline_closure_seed,
|
||||||
|
|
|
@ -282,11 +282,11 @@ pub struct Constellation<Message, LTF, STF> {
|
||||||
|
|
||||||
/// A channel for the background hang monitor to send messages
|
/// A channel for the background hang monitor to send messages
|
||||||
/// to the constellation.
|
/// to the constellation.
|
||||||
background_hang_monitor_sender: IpcSender<HangMonitorAlert>,
|
background_hang_monitor_sender: Option<IpcSender<HangMonitorAlert>>,
|
||||||
|
|
||||||
/// A channel for the constellation to receiver messages
|
/// A channel for the constellation to receiver messages
|
||||||
/// from the background hang monitor.
|
/// from the background hang monitor.
|
||||||
background_hang_monitor_receiver: Receiver<Result<HangMonitorAlert, IpcError>>,
|
background_hang_monitor_receiver: Option<Receiver<Result<HangMonitorAlert, IpcError>>>,
|
||||||
|
|
||||||
/// An IPC channel for layout threads to send messages to the constellation.
|
/// An IPC channel for layout threads to send messages to the constellation.
|
||||||
/// This is the layout threads' view of `layout_receiver`.
|
/// This is the layout threads' view of `layout_receiver`.
|
||||||
|
@ -849,28 +849,42 @@ where
|
||||||
ipc_scheduler_receiver,
|
ipc_scheduler_receiver,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (background_hang_monitor_sender, ipc_bhm_receiver) =
|
let (background_hang_monitor_sender, background_hang_monitor_receiver) =
|
||||||
ipc::channel().expect("ipc channel failure");
|
if opts::get().background_hang_monitor {
|
||||||
let background_hang_monitor_receiver =
|
let (bhm_sender, ipc_bhm_receiver) =
|
||||||
route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(ipc_bhm_receiver);
|
ipc::channel().expect("ipc channel failure");
|
||||||
|
(
|
||||||
|
Some(bhm_sender),
|
||||||
|
Some(route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(
|
||||||
|
ipc_bhm_receiver,
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(None, None)
|
||||||
|
};
|
||||||
|
|
||||||
// If we are in multiprocess mode,
|
// If we are in multiprocess mode,
|
||||||
// a dedicated per-process hang monitor will be initialized later inside the content process.
|
// a dedicated per-process hang monitor will be initialized later inside the content process.
|
||||||
// See run_content_process in servo/lib.rs
|
// See run_content_process in servo/lib.rs
|
||||||
let (background_monitor_register, sampler_chan) = if opts::multiprocess() {
|
let (background_monitor_register, sampler_chan) =
|
||||||
(None, vec![])
|
if opts::multiprocess() || !opts::get().background_hang_monitor {
|
||||||
} else {
|
(None, vec![])
|
||||||
let (sampling_profiler_control, sampling_profiler_port) =
|
} else {
|
||||||
ipc::channel().expect("ipc channel failure");
|
let (sampling_profiler_control, sampling_profiler_port) =
|
||||||
|
ipc::channel().expect("ipc channel failure");
|
||||||
(
|
if let Some(bhm_sender) = background_hang_monitor_sender.clone() {
|
||||||
Some(HangMonitorRegister::init(
|
(
|
||||||
background_hang_monitor_sender.clone(),
|
Some(HangMonitorRegister::init(
|
||||||
sampling_profiler_port,
|
bhm_sender,
|
||||||
)),
|
sampling_profiler_port,
|
||||||
vec![sampling_profiler_control],
|
)),
|
||||||
)
|
vec![sampling_profiler_control],
|
||||||
};
|
)
|
||||||
|
} else {
|
||||||
|
warn!("No BHM sender found in BHM mode.");
|
||||||
|
(None, vec![])
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let (ipc_layout_sender, ipc_layout_receiver) =
|
let (ipc_layout_sender, ipc_layout_receiver) =
|
||||||
ipc::channel().expect("ipc channel failure");
|
ipc::channel().expect("ipc channel failure");
|
||||||
|
@ -1413,7 +1427,7 @@ where
|
||||||
recv(self.script_receiver) -> msg => {
|
recv(self.script_receiver) -> msg => {
|
||||||
msg.expect("Unexpected script channel panic in constellation").map(Request::Script)
|
msg.expect("Unexpected script channel panic in constellation").map(Request::Script)
|
||||||
}
|
}
|
||||||
recv(self.background_hang_monitor_receiver) -> msg => {
|
recv(self.background_hang_monitor_receiver.as_ref().unwrap_or(&never())) -> msg => {
|
||||||
msg.expect("Unexpected BHM channel panic in constellation").map(Request::BackgroundHangMonitor)
|
msg.expect("Unexpected BHM channel panic in constellation").map(Request::BackgroundHangMonitor)
|
||||||
}
|
}
|
||||||
recv(self.compositor_receiver) -> msg => {
|
recv(self.compositor_receiver) -> msg => {
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub struct InitialPipelineState {
|
||||||
pub background_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
pub background_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
|
|
||||||
/// A channel for the background hang monitor to send messages to the constellation.
|
/// A channel for the background hang monitor to send messages to the constellation.
|
||||||
pub background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>,
|
pub background_hang_monitor_to_constellation_chan: Option<IpcSender<HangMonitorAlert>>,
|
||||||
|
|
||||||
/// A channel for the layout thread to send messages to the constellation.
|
/// A channel for the layout thread to send messages to the constellation.
|
||||||
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
||||||
|
@ -319,15 +319,24 @@ impl Pipeline {
|
||||||
Some(sampler_chan)
|
Some(sampler_chan)
|
||||||
} else {
|
} else {
|
||||||
// Should not be None in single-process mode.
|
// Should not be None in single-process mode.
|
||||||
let register = state
|
if opts::get().background_hang_monitor {
|
||||||
.background_monitor_register
|
let register = state.background_monitor_register.expect(
|
||||||
.expect("Couldn't start content, no background monitor has been initiated");
|
"Couldn't start content, no background monitor has been initiated",
|
||||||
unprivileged_pipeline_content.start_all::<Message, LTF, STF>(
|
);
|
||||||
false,
|
unprivileged_pipeline_content.start_all::<Message, LTF, STF>(
|
||||||
register,
|
false,
|
||||||
state.event_loop_waker,
|
Some(register),
|
||||||
);
|
state.event_loop_waker,
|
||||||
None
|
);
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
unprivileged_pipeline_content.start_all::<Message, LTF, STF>(
|
||||||
|
false,
|
||||||
|
None,
|
||||||
|
state.event_loop_waker,
|
||||||
|
);
|
||||||
|
None
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(EventLoop::new(script_chan), sampler_chan)
|
(EventLoop::new(script_chan), sampler_chan)
|
||||||
|
@ -488,7 +497,7 @@ pub struct UnprivilegedPipelineContent {
|
||||||
opener: Option<BrowsingContextId>,
|
opener: Option<BrowsingContextId>,
|
||||||
namespace_request_sender: IpcSender<PipelineNamespaceRequest>,
|
namespace_request_sender: IpcSender<PipelineNamespaceRequest>,
|
||||||
script_to_constellation_chan: ScriptToConstellationChan,
|
script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
background_hang_monitor_to_constellation_chan: IpcSender<HangMonitorAlert>,
|
background_hang_monitor_to_constellation_chan: Option<IpcSender<HangMonitorAlert>>,
|
||||||
sampling_profiler_port: Option<IpcReceiver<SamplerControlMsg>>,
|
sampling_profiler_port: Option<IpcReceiver<SamplerControlMsg>>,
|
||||||
layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
||||||
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||||
|
@ -520,7 +529,7 @@ impl UnprivilegedPipelineContent {
|
||||||
pub fn start_all<Message, LTF, STF>(
|
pub fn start_all<Message, LTF, STF>(
|
||||||
self,
|
self,
|
||||||
wait_for_completion: bool,
|
wait_for_completion: bool,
|
||||||
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
event_loop_waker: Option<Box<dyn EventLoopWaker>>,
|
event_loop_waker: Option<Box<dyn EventLoopWaker>>,
|
||||||
) where
|
) where
|
||||||
LTF: LayoutThreadFactory<Message = Message>,
|
LTF: LayoutThreadFactory<Message = Message>,
|
||||||
|
@ -730,13 +739,17 @@ impl UnprivilegedPipelineContent {
|
||||||
|
|
||||||
pub fn register_with_background_hang_monitor(
|
pub fn register_with_background_hang_monitor(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> Box<dyn BackgroundHangMonitorRegister> {
|
) -> Option<Box<dyn BackgroundHangMonitorRegister>> {
|
||||||
HangMonitorRegister::init(
|
self.background_hang_monitor_to_constellation_chan
|
||||||
self.background_hang_monitor_to_constellation_chan.clone(),
|
.clone()
|
||||||
self.sampling_profiler_port
|
.map(|bhm| {
|
||||||
.take()
|
HangMonitorRegister::init(
|
||||||
.expect("no sampling profiler?"),
|
bhm.clone(),
|
||||||
)
|
self.sampling_profiler_port
|
||||||
|
.take()
|
||||||
|
.expect("no sampling profiler?"),
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan {
|
pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan {
|
||||||
|
|
|
@ -159,7 +159,7 @@ pub struct LayoutThread {
|
||||||
font_cache_sender: IpcSender<()>,
|
font_cache_sender: IpcSender<()>,
|
||||||
|
|
||||||
/// A means of communication with the background hang monitor.
|
/// A means of communication with the background hang monitor.
|
||||||
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
|
background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the constellation.
|
/// The channel on which messages can be sent to the constellation.
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
|
@ -292,7 +292,7 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
chan: (Sender<Msg>, Receiver<Msg>),
|
chan: (Sender<Msg>, Receiver<Msg>),
|
||||||
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||||
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
|
@ -326,12 +326,13 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
// Ensures layout thread is destroyed before we send shutdown message
|
// Ensures layout thread is destroyed before we send shutdown message
|
||||||
let sender = chan.0;
|
let sender = chan.0;
|
||||||
|
|
||||||
let background_hang_monitor = background_hang_monitor_register
|
let background_hang_monitor = background_hang_monitor_register.map(|bhm| {
|
||||||
.register_component(
|
bhm.register_component(
|
||||||
MonitoredComponentId(id, MonitoredComponentType::Layout),
|
MonitoredComponentId(id, MonitoredComponentType::Layout),
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
Duration::from_millis(5000),
|
Duration::from_millis(5000),
|
||||||
);
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let layout = LayoutThread::new(
|
let layout = LayoutThread::new(
|
||||||
id,
|
id,
|
||||||
|
@ -510,7 +511,7 @@ impl LayoutThread {
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||||
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
|
background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
|
@ -708,7 +709,8 @@ impl LayoutThread {
|
||||||
Msg::GetRunningAnimations(..) => LayoutHangAnnotation::GetRunningAnimations,
|
Msg::GetRunningAnimations(..) => LayoutHangAnnotation::GetRunningAnimations,
|
||||||
};
|
};
|
||||||
self.background_hang_monitor
|
self.background_hang_monitor
|
||||||
.notify_activity(HangAnnotation::Layout(hang_annotation));
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.notify_activity(HangAnnotation::Layout(hang_annotation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receives and dispatches messages from the script and constellation threads
|
/// Receives and dispatches messages from the script and constellation threads
|
||||||
|
@ -720,7 +722,9 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify the background-hang-monitor we are waiting for an event.
|
// Notify the background-hang-monitor we are waiting for an event.
|
||||||
self.background_hang_monitor.notify_wait();
|
self.background_hang_monitor
|
||||||
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.notify_wait());
|
||||||
|
|
||||||
let request = select! {
|
let request = select! {
|
||||||
recv(self.pipeline_port) -> msg => Request::FromPipeline(msg.unwrap()),
|
recv(self.pipeline_port) -> msg => Request::FromPipeline(msg.unwrap()),
|
||||||
|
@ -995,7 +999,9 @@ impl LayoutThread {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.root_flow.borrow_mut().take();
|
self.root_flow.borrow_mut().take();
|
||||||
self.background_hang_monitor.unregister();
|
self.background_hang_monitor
|
||||||
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.unregister());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_add_stylesheet(&self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard) {
|
fn handle_add_stylesheet(&self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ pub struct LayoutThread {
|
||||||
font_cache_sender: IpcSender<()>,
|
font_cache_sender: IpcSender<()>,
|
||||||
|
|
||||||
/// A means of communication with the background hang monitor.
|
/// A means of communication with the background hang monitor.
|
||||||
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
|
background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
|
||||||
|
|
||||||
/// The channel on which messages can be sent to the script thread.
|
/// The channel on which messages can be sent to the script thread.
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
|
@ -247,7 +247,7 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
chan: (Sender<Msg>, Receiver<Msg>),
|
chan: (Sender<Msg>, Receiver<Msg>),
|
||||||
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||||
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
|
@ -281,12 +281,13 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
// Ensures layout thread is destroyed before we send shutdown message
|
// Ensures layout thread is destroyed before we send shutdown message
|
||||||
let sender = chan.0;
|
let sender = chan.0;
|
||||||
|
|
||||||
let background_hang_monitor = background_hang_monitor_register
|
let background_hang_monitor = background_hang_monitor_register.map(|bhm| {
|
||||||
.register_component(
|
bhm.register_component(
|
||||||
MonitoredComponentId(id, MonitoredComponentType::Layout),
|
MonitoredComponentId(id, MonitoredComponentType::Layout),
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
Duration::from_millis(5000),
|
Duration::from_millis(5000),
|
||||||
);
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let layout = LayoutThread::new(
|
let layout = LayoutThread::new(
|
||||||
id,
|
id,
|
||||||
|
@ -463,7 +464,7 @@ impl LayoutThread {
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
port: Receiver<Msg>,
|
port: Receiver<Msg>,
|
||||||
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||||
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
|
background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
|
@ -648,7 +649,8 @@ impl LayoutThread {
|
||||||
Msg::GetRunningAnimations(..) => LayoutHangAnnotation::GetRunningAnimations,
|
Msg::GetRunningAnimations(..) => LayoutHangAnnotation::GetRunningAnimations,
|
||||||
};
|
};
|
||||||
self.background_hang_monitor
|
self.background_hang_monitor
|
||||||
.notify_activity(HangAnnotation::Layout(hang_annotation));
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.notify_activity(HangAnnotation::Layout(hang_annotation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receives and dispatches messages from the script and constellation threads
|
/// Receives and dispatches messages from the script and constellation threads
|
||||||
|
@ -660,7 +662,9 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify the background-hang-monitor we are waiting for an event.
|
// Notify the background-hang-monitor we are waiting for an event.
|
||||||
self.background_hang_monitor.notify_wait();
|
self.background_hang_monitor
|
||||||
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.notify_wait());
|
||||||
|
|
||||||
let request = select! {
|
let request = select! {
|
||||||
recv(self.pipeline_port) -> msg => Request::FromPipeline(msg.unwrap()),
|
recv(self.pipeline_port) -> msg => Request::FromPipeline(msg.unwrap()),
|
||||||
|
@ -895,7 +899,9 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exit_now(&mut self) {
|
fn exit_now(&mut self) {
|
||||||
self.background_hang_monitor.unregister();
|
self.background_hang_monitor
|
||||||
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.unregister());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_add_stylesheet(&self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard) {
|
fn handle_add_stylesheet(&self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub trait LayoutThreadFactory {
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
chan: (Sender<Self::Message>, Receiver<Self::Message>),
|
chan: (Sender<Self::Message>, Receiver<Self::Message>),
|
||||||
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||||
background_hang_monitor: Box<dyn BackgroundHangMonitorRegister>,
|
background_hang_monitor: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
script_chan: IpcSender<ConstellationControlMsg>,
|
script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
|
|
|
@ -545,9 +545,9 @@ pub struct ScriptThread {
|
||||||
task_queue: TaskQueue<MainThreadScriptMsg>,
|
task_queue: TaskQueue<MainThreadScriptMsg>,
|
||||||
|
|
||||||
/// A handle to register associated layout threads for hang-monitoring.
|
/// A handle to register associated layout threads for hang-monitoring.
|
||||||
background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
/// The dedicated means of communication with the background-hang-monitor for this script-thread.
|
/// The dedicated means of communication with the background-hang-monitor for this script-thread.
|
||||||
background_hang_monitor: Box<dyn BackgroundHangMonitor>,
|
background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
|
||||||
|
|
||||||
/// A channel to hand out to script thread-based entities that need to be able to enqueue
|
/// A channel to hand out to script thread-based entities that need to be able to enqueue
|
||||||
/// events in the event queue.
|
/// events in the event queue.
|
||||||
|
@ -1262,18 +1262,20 @@ impl ScriptThread {
|
||||||
let devtools_port =
|
let devtools_port =
|
||||||
ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(ipc_devtools_receiver);
|
ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(ipc_devtools_receiver);
|
||||||
|
|
||||||
// Ask the router to proxy IPC messages from the control port to us.
|
|
||||||
let control_port = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(state.control_port);
|
|
||||||
|
|
||||||
let (image_cache_channel, image_cache_port) = unbounded();
|
let (image_cache_channel, image_cache_port) = unbounded();
|
||||||
|
|
||||||
let task_queue = TaskQueue::new(port, chan.clone());
|
let task_queue = TaskQueue::new(port, chan.clone());
|
||||||
|
|
||||||
let background_hang_monitor = state.background_hang_monitor_register.register_component(
|
let background_hang_monitor = state.background_hang_monitor_register.clone().map(|bhm| {
|
||||||
MonitoredComponentId(state.id, MonitoredComponentType::Script),
|
bhm.register_component(
|
||||||
Duration::from_millis(1000),
|
MonitoredComponentId(state.id.clone(), MonitoredComponentType::Script),
|
||||||
Duration::from_millis(5000),
|
Duration::from_millis(1000),
|
||||||
);
|
Duration::from_millis(5000),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ask the router to proxy IPC messages from the control port to us.
|
||||||
|
let control_port = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(state.control_port);
|
||||||
|
|
||||||
ScriptThread {
|
ScriptThread {
|
||||||
documents: DomRefCell::new(Documents::new()),
|
documents: DomRefCell::new(Documents::new()),
|
||||||
|
@ -1408,7 +1410,9 @@ impl ScriptThread {
|
||||||
let mut sequential = vec![];
|
let mut sequential = vec![];
|
||||||
|
|
||||||
// Notify the background-hang-monitor we are waiting for an event.
|
// Notify the background-hang-monitor we are waiting for an event.
|
||||||
self.background_hang_monitor.notify_wait();
|
self.background_hang_monitor
|
||||||
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.notify_wait());
|
||||||
|
|
||||||
// Receive at least one message so we don't spinloop.
|
// Receive at least one message so we don't spinloop.
|
||||||
debug!("Waiting for event.");
|
debug!("Waiting for event.");
|
||||||
|
@ -1662,7 +1666,8 @@ impl ScriptThread {
|
||||||
ScriptThreadEventCategory::PortMessage => ScriptHangAnnotation::PortMessage,
|
ScriptThreadEventCategory::PortMessage => ScriptHangAnnotation::PortMessage,
|
||||||
};
|
};
|
||||||
self.background_hang_monitor
|
self.background_hang_monitor
|
||||||
.notify_activity(HangAnnotation::Script(hang_annotation));
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.notify_activity(HangAnnotation::Script(hang_annotation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn message_to_pipeline(&self, msg: &MixedMessage) -> Option<PipelineId> {
|
fn message_to_pipeline(&self, msg: &MixedMessage) -> Option<PipelineId> {
|
||||||
|
@ -2882,7 +2887,9 @@ impl ScriptThread {
|
||||||
self.handle_exit_pipeline_msg(pipeline_id, DiscardBrowsingContext::Yes);
|
self.handle_exit_pipeline_msg(pipeline_id, DiscardBrowsingContext::Yes);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.background_hang_monitor.unregister();
|
self.background_hang_monitor
|
||||||
|
.as_ref()
|
||||||
|
.map(|bhm| bhm.unregister());
|
||||||
|
|
||||||
debug!("Exited script thread.");
|
debug!("Exited script thread.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ pub struct LayoutThreadInit {
|
||||||
pub is_parent: bool,
|
pub is_parent: bool,
|
||||||
pub layout_pair: (Sender<Msg>, Receiver<Msg>),
|
pub layout_pair: (Sender<Msg>, Receiver<Msg>),
|
||||||
pub pipeline_port: IpcReceiver<LayoutControlMsg>,
|
pub pipeline_port: IpcReceiver<LayoutControlMsg>,
|
||||||
pub background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
pub background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
pub constellation_chan: IpcSender<ConstellationMsg>,
|
pub constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
pub script_chan: IpcSender<ConstellationControlMsg>,
|
pub script_chan: IpcSender<ConstellationControlMsg>,
|
||||||
pub image_cache: Arc<dyn ImageCache>,
|
pub image_cache: Arc<dyn ImageCache>,
|
||||||
|
|
|
@ -644,7 +644,7 @@ pub struct InitialScriptState {
|
||||||
/// A channel on which messages can be sent to the constellation from script.
|
/// A channel on which messages can be sent to the constellation from script.
|
||||||
pub script_to_constellation_chan: ScriptToConstellationChan,
|
pub script_to_constellation_chan: ScriptToConstellationChan,
|
||||||
/// A handle to register script-(and associated layout-)threads for hang monitoring.
|
/// A handle to register script-(and associated layout-)threads for hang monitoring.
|
||||||
pub background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
|
pub background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
|
||||||
/// A sender for the layout thread to communicate to the constellation.
|
/// A sender for the layout thread to communicate to the constellation.
|
||||||
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
||||||
/// A channel to schedule timer events.
|
/// A channel to schedule timer events.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue