2 min read

Yesterday, Google announced that Chrome 70 now supports WebAssembly threads. The WebAssembly Community Group has been working to bring the support for threads to the web and this is a step towards that effort. Google’s open source JavaScript and WebAssembly engine, V8 has implemented all the necessary support for WebAssembly threads.

Why the support for WebAssembly threads is needed?

Earlier, parallelism in browsers was supported with the help of web workers. The downside of web workers is that they do not share mutable data between them. Instead, they rely on message-passing for communication.

On the other hand, WebAssembly threads can share the same Wasm memory. The underlying storage of shared memory is enabled by SharedArrayBuffer, a JavaScript primitive that allows sharing the contents of a single ArrayBuffer concurrently between workers. Each WebAssembly thread runs in a web worker, but their shared Wasm memory allows them to work as fast as they do on native platforms. This means that those applications which use Wasm threads are responsible for managing access to the shared memory as in any traditional threaded application.

How you can try this support

To test the WebAssembly module you need to turn on the experimental WebAssembly threads support in Chrome 70 onwards:

  1. First, navigate to the chrome://flags URL in your browser:

WebAssembly Support

Source: Google Developers

  1. Next, go to the experimental WebAssembly threads setting:

WebAssembly thread support

Source: Google Developers

  1. Now change the setting from Default to Enabled and then restart your browser:

WebAssembly thread support enabled

Source: Google Developers

The aforementioned steps are for development purposes. In case you are interested in testing your application out in the field, you can do that with origin trial. Original trials allow you to try experimental features with your users by obtaining a testing token that’s tied to your domain.

You can read more in detail about the WebAssembly thread support in Chrome 70 on the Google Developers blog.

Read Next

Chrome 70 releases with support for Desktop Progressive Web Apps on Windows and Linux

Testing WebAssembly modules with Jest [Tutorial]

Introducing Walt: A syntax for WebAssembly text format written 100% in JavaScript and needs no LLVM/binary toolkits