Enable LinuxSampler to be used on Android (#37784)

This enables `background_hang_monitor` to work on Android. Relevant
Zulip thread: [#general > Android stack walking questions @
💬](https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Android.20stack.20walking.20questions/near/526369883)


Testing: Manually tested on a Pixel 6a with Android 16 with following
page:
```html
<!DOCTYPE html>
<html>
    <head>
        <title>Infinite Loop Test</title>
    </head>
    <body>
        Will it print? That is the question.
    </body>
    <script>
        console.log("hello. you're about to loop infinitely.");

        while (true) {
            //do nothing, just block the thread
        }
    </script>
</html>
```
Fixes: #23136

---------

Signed-off-by: CarePackage17 <5157010+CarePackage17@users.noreply.github.com>
This commit is contained in:
CarePackage17 2025-06-30 19:17:50 +02:00 committed by GitHub
parent 60c10d710d
commit f682f9d6f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View file

@ -29,5 +29,8 @@ 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] [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"], optional = true } nix = { workspace = true, features = ["signal"], optional = true }
[target.'cfg(target_os = "android")'.dependencies]
nix = { workspace = true, features = ["signal"], optional = true }
[features] [features]
sampler = ["mach2", "nix"] sampler = ["mach2", "nix"]

View file

@ -97,6 +97,8 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
let sampler = crate::sampler_windows::WindowsSampler::new_boxed(); let sampler = crate::sampler_windows::WindowsSampler::new_boxed();
#[cfg(all(feature = "sampler", target_os = "macos"))] #[cfg(all(feature = "sampler", target_os = "macos"))]
let sampler = crate::sampler_mac::MacOsSampler::new_boxed(); let sampler = crate::sampler_mac::MacOsSampler::new_boxed();
#[cfg(all(feature = "sampler", target_os = "android"))]
let sampler = crate::sampler_linux::LinuxSampler::new_boxed();
#[cfg(all( #[cfg(all(
feature = "sampler", feature = "sampler",
target_os = "linux", target_os = "linux",
@ -110,7 +112,6 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
let sampler = crate::sampler_linux::LinuxSampler::new_boxed(); let sampler = crate::sampler_linux::LinuxSampler::new_boxed();
#[cfg(any( #[cfg(any(
not(feature = "sampler"), not(feature = "sampler"),
target_os = "android",
all( all(
target_os = "linux", target_os = "linux",
any( any(

View file

@ -17,6 +17,8 @@ mod sampler;
)) ))
))] ))]
mod sampler_linux; mod sampler_linux;
#[cfg(all(feature = "sampler", target_os = "android"))]
mod sampler_linux;
#[cfg(all(feature = "sampler", target_os = "macos"))] #[cfg(all(feature = "sampler", target_os = "macos"))]
mod sampler_mac; mod sampler_mac;
#[cfg(all(feature = "sampler", target_os = "windows"))] #[cfg(all(feature = "sampler", target_os = "windows"))]