From f01fa891d8334f8b7c57c6feed6cfa00a6e27f4b 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 5446f251b1c6ae..ac371a3d4a82a2 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 3d78e7160d1c22..96864623f11133 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 0ef1cb6e5c3304..0b1b544eec17bd 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -360,6 +360,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::();