mrk-its / bevy_webgl2_app_template

Other
60 stars 19 forks source link

bevy_webgl2 dependency will not build #13

Open Geordi7 opened 3 years ago

Geordi7 commented 3 years ago

I did a fresh clone and cargo make and it gets stuck on this error:

   Compiling bevy_webgl2 v0.5.0
error[E0432]: unresolved import `winit::platform::web`
  --> /Users/geordi/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_webgl2-0.5.2/src/renderer/webgl2_render_resource_context.rs:88:30
   |
88 |         use winit::platform::web::WindowExtWebSys;
   |                              ^^^ could not find `web` in `platform`

error[E0599]: no method named `canvas` found for reference `&winit::window::Window` in the current scope
  --> /Users/geordi/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_webgl2-0.5.2/src/renderer/webgl2_render_resource_context.rs:98:14
   |
98 |             .canvas()
   |              ^^^^^^ method not found in `&winit::window::Window`

error: aborting due to 2 previous errors

I thought the issue might be in bevy_webgl2, but I cloned it and switched to the v0.5 branch and cargo make succeeds.

I also tried switching the dependency version to v0.5.2, it did not fix the issue.

I looked through the features flags for both projects, and I tried copying over the winit dependency specifier, it did not fix the issue.

I could not think of something else to try.

Geordi7 commented 3 years ago

Added note: I reproduced this error with rustc 1.56.0 on a M1 MacOS host and an i86_x86 Win10 host

Geordi7 commented 3 years ago

OK... I solved it... but it was awkward

First: running cargo make doesn't work, you have to run cargo make serve so that it correctly sets the feature flags. It might be nice to have a cargo make web option to just do the build and not run the server. Also cargo make should emit an explicit error to the user given that the build will definitely fail.

After figuring that out I ran into the problem in issue #12, which happens because wasm-bindgen-cli's latest version is later than the version referenced in bevy_webgl2.

I ran cargo install wasm-bindgen-cli --version 0.2.69, after which it built successfully. I got this idea because the Cargo.toml of bevy_webgl2 specifies this version of wasm-bindgen.

Geordi7 commented 3 years ago

Just Realized I closed this issue, but no changes were made to fix it...

Please update the readme to clearly state that cargo make doesn't work, and add a note about setting the version of wasm-bindgen-cli to match the wasm-bindgen version of bevy_webgl2.

mrk-its commented 3 years ago

Can you check again? It should do local installation of proper wasm-bindgen-cli version. Dependencies are also fixed (it should not try to compilee bevy-webgl2 on non-wasm32 platforms), but I tested that only on linux machine so far.