iced-rs / iced_aw

Additional widgets for the Iced GUI library
MIT License
443 stars 104 forks source link

WASM build broken #274

Open tukanoidd opened 1 month ago

tukanoidd commented 1 month ago

Hey, been trying to make something with iced master on web, but having trouble building the app with iced_aw, getting this error:

Compiling iced_aw v0.9.3 (https://github.com/iced-rs/iced_aw.git#598791cb)
error[E0277]: cannot subtract `std::time::Instant` from `iced::time::Instant`
   --> /home/xpar_vitalii/.cargo/git/checkouts/iced_aw-d8617147b960a6c7/598791c/src/widgets/spinner.rs:185:37
    |
185 |                 let duration = (now - state.last_update).as_secs_f32();
    |                                     ^ no implementation for `iced::time::Instant - std::time::Instant`
    |
    = help: the trait `Sub<std::time::Instant>` is not implemented for `iced::time::Instant`
    = help: the following other types implement trait `Sub<Rhs>`:
              `iced::time::Instant` implements `Sub<Duration>`
              `iced::time::Instant` implements `Sub`

error[E0308]: mismatched types
   --> /home/xpar_vitalii/.cargo/git/checkouts/iced_aw-d8617147b960a6c7/598791c/src/widgets/spinner.rs:201:37
    |
201 |                 state.last_update = now;
    |                 -----------------   ^^^ expected `std::time::Instant`, found `iced::time::Instant`
    |                 |
    |                 expected due to the type of this binding
    |
    = note: `iced::time::Instant` and `std::time::Instant` have similar names, but are actually distinct types
note: `iced::time::Instant` is defined in crate `web_time`
   --> /home/xpar_vitalii/.cargo/registry/src/index.crates.io-6f17d22bba15001f/web-time-1.1.0/src/time/instant.rs:15:1
    |
15  | pub struct Instant(Duration);
    | ^^^^^^^^^^^^^^^^^^
note: `std::time::Instant` is defined in crate `std`
   --> /nix/store/i0jlk8cgwawb852kfk7q67r1pcibzdf0-rust-default-1.81.0-nightly-2024-06-25/lib/rustlib/src/rust/library/std/src/time.rs:156:1
    |
156 | pub struct Instant(time::Instant);
    | ^^^^^^^^^^^^^^^^^^

From what I can tell, spinner widget (src/widgets/spinner.rs 72:5) uses std::time::Instant, instead of using web_time::Instant, which causes this error.

genusistimelord commented 1 month ago

yeah i think the fix is to just make it use the iced time which will allow web and none web i believe.

though, my question is are you also using Iced_aw main branch? If not, if you use iced master you must use iced_aw main as the crate.io one will not work with the git repo iced.

tukanoidd commented 1 month ago

My cargo deps:

[dependencies]
derive_more = "0.99.18"
iced = { git = "https://github.com/iced-rs/iced.git", version = "0.13.0-dev", default-features = false, features = [
  "advanced",
  "wgpu",
] }
iced_aw = { git = "https://github.com/iced-rs/iced_aw.git", version = "0.9.3" }
serde = { version = "1.0.204", features = ["derive"] }

console_error_panic_hook = "0.1"
console_log = "1.0"

Cargo.lock:

[[package]]
name = "iced_aw"
version = "0.9.3"
source = "git+https://github.com/iced-rs/iced_aw.git#598791cb4ceaee26e2dfee6a54722e1c5027e41b"
dependencies = [
 "cfg-if",
 "chrono",
 "iced",
 "itertools",
 "num-format",
 "num-traits",
 "once_cell",
]

I also made sure to clean target/ before building again.

I'm assuming it's using main, or do I need to set the branch manually for some reason?