diff options
| author | 2023-01-13 11:56:28 -0800 | |
|---|---|---|
| committer | 2023-01-13 12:26:23 -0800 | |
| commit | 790fa3e7a01a790aa3f07083fe9abf6b68fa7ba1 (patch) | |
| tree | 5fbbc65e7724cee44e9a180b5a0ca7edeb38f301 /glutin | |
| parent | f78ccd9af9ced4c18ed4b56cbf838c6c5a5119ad (diff) | |
| download | iced-790fa3e7a01a790aa3f07083fe9abf6b68fa7ba1.tar.gz iced-790fa3e7a01a790aa3f07083fe9abf6b68fa7ba1.tar.bz2 iced-790fa3e7a01a790aa3f07083fe9abf6b68fa7ba1.zip  | |
Added tracing to multi_window applications
Diffstat (limited to '')
| -rw-r--r-- | glutin/Cargo.toml | 2 | ||||
| -rw-r--r-- | glutin/src/application.rs | 8 | ||||
| -rw-r--r-- | glutin/src/multi_window.rs | 50 | 
3 files changed, 40 insertions, 20 deletions
diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 3f902d20..5197b076 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]  categories = ["gui"]  [features] -trace = ["iced_winit/trace"] +trace = ["iced_winit/trace", "tracing"]  debug = ["iced_winit/debug"]  system = ["iced_winit/system"]  multi_window = ["iced_winit/multi_window"] diff --git a/glutin/src/application.rs b/glutin/src/application.rs index f43a47b9..a6479597 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -33,7 +33,7 @@ use std::ffi::CString;  use std::mem::ManuallyDrop;  use std::num::NonZeroU32; -#[cfg(feature = "tracing")] +#[cfg(feature = "trace")]  use tracing::{info_span, instrument::Instrument};  #[allow(unsafe_code)] @@ -62,7 +62,7 @@ where      let mut debug = Debug::new();      debug.startup_started(); -    #[cfg(feature = "tracing")] +    #[cfg(feature = "trace")]      let _ = info_span!("Application::Glutin", "RUN").entered();      let mut event_loop = EventLoopBuilder::with_user_event().build(); @@ -298,7 +298,7 @@ where              settings.exit_on_close_request,          ); -        #[cfg(feature = "tracing")] +        #[cfg(feature = "trace")]          let run_instance =              run_instance.instrument(info_span!("Application", "LOOP")); @@ -509,7 +509,7 @@ async fn run_instance<A, E, C>(                  messages.push(message);              }              event::Event::RedrawRequested(_) => { -                #[cfg(feature = "tracing")] +                #[cfg(feature = "trace")]                  let _ = info_span!("Application", "FRAME").entered();                  debug.render_started(); diff --git a/glutin/src/multi_window.rs b/glutin/src/multi_window.rs index 2b456543..a2e0581a 100644 --- a/glutin/src/multi_window.rs +++ b/glutin/src/multi_window.rs @@ -32,6 +32,9 @@ use std::ffi::CString;  use std::mem::ManuallyDrop;  use std::num::NonZeroU32; +#[cfg(feature = "tracing")] +use tracing::{info_span, instrument::Instrument}; +  #[allow(unsafe_code)]  const ONE: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(1) }; @@ -52,9 +55,15 @@ where      use winit::event_loop::EventLoopBuilder;      use winit::platform::run_return::EventLoopExtRunReturn; +    #[cfg(feature = "trace")] +    let _guard = iced_winit::Profiler::init(); +      let mut debug = Debug::new();      debug.startup_started(); +    #[cfg(feature = "tracing")] +    let _ = info_span!("Application::Glutin", "RUN").entered(); +      let mut event_loop = EventLoopBuilder::with_user_event().build();      let proxy = event_loop.create_proxy(); @@ -267,21 +276,29 @@ where      let (mut sender, receiver) = mpsc::unbounded(); -    let mut instance = Box::pin(run_instance::<A, E, C>( -        application, -        compositor, -        renderer, -        runtime, -        proxy, -        debug, -        receiver, -        display, -        windows, -        configuration, -        context, -        init_command, -        settings.exit_on_close_request, -    )); +    let mut instance = Box::pin({ +        let run_instance = run_instance::<A, E, C>( +            application, +            compositor, +            renderer, +            runtime, +            proxy, +            debug, +            receiver, +            display, +            windows, +            configuration, +            context, +            init_command, +            settings.exit_on_close_request, +        ); + +        #[cfg(feature = "tracing")] +            let run_instance = +            run_instance.instrument(info_span!("Application", "LOOP")); + +        run_instance +    });      let mut context = task::Context::from_waker(task::noop_waker_ref()); @@ -619,6 +636,9 @@ async fn run_instance<A, E, C>(                  Event::NewWindow { .. } => unreachable!(),              },              event::Event::RedrawRequested(id) => { +                #[cfg(feature = "tracing")] +                let _ = info_span!("Application", "FRAME").entered(); +                  let state = window_ids                      .get(&id)                      .and_then(|id| states.get_mut(id))  | 
