Description
Describe the Bug
I have a multithreaded wasm app that uses futures-channel-preview for asynchronous communication that suddenly stopped working with Chrome version 87+. I googled a bit to find out that chrome released the Atomics.waitAsync feature and that even the example i used as a reference triggers exactly the same bug.
The problem turned out to be in this function:
wasm-bindgen/crates/futures/src/task/multithread.rs
Lines 158 to 170 in 316c5a7
Since
Atomics.waitAsync
is now defined in Chrome, it is getting used instead of the fallback method, however the function waitAsync is expecting either a Int32Array or a BigInt64Array backed by a SharedArrayBuffer. Also it's not returning a promise anymore but an Object with 2 properties async
and value
. The value property can either be a string or a promise. (Source)
I fixed the bug for my app in this fork but i'm not really sure if the code is compliant for a PR, not sure if that breaks anything else and also if the other output cases should be handled aswell. I'd be happy to change it accordingly with your input though.
Steps to Reproduce
Just clone and run this example in Chrome 87+ or use the already compiled online one
Expected Behavior
A promise should be returned from wait_async()
to be resolved successfully later with a call to Atomics.notify
.
Actual Behavior
This error is thrown:
TypeError: #<SharedArrayBuffer> is not an int32 or BigInt64 typed array.
Additional Context
rustc 1.49.0-nightly
futures-channel-preview = "0.3.0-alpha.18"
wasm-bindgen = "0.2.68"