Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM build broken #274

Closed
tukanoidd opened this issue Jul 26, 2024 · 3 comments
Closed

WASM build broken #274

tukanoidd opened this issue Jul 26, 2024 · 3 comments

Comments

@tukanoidd
Copy link

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
Copy link
Collaborator

genusistimelord commented Jul 26, 2024

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
Copy link
Author

tukanoidd commented Jul 26, 2024

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?

@your-diary
Copy link

your-diary commented Nov 3, 2024

Any updates?
I have the same problem.

Minimal working (broken) Cargo.toml:

[package]
name = "a"
version = "0.1.0"
edition = "2021"

[dependencies]
iced_aw = { version = "0.11.0" }

Command used:

$ cargo build --target wasm32-unknown-unknown

Cargo version: 1.82.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants