mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Add tracing-wasm
This commit is contained in:
parent
32fa82145c
commit
8644215dc9
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -1795,6 +1795,7 @@ dependencies = [
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"tracing-tracy",
|
||||
"tracing-wasm",
|
||||
"tracy-client",
|
||||
"vector-tile",
|
||||
"wasm-bindgen",
|
||||
@ -3381,6 +3382,17 @@ dependencies = [
|
||||
"tracy-client",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-wasm"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracy-client"
|
||||
version = "0.12.8"
|
||||
|
||||
@ -31,7 +31,8 @@ debug = true
|
||||
|
||||
[features]
|
||||
web-webgl = ["wgpu/webgl"]
|
||||
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client"]
|
||||
# Enable tracing using tracy on desktop/mobile and the chrome profiler on web
|
||||
enable-tracing = [ "tracing-subscriber", "tracing-tracy", "tracy-client", "tracing-wasm"]
|
||||
default = []
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
@ -46,6 +47,7 @@ js-sys = "0.3"
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
console_log = { version = "0.2", features = ["color"] }
|
||||
tracing-wasm = { version = "0.2", optional = true }
|
||||
# stdweb variant is way faster!
|
||||
instant = { version = "0.1", features = ["stdweb"] } # FIXME: Untrusted dependency
|
||||
|
||||
@ -55,6 +57,8 @@ env_logger = "0.9"
|
||||
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "gzip"] }
|
||||
reqwest-middleware-cache = "0.1" # FIXME: Untrusted dependency
|
||||
reqwest-middleware = { version = "0.1" } # FIXME: Untrusted dependency
|
||||
tracing-tracy = { version = "0.8", optional = true }
|
||||
tracy-client = { git = "https://github.com/nagisa/rust_tracy_client.git", branch = "create-pull-request/patch", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
ndk-glue = "0.5.0" # version is required by winit
|
||||
@ -70,8 +74,6 @@ winit = { version = "0.26", default-features = false }
|
||||
|
||||
tracing = { version = "0.1" }
|
||||
tracing-subscriber = { version = "0.3", optional = true }
|
||||
tracing-tracy = { version = "0.8", optional = true }
|
||||
tracy-client = { git = "https://github.com/nagisa/rust_tracy_client.git", branch = "create-pull-request/patch", optional = true }
|
||||
|
||||
|
||||
# Vector riles
|
||||
|
||||
@ -125,7 +125,7 @@ pub async fn run(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "enable-tracing")]
|
||||
#[cfg(all(feature = "enable-tracing", not(target_arch = "wasm32")))]
|
||||
tracy_client::finish_continuous_frame!();
|
||||
}
|
||||
Event::Suspended => {
|
||||
|
||||
@ -33,12 +33,29 @@ pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8
|
||||
#[cfg(feature = "web-webgl")]
|
||||
pub const COLOR_TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
||||
|
||||
#[cfg(feature = "enable-tracing")]
|
||||
fn enable_tracing() {
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::Registry;
|
||||
|
||||
let mut builder = tracing_wasm::WASMLayerConfigBuilder::new();
|
||||
builder.set_report_logs_in_timings(true);
|
||||
builder.set_console_config(tracing_wasm::ConsoleConfig::NoReporting);
|
||||
|
||||
tracing::subscriber::set_global_default(
|
||||
Registry::default().with(tracing_wasm::WASMLayer::new(builder.build())),
|
||||
);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn wasm_bindgen_start() {
|
||||
if let Err(_) = console_log::init_with_level(log::Level::Info) {
|
||||
// Failed to initialize logging. No need to log a message.
|
||||
}
|
||||
panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
|
||||
#[cfg(any(feature = "enable-tracing"))]
|
||||
enable_tracing();
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
||||
@ -64,7 +64,7 @@ module.exports = (env) => ({
|
||||
// command. Default arguments are `--verbose`.
|
||||
//args: '--log-level warn',
|
||||
// Default arguments are `--typescript --target browser --mode normal`.
|
||||
extraArgs: ` --target web -- . -Z build-std=std,panic_abort ${env.webgl ? '--features web-webgl' : ''}`,
|
||||
extraArgs: ` --target web -- . -Z build-std=std,panic_abort ${env.webgl ? '--features web-webgl' : ''} ${env.tracing ? '--features enable-tracing' : ''}`,
|
||||
|
||||
// Optional array of absolute paths to directories, changes to which
|
||||
// will trigger the build.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user