Fix block_on in iced_wgpu hanging Wasm builds

This commit is contained in:
Héctor Ramón Jiménez 2024-03-07 23:25:24 +01:00
parent 1bb5a1b9a2
commit ecf42b97df
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
8 changed files with 53 additions and 30 deletions

View file

@ -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)?)
}
}