Wasm-pack | createBufferMapped is not a function
Closed this issue · 6 comments
I'm working on a multiplatform wgpu example https://github.com/sotrh/wgpu-multiplatform, and I've hit a bit of a snag on the wasm
portion. The code builds just fine, but the example I've made fails with the following error.
Uncaught (in promise) TypeError: getObject(...).createBufferMapped is not a function
__wbg_createBufferMapped_198ac74b005c14c1 demo_bg.js:737
__wbg_createBufferMapped_198ac74b005c14c1 app.js:1098
__wbg_adapter_49 demo_bg.js:253
real demo_bg.js:202
The project was working just fine before I added a uniform buffer to animate the simulation.
I haven't tested this on Chrome Canary as they don't have a Linux target, but this is from Firefox Nightly (84.0a1 (2020-11-03) (64-bit)).
Testing
git clone https://github.com/sotrh/wgpu-multiplatform
cd wgpu-multiplatform
sh setup.sh
yarn serve
Go to http://localhost:8080/wgpu-multiplatform and then open up the console. You should see the same error.
Cargo.toml
[package]
name = "demo"
version = "0.1.0"
authors = ["Ben Hansen <bhbenjaminhansen@gmail.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
# wgpu = "0.6"
wgpu = { version = "0.6", git = "https://github.com/gfx-rs/wgpu-rs" }
winit = { version = "0.23", features = ["web-sys"] }
env_logger = "0.7"
log = "0.4"
anyhow = "1.0"
futures = "0.3"
bytemuck = { version = "1.4", features = ["derive"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.subscriber]
package = "wgpu-subscriber"
version = "0.1"
[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = "=0.3.45"
wasm-bindgen = "=0.2.68" # Must be exact
wasm-bindgen-futures = "0.4.18"
console_error_panic_hook = "0.1.6"
console_log = "0.1.2"
[build-dependencies]
anyhow = "1.0"
fs_extra = "1.2"
glob = "0.3"
rayon = "1.4"
shaderc = "0.6"
Other info
rustup 1.22.1 (b01adbbc3 2020-07-08)
cargo 1.46.0 (149022b1d 2020-07-17)
wasm-pack 0.9.1
This may be a web-sys issue as running the desktop version of the project works fine.
WebGPU API is a moving target. There is no semver compatibility guarantees for this target yet. Best you can do is to track the gecko
branch, which matches Firefox support for the API.
Gotcha, I'll probably work on other aspects of the project until the gecko
branch lines up with 0.6
FYI, I ran in to the same issue and tried to work around it by using create_buffer
+ get_mapped_range_mut
, but that doesn't work either as get_mapped_range_mut
is still unimplemented in wgpu-rs's web backend.
@khuttun you could temporarily use the polyfill from master
that uses the old buffer mapping API. This will break when Firefox is updated though, so we didn't bother to backport it to 0.6.
Yeah you're correct, that would only work with a slightly older version of Firefox Nightly for now. We'll update the bindings soon to match the newest Nightly.