diff options
| author | 2024-03-07 23:39:55 +0100 | |
|---|---|---|
| committer | 2024-03-07 23:39:55 +0100 | |
| commit | 2074757cdc65ec16eeb1c7a12a5ff3bb5ed00859 (patch) | |
| tree | 43ea058c8b7d0b4a13f9fe3ad7015efeea94ed48 /wgpu/src | |
| parent | 1bb5a1b9a23e1c4739430ac87ca33b06c2f4d9df (diff) | |
| parent | ecf42b97df85df25b1b825f37adfeb00f658f6ee (diff) | |
| download | iced-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 '')
| -rw-r--r-- | wgpu/src/window/compositor.rs | 16 | 
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)      } | 
