-
Notifications
You must be signed in to change notification settings - Fork 950
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
Dependency to "env" makes triangle example not run with wasm_bindgen in browser #5480
Comments
You should try this tool to find the guilty function. |
Thanks for the suggestion, I forgot to mention that I tried this tool and for some reason it didn't return anything. Now I explored the wasm using wasm2wat and I found Looking at my dependency tree, this is something that comes from wgpu's dependency to parking_lot 0.11.2
Is there any way to not depend on this? |
I fixed it by adding Maybe wgpu could add a |
better still, wgpu should enable the |
turns out this was the case at some point. Probably got lost when moving to workspace dependencies? would be good to do the detective work and check if there was a reason this got removed |
I don't think recent versions of parking_lot have this feature flag, maybe that's why it got removed |
Looks like it was removed in #2639 when moving from The problem is that we then started allowing |
I think we can also remove parking_lot 0.11 after switching to windows-rs fully (#3207) |
@grovesNL we can remove it now - the problem was that firefox couldn't accept windows-rs; but they now can. We should double check that parking_lot 0.12 is okay, then just fully upgrade |
Yes, it's fine https://searchfox.org/mozilla-central/source/Cargo.lock#4334 |
Oh ok awesome 👍 |
edit: tl;dr: wgpu's dependency to
parking_lot
0.11 adds a dependency toinstant
without itswasm-bindgen
feature flag, which causes wasm to have an incorrect dependency toenv
Description
The Triangle example compiles with target
wasm32-unknown-unknown
but doesn't run in the browser usingwasm_bindgen
.When adding
wasm_bindgen(start)
(or justwasm_bindgen
) macro to the main in the triangle example,the generated javascript contains
import * as __wbg_star0 from 'env';
When ran, this results in
Failed to resolve import "env" from "backend/pkg/backend.js". Does the file exist?
This looks like an issue other crates also had when something broke compatibility with
wasm32-unknown-unknown
.Repro steps
The following minimal repro contains code that can be commented out to get the code to run :
https://github.com/vizigr0u/rust-wasm-gl/tree/wgpu-wasm-env-bug/backend
Expected vs observed behavior
When
surface.configure(&device, &config);
is in the code, the generated javascript starts withimport * as __wbg_star0 from 'env';
which gives an error when running.When this line is removed, the generated javascript doesn't have the line and the program runs fine.
Expected: in either case there shouldn't be a dependency to env.
Extra materials
Platform
compile command (found in project root
package.json
) :wasm-pack build --dev ./backend --target web
target
wasm32-unknown-unknown
wgpu 0.19.3
see dependencies used in repro's cargo.toml
❯ cargo --version
cargo 1.77.1 (e52e36006 2024-03-26)
❯ rustc --version
rustc 1.77.1 (7cf61ebde 2024-03-27)
Windows 10 + WSL2
The text was updated successfully, but these errors were encountered: