diff --git a/components/background_hang_monitor/Cargo.toml b/components/background_hang_monitor/Cargo.toml index 9e7726e3928..e9263b29fb2 100644 --- a/components/background_hang_monitor/Cargo.toml +++ b/components/background_hang_monitor/Cargo.toml @@ -23,9 +23,12 @@ libc = { workspace = true } log = { workspace = true } serde_json = { workspace = true } +[features] +sampler = ["unwind-sys", "mach2"] + [target.'cfg(target_os = "macos")'.dependencies] -mach2 = "0.4" +mach2 = { version = "0.4", optional = true } [target.'cfg(all(target_os = "linux", not(any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos", target_env = "musl"))))'.dependencies] nix = { workspace = true, features = ["signal"] } -unwind-sys = "0.1.4" +unwind-sys = { version = "0.1.4", optional = true } diff --git a/components/background_hang_monitor/background_hang_monitor.rs b/components/background_hang_monitor/background_hang_monitor.rs index 9a034e6e0b9..0889cba8b63 100644 --- a/components/background_hang_monitor/background_hang_monitor.rs +++ b/components/background_hang_monitor/background_hang_monitor.rs @@ -90,13 +90,15 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister { ); #[cfg(all( + feature = "sampler", target_os = "windows", any(target_arch = "x86_64", target_arch = "x86") ))] let sampler = crate::sampler_windows::WindowsSampler::new_boxed(); - #[cfg(target_os = "macos")] + #[cfg(all(feature = "sampler", target_os = "macos"))] let sampler = crate::sampler_mac::MacOsSampler::new_boxed(); #[cfg(all( + feature = "sampler", target_os = "linux", not(any( target_arch = "arm", @@ -107,6 +109,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister { ))] let sampler = crate::sampler_linux::LinuxSampler::new_boxed(); #[cfg(any( + not(feature = "sampler"), target_os = "android", all( target_os = "linux", @@ -116,7 +119,7 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister { target_env = "ohos", target_env = "musl" ) - ) + ), ))] let sampler = crate::sampler::DummySampler::new_boxed(); diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 1f165ee0bb2..d0634b45cf3 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -15,6 +15,7 @@ crate-type = ["rlib"] [features] crown = ["script/crown"] debugmozjs = ["script/debugmozjs"] +background_hang_monitor = ["background_hang_monitor/sampler"] jitspew = ["script/jitspew"] js_backtrace = ["script/js_backtrace"] layout_2013 = ["dep:layout_thread_2013"] diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index b13c251ce89..a97f04f5ba5 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -59,7 +59,7 @@ webgpu = ["libservo/webgpu"] [dependencies] euclid = { workspace = true } libc = { workspace = true } -libservo = { path = "../../components/servo" } +libservo = { path = "../../components/servo", features = ["background_hang_monitor"] } cfg-if = { workspace = true } keyboard-types = { workspace = true } log = { workspace = true }