Pointers being passed from WASM to JS are interpreted as signed, so
large pointers ended up negative. This prevented WASM programs from
allocating more than 2GB.
To fix it we make all pointers unsigned (via >>> 0) for all malloc/realloc
calls and inside shim functions. Ideally we would have an abstraction
that guarantees we catch all cases, but that would require a major
refactor.
To test it we add gg-alloc as an optional system allocator for
wasm-bindgen-test. It only allocates in the upper 2GB range and was made to
test this exact issue but was never upstreamed.
Fixes#2388Fixes#2957
* Add a test that examples don't throw any errors
TODO:
- run all the tests, not just the ones which use webpack (also an issue with CI)
- fix webxr test
- run in CI
- share WebDriver instance between tests
- maybe ditch async, since we don't really need it here and it adds a bunch of dependencies and build time.
* Disable testing WebXR example
It isn't supported in Firefox yet, which is where we're running our tests.
* Test examples that aren't built with webpack
* Remove `WEBDRIVER` environment variable
It wouldn't have worked anyway because at least for the moment, I'm using one WebDriver session per test, and Firefox at least only allows one session to be connected.
I would like to make them share a session, in which case I could add this back, but I can't right now because Firefox hasn't implemented `LogEntry.source` yet, which is needed to figure out which log entries should fail which tests.
* Run in CI
* Use `Once` instead of `Mutex`
* Build `webxr` and `synchronous-instantiation` in CI
Although we can't test them, we can still build them.
* Add missing '`'
* Fix running of tests
* Only include dev deps when not compiling for wasm
* oops, those are the native tests
* Create build dirs before copying to them
* Install binaryen
* decompress
* Follow redirects
* Set `PATH` properly
* Use an absolute path
* Don't symlink `node_modules` and fix artifact download
* Enable `web_sys_unstable_apis`
This is needed for the `webxr` example.
* Increase timeout to 10s
* Increase timeout to 20s
This seems excessive but 10s is still sometimes failing.
* Disable testing the webgl example
* Add binaryen to PATH directly after installing
* Properly download the raytrace example artifacts
* Disable example tests instead of enabling everything else
* Move to a separate `example-tests` crate
* Make `Closure::new` work on stable
I've removed the nightly requirement by replacing `Unsize<T>` with a custom `IntoWasmClosure<T>` trait, implemented for `Fn` and `FnMut`.
I don't think this is a breaking change, since I don't think any stability guarantees are provided for nightly.
* Update docs
I also removed an outdated note about closures only being able to take WASM primitive types.
* Remove nightly CI
* Don't attempt to enable the removed nightly feature in doc generation
* Upgraded the webpack examples' npm dependencies which (among other things) upgrades them to webpack 5
For the weather_report, had to choose the syncWebAssembly experiment,
whereas the rest works fine with asyncWebAssembly
* Fix the weather report example compilation by adding it to the main workspace.
This currently fails with:
error: current package believes it's in a workspace when it's not:
current:
<project-root>/examples/weather_report/Cargo.toml
workspace: <project-root>/Cargo.toml
* Fix the build of the webxr example with webpack 5
* run cargo fmt
This commit adds a parallel execution example in which we spawn a web
worker with `web_sys`, run WASM code in the web worker and interact
between the main thread and the web worker.
It is intended to add an easy starting point for parallel execution
with WASM, complementing the more involved parallel raytrace example.
Related to GitHub issue #2549
Co-authored-by: Simon Gasse <sgasse@users.noreply.github.com>