mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Make tracing available on all platforms, with or without perfetto (#33301)
* Make tracing available on all platforms Signed-off-by: Delan Azabani <dazabani@igalia.com> * Gate perfetto support behind its own feature Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
891562be8e
commit
c0ced7a524
8 changed files with 33 additions and 79 deletions
32
Cargo.lock
generated
32
Cargo.lock
generated
|
@ -4156,15 +4156,6 @@ dependencies = [
|
||||||
"tendril",
|
"tendril",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "matchers"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
|
||||||
dependencies = [
|
|
||||||
"regex-automata 0.1.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matches"
|
name = "matches"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
|
@ -5510,16 +5501,7 @@ dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-automata 0.4.7",
|
"regex-automata 0.4.7",
|
||||||
"regex-syntax 0.8.4",
|
"regex-syntax",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-automata"
|
|
||||||
version = "0.1.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
|
||||||
dependencies = [
|
|
||||||
"regex-syntax 0.6.29",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5539,15 +5521,9 @@ checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-syntax 0.8.4",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-syntax"
|
|
||||||
version = "0.6.29"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
@ -7303,14 +7279,10 @@ version = "0.3.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"matchers",
|
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
"once_cell",
|
|
||||||
"regex",
|
|
||||||
"sharded-slab",
|
"sharded-slab",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
"tracing",
|
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
]
|
]
|
||||||
|
|
|
@ -48,7 +48,8 @@ multiview = ["libservo/multiview"]
|
||||||
native-bluetooth = ["libservo/native-bluetooth"]
|
native-bluetooth = ["libservo/native-bluetooth"]
|
||||||
profilemozjs = ["libservo/profilemozjs"]
|
profilemozjs = ["libservo/profilemozjs"]
|
||||||
refcell_backtrace = ["libservo/refcell_backtrace"]
|
refcell_backtrace = ["libservo/refcell_backtrace"]
|
||||||
tracing = ["dep:tracing", "dep:tracing-subscriber", "dep:tracing-perfetto"]
|
tracing = ["dep:tracing", "dep:tracing-subscriber"]
|
||||||
|
tracing-perfetto = ["tracing", "dep:tracing-perfetto"]
|
||||||
webdriver = ["libservo/webdriver"]
|
webdriver = ["libservo/webdriver"]
|
||||||
webgl_backtrace = ["libservo/webgl_backtrace"]
|
webgl_backtrace = ["libservo/webgl_backtrace"]
|
||||||
|
|
||||||
|
@ -62,6 +63,9 @@ mime_guess = { workspace = true }
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
servo-media = { workspace = true }
|
servo-media = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
tracing = { workspace = true, optional = true }
|
||||||
|
tracing-subscriber = { workspace = true, optional = true }
|
||||||
|
tracing-perfetto = { workspace = true, optional = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "android")'.dependencies]
|
[target.'cfg(target_os = "android")'.dependencies]
|
||||||
android_logger = "0.14"
|
android_logger = "0.14"
|
||||||
|
@ -111,9 +115,6 @@ raw-window-handle = "0.6"
|
||||||
shellwords = "1.0.0"
|
shellwords = "1.0.0"
|
||||||
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
|
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
|
||||||
tinyfiledialogs = "3.0"
|
tinyfiledialogs = "3.0"
|
||||||
tracing = { workspace = true, optional = true }
|
|
||||||
tracing-subscriber = { workspace = true, features = ["env-filter"], optional = true }
|
|
||||||
tracing-perfetto = { workspace = true, optional = true }
|
|
||||||
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] }
|
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] }
|
||||||
winit = "0.29.10"
|
winit = "0.29.10"
|
||||||
|
|
||||||
|
|
|
@ -8,42 +8,13 @@ use getopts::Options;
|
||||||
use log::error;
|
use log::error;
|
||||||
use servo::config::opts::{self, ArgumentParsingResult};
|
use servo::config::opts::{self, ArgumentParsingResult};
|
||||||
use servo::servo_config::pref;
|
use servo::servo_config::pref;
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
use tracing::subscriber::set_global_default;
|
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
use tracing_perfetto::PerfettoLayer;
|
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
use tracing_subscriber::EnvFilter;
|
|
||||||
|
|
||||||
use crate::desktop::app::App;
|
use crate::desktop::app::App;
|
||||||
use crate::panic_hook;
|
use crate::panic_hook;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
crate::crash_handler::install();
|
crate::crash_handler::install();
|
||||||
|
crate::init_tracing();
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
{
|
|
||||||
let file = std::fs::File::create("servo.pftrace").unwrap();
|
|
||||||
let perfetto_layer = PerfettoLayer::new(std::sync::Mutex::new(file));
|
|
||||||
|
|
||||||
// Set up a custom tracing subscriber and PerfettoLayer for performance tracing.
|
|
||||||
// The servo.pftrace file can be uploaded to https://ui.perfetto.dev for analysis.
|
|
||||||
let env_filter_layer = EnvFilter::from_default_env();
|
|
||||||
let subscriber = tracing_subscriber::registry()
|
|
||||||
.with(env_filter_layer)
|
|
||||||
.with(perfetto_layer);
|
|
||||||
|
|
||||||
// Set the subscriber as the global default for tracing. This means it will be used
|
|
||||||
// throughout the entire program unless a thread-local subscriber is set.
|
|
||||||
// Can only be set once; subsequent attempts will fail.
|
|
||||||
// <https://docs.rs/tracing/0.1.40/src/tracing/subscriber.rs.html#30>
|
|
||||||
set_global_default(subscriber).expect("Failed to set global default subscriber");
|
|
||||||
}
|
|
||||||
|
|
||||||
crate::resources::init();
|
crate::resources::init();
|
||||||
|
|
||||||
// Parse the command line options and store them globally
|
// Parse the command line options and store them globally
|
||||||
|
|
|
@ -107,6 +107,7 @@ pub fn init(
|
||||||
waker: Box<dyn EventLoopWaker>,
|
waker: Box<dyn EventLoopWaker>,
|
||||||
callbacks: Box<dyn HostTrait>,
|
callbacks: Box<dyn HostTrait>,
|
||||||
) -> Result<(), &'static str> {
|
) -> Result<(), &'static str> {
|
||||||
|
crate::init_tracing();
|
||||||
resources::set(Box::new(ResourceReaderInstance::new()));
|
resources::set(Box::new(ResourceReaderInstance::new()));
|
||||||
|
|
||||||
if let Some(prefs) = init_opts.prefs {
|
if let Some(prefs) = init_opts.prefs {
|
||||||
|
|
|
@ -40,6 +40,7 @@ pub fn init(
|
||||||
callbacks: Box<dyn HostTrait>,
|
callbacks: Box<dyn HostTrait>,
|
||||||
) -> Result<ServoGlue, &'static str> {
|
) -> Result<ServoGlue, &'static str> {
|
||||||
info!("Entered simpleservo init function");
|
info!("Entered simpleservo init function");
|
||||||
|
crate::init_tracing();
|
||||||
resources::set(Box::new(ResourceReaderInstance::new()));
|
resources::set(Box::new(ResourceReaderInstance::new()));
|
||||||
|
|
||||||
gl.clear_color(1.0, 1.0, 1.0, 1.0);
|
gl.clear_color(1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
|
@ -39,17 +39,28 @@ pub fn main() {
|
||||||
desktop::cli::main()
|
desktop::cli::main()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
pub fn init_tracing() {
|
||||||
pub fn main() {
|
#[cfg(feature = "tracing")]
|
||||||
println!(
|
{
|
||||||
"Cannot start /ports/servoshell/ on Android. \
|
let subscriber = tracing_subscriber::registry();
|
||||||
Use /support/android/apk/ + `libservoshell.so` instead"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_env = "ohos")]
|
#[cfg(feature = "tracing-perfetto")]
|
||||||
pub fn main() {
|
let subscriber = {
|
||||||
println!("You shouldn't start /ports/servoshell/ on OpenHarmony.");
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
|
// Set up a PerfettoLayer for performance tracing.
|
||||||
|
// The servo.pftrace file can be uploaded to https://ui.perfetto.dev for analysis.
|
||||||
|
let file = std::fs::File::create("servo.pftrace").unwrap();
|
||||||
|
let perfetto_layer = tracing_perfetto::PerfettoLayer::new(std::sync::Mutex::new(file));
|
||||||
|
subscriber.with(perfetto_layer)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Same as SubscriberInitExt::init, but avoids initialising the tracing-log compat layer,
|
||||||
|
// since it would break Servo’s FromScriptLogger and FromCompositorLogger.
|
||||||
|
// <https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/util/trait.SubscriberInitExt.html#method.init>
|
||||||
|
// <https://docs.rs/tracing/0.1.40/tracing/#consuming-log-records>
|
||||||
|
tracing::subscriber::set_global_default(subscriber)
|
||||||
|
.expect("Failed to set tracing subscriber");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn servo_version() -> String {
|
pub fn servo_version() -> String {
|
||||||
|
|
|
@ -25,6 +25,8 @@ fn main() {
|
||||||
if #[cfg(not(any(target_os = "android", target_env = "ohos")))] {
|
if #[cfg(not(any(target_os = "android", target_env = "ohos")))] {
|
||||||
servoshell::main()
|
servoshell::main()
|
||||||
} else {
|
} else {
|
||||||
|
// Android: see ports/servoshell/egl/android/simpleservo.rs.
|
||||||
|
// OpenHarmony: see ports/servoshell/egl/ohos/simpleservo.rs.
|
||||||
println!(
|
println!(
|
||||||
"Cannot run the servoshell `bin` executable on platforms such as \
|
"Cannot run the servoshell `bin` executable on platforms such as \
|
||||||
Android or OpenHarmony. On these platforms you need to compile \
|
Android or OpenHarmony. On these platforms you need to compile \
|
||||||
|
|
|
@ -77,11 +77,6 @@ packages = [
|
||||||
# icu_list -> regex-automata 0.2.0
|
# icu_list -> regex-automata 0.2.0
|
||||||
# tracing-subscriber -> matchers -> regex-automata 0.1.0
|
# tracing-subscriber -> matchers -> regex-automata 0.1.0
|
||||||
"regex-automata",
|
"regex-automata",
|
||||||
|
|
||||||
# tracing-subscriber (tokio-rs/tracing#3033) uses old version
|
|
||||||
# regex [-> regex-automata 0.4.7] -> regex-syntax 0.8.4
|
|
||||||
# tracing-subscriber -> matchers -> regex-automata 0.1.0 -> regex-syntax 0.6.29
|
|
||||||
"regex-syntax",
|
|
||||||
]
|
]
|
||||||
# Files that are ignored for all tidy and lint checks.
|
# Files that are ignored for all tidy and lint checks.
|
||||||
files = [
|
files = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue