mirror of
https://github.com/servo/servo.git
synced 2025-08-20 21:05:34 +01:00
Add initial support for tracing and tracing-perfetto (#33188)
Signed-off-by: atbrakhi <atbrakhi@igalia.com> Co-authored-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
parent
abe532dd2f
commit
ba7e53264d
6 changed files with 286 additions and 4 deletions
|
@ -48,6 +48,7 @@ multiview = ["libservo/multiview"]
|
|||
native-bluetooth = ["libservo/native-bluetooth"]
|
||||
profilemozjs = ["libservo/profilemozjs"]
|
||||
refcell_backtrace = ["libservo/refcell_backtrace"]
|
||||
tracing = ["dep:tracing", "dep:tracing-subscriber", "dep:tracing-perfetto"]
|
||||
webdriver = ["libservo/webdriver"]
|
||||
webgl_backtrace = ["libservo/webgl_backtrace"]
|
||||
|
||||
|
@ -110,6 +111,9 @@ raw-window-handle = "0.6"
|
|||
shellwords = "1.0.0"
|
||||
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
|
||||
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"] }
|
||||
winit = "0.29.10"
|
||||
|
||||
|
|
|
@ -8,6 +8,16 @@ use getopts::Options;
|
|||
use log::error;
|
||||
use servo::config::opts::{self, ArgumentParsingResult};
|
||||
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::panic_hook;
|
||||
|
@ -15,6 +25,25 @@ use crate::panic_hook;
|
|||
pub fn main() {
|
||||
crate::crash_handler::install();
|
||||
|
||||
#[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();
|
||||
|
||||
// Parse the command line options and store them globally
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue