summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-07 23:25:24 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-07 23:25:24 +0100
commitecf42b97df85df25b1b825f37adfeb00f658f6ee (patch)
tree43ea058c8b7d0b4a13f9fe3ad7015efeea94ed48 /wgpu
parent1bb5a1b9a23e1c4739430ac87ca33b06c2f4d9df (diff)
downloadiced-ecf42b97df85df25b1b825f37adfeb00f658f6ee.tar.gz
iced-ecf42b97df85df25b1b825f37adfeb00f658f6ee.tar.bz2
iced-ecf42b97df85df25b1b825f37adfeb00f658f6ee.zip
Fix `block_on` in `iced_wgpu` hanging Wasm builds
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/window/compositor.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs
index 0a5d2c8f..328ad781 100644
--- a/wgpu/src/window/compositor.rs
+++ b/wgpu/src/window/compositor.rs
@@ -6,6 +6,8 @@ use crate::graphics::compositor;
use crate::graphics::{Error, Viewport};
use crate::{Backend, Primitive, Renderer, Settings};
+use std::future::Future;
+
/// A window graphics backend for iced powered by `wgpu`.
#[allow(missing_debug_implementations)]
pub struct Compositor {
@@ -158,17 +160,13 @@ impl Compositor {
/// Creates a [`Compositor`] and its [`Backend`] for the given [`Settings`] and
/// window.
-pub fn new<W: compositor::Window>(
+pub async fn new<W: compositor::Window>(
settings: Settings,
compatible_window: W,
) -> Result<Compositor, Error> {
- let compositor = futures::executor::block_on(Compositor::request(
- settings,
- Some(compatible_window),
- ))
- .ok_or(Error::GraphicsAdapterNotFound)?;
-
- Ok(compositor)
+ Compositor::request(settings, Some(compatible_window))
+ .await
+ .ok_or(Error::GraphicsAdapterNotFound)
}
/// Presents the given primitives with the given [`Compositor`] and [`Backend`].
@@ -234,7 +232,7 @@ impl graphics::Compositor for Compositor {
fn new<W: compositor::Window>(
settings: Self::Settings,
compatible_window: W,
- ) -> Result<Self, Error> {
+ ) -> impl Future<Output = Result<Self, Error>> {
new(settings, compatible_window)
}