This is an example of using threads inside specific worklets with WebAssembly,
wasm-bindgen, culminating in an oscillator demo. This demo should
complement the parallel-raytrace example by
demonstrating an alternative approach using ES modules with on-the-fly module
One of the major gotchas with threaded WebAssembly is that Rust does not ship a
precompiled target (e.g. standard library) which has threading support enabled.
This means that you'll need to recompile the standard library with the
appropriate rustc flags, namely
Note that this requires a nightly Rust toolchain. See the more detailed
instructions of the parallel-raytrace example.
This example shares most of its caveats with the parallel-raytrace example. However, it tries to encapsulate worklet creation in a Rust module, so the application developer does not need to maintain custom JS code.
This demo should work in the latest Chrome and Safari versions at this time.
Firefox does not support imports in worklet modules,
which are difficult to avoid in this example, as
importScripts is unavailable
in worklets. Note that this example requires HTTP headers to be set like in