-
Notifications
You must be signed in to change notification settings - Fork 906
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, buffer_future panics after commit 32af4f5 in example hello-compute #2715
Comments
Hmm, there's something up with the plumbing, the sender is being dropped without being called. |
Hi again, I tested some more and found a fix for the issue, but I'm not sure it is what we are looking for. I'll explain why further down in the comment. In the following file:
The issue with this fix is that it seems that the "forget" call causes memory-leaks: An workaround is found here, but it is from 2018 and it briefly describes that "weak-refs" would solve this issue: This seems to be what the above link was about. However, it requires the flag "--weak-refs" to be enabled for wasm-bindgen cli: wasm-pack seems to not have the flag for "--weak-refs": Perhaps you have found a better way to resolve this issue, without using the "forget" call? Also, any findings about the issue which requires the line Best regards, |
web_sys is just out of date, see #2795 Bleh that's annoying. https://docs.rs/wasm-bindgen/latest/wasm_bindgen/closure/struct.Closure.html#method.once_into_js though seems to support turning FnOnce functions into closures without leaking what they contain. However because we share resources with a function that doesn't get called, we should add a call to https://doc.rust-lang.org/std/rc/struct.Rc.html#method.decrement_strong_count to cause the Rc to fully die. |
@TimothyBergstrom could you try out #2807? I don't have a WebGPU browser handy. |
Description
I have some issues when running webgpu for wasm32-unknown-unknown after the commit 32af4f5. In commit 8063edc, it works fine
I tested the "wgpu/examples/hello-compute/main.rs"
Repro steps
Go to
wgpu
directory(in windows, in unix remove "set")
set RUSTFLAGS=--cfg=web_sys_unstable_apis
Run the commands
cargo build --no-default-features --target wasm32-unknown-unknown --example hello-compute
wasm-bindgen --out-dir target/generated --web ../target/wasm32-unknown-unknown/debug/examples/hello-compute.wasm
change
getObject(arg0).dispatch
intarget/generated/hello-compute.js
to
Not sure if it is an issue with the "wrong" dispatch comes from wasm-bindgen or wgpu? Otherwise, it yields the error
Uncaught (in promise) TypeError: getObject(...).dispatch is not a function
.Create the file
target/generated/index.html
and add the following:Run the command (requires installation)
simple-http-server target/generated
open
localhost:8000
open the console (f12) and check output
Expected vs observed behavior
Example should pass / compute in both commits
Extra materials
Fail commit 32af4f5
Ok commit 8063edc
Platform
Windows version 10.0.19044 build 19044
cargo 1.60.0 (d1fd9fe2c 2022-03-01)
rustc 1.60.0 (7737e0b5c 2022-04-04)
wasm-bindgen 0.2.80
Firefox nightly 103.0a1 (2022-05-31) (64-bit) with webgpu enabled
The text was updated successfully, but these errors were encountered: