From d3cc8dc2398b041ec603a8bc7e0fff18701d8d58 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 14 Nov 2022 23:08:31 +0000 Subject: [PATCH] add span to winit event handler (#6612) # Objective - Add a span for the winit event handler. I've found this useful in my PR for pipelined rendering and I've seen it come up in a few other contexts now. ![image](https://user-images.githubusercontent.com/2180432/201588888-5dc02063-2c41-471b-8937-a71aeaf174b4.png) --- crates/bevy_internal/Cargo.toml | 3 ++- crates/bevy_winit/Cargo.toml | 1 + crates/bevy_winit/src/lib.rs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index ed749672ab568..91621d23d3b7f 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -16,7 +16,8 @@ trace = [ "bevy_ecs/trace", "bevy_log/trace", "bevy_render?/trace", - "bevy_hierarchy/trace" + "bevy_hierarchy/trace", + "bevy_winit/trace" ] trace_chrome = [ "bevy_log/tracing-chrome" ] trace_tracy = ["bevy_render?/tracing-tracy", "bevy_log/tracing-tracy" ] diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 8382894237969..6bd2bcf516b55 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -9,6 +9,7 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [features] +trace = [] wayland = ["winit/wayland"] x11 = ["winit/x11"] diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 05577fdb7afc0..65714175b6612 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -369,6 +369,8 @@ pub fn winit_runner_with(mut app: App) { let event_handler = move |event: Event<()>, event_loop: &EventLoopWindowTarget<()>, control_flow: &mut ControlFlow| { + #[cfg(feature = "trace")] + let _span = bevy_utils::tracing::info_span!("winit event_handler").entered(); match event { event::Event::NewEvents(start) => { let winit_config = app.world.resource::();