summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-03-07 23:39:55 +0100
committerLibravatar GitHub <noreply@github.com>2024-03-07 23:39:55 +0100
commit2074757cdc65ec16eeb1c7a12a5ff3bb5ed00859 (patch)
tree43ea058c8b7d0b4a13f9fe3ad7015efeea94ed48 /src
parent1bb5a1b9a23e1c4739430ac87ca33b06c2f4d9df (diff)
parentecf42b97df85df25b1b825f37adfeb00f658f6ee (diff)
downloadiced-2074757cdc65ec16eeb1c7a12a5ff3bb5ed00859.tar.gz
iced-2074757cdc65ec16eeb1c7a12a5ff3bb5ed00859.tar.bz2
iced-2074757cdc65ec16eeb1c7a12a5ff3bb5ed00859.zip
Merge pull request #2313 from iced-rs/fix/wasm-block-on
Fix `block_on` in `iced_wgpu` hanging Wasm builds
Diffstat (limited to 'src')
-rw-r--r--src/application.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/application.rs b/src/application.rs
index 3d89c758..87c2607a 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -205,11 +205,26 @@ pub trait Application: Sized {
..crate::renderer::Settings::default()
};
- Ok(crate::shell::application::run::<
+ let run = crate::shell::application::run::<
Instance<Self>,
Self::Executor,
crate::renderer::Compositor,
- >(settings.into(), renderer_settings)?)
+ >(settings.into(), renderer_settings);
+
+ #[cfg(target_arch = "wasm32")]
+ {
+ use crate::futures::FutureExt;
+ use iced_futures::backend::wasm::wasm_bindgen::Executor;
+
+ Executor::new()
+ .expect("Create Wasm executor")
+ .spawn(run.map(|_| ()));
+
+ Ok(())
+ }
+
+ #[cfg(not(target_arch = "wasm32"))]
+ Ok(crate::futures::executor::block_on(run)?)
}
}