From f1ec0af5070fe2752967cdc38ed66b8b70882366 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 4 May 2022 14:25:04 +0200 Subject: Run `system::information` in a different thread ... since it seems it can block for a couple of seconds. --- winit/src/application.rs | 17 +++++++++++------ winit/src/system.rs | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 421ae398..90b03d56 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -583,14 +583,19 @@ pub fn run_command( system::Action::QueryInformation(_tag) => { #[cfg(feature = "system")] { - let information = - crate::system::information(_graphics_info()); + let graphics_info = _graphics_info(); + let proxy = proxy.clone(); - let message = _tag(information); + let _ = std::thread::spawn(move || { + let information = + crate::system::information(graphics_info); - proxy - .send_event(message) - .expect("Send message to event loop"); + let message = _tag(information); + + proxy + .send_event(message) + .expect("Send message to event loop") + }); } } }, diff --git a/winit/src/system.rs b/winit/src/system.rs index fa4ad1a3..0ed61dc9 100644 --- a/winit/src/system.rs +++ b/winit/src/system.rs @@ -6,7 +6,7 @@ use iced_graphics::compositor; /// Query for available system information. pub fn fetch_information( - f: impl Fn(Information) -> Message + 'static, + f: impl Fn(Information) -> Message + Send + 'static, ) -> Command { Command::single(command::Action::System(Action::QueryInformation( Box::new(f), -- cgit