Blob::new(&[u8])
fails when wasm memory is backed by SharedArrayBuffer
#208
Labels
bug
Something isn't working
Describe the Bug
I've just stumbled upon an issue with my changes in #152, which is that
new Blob()
doesn't allow passingUint8Array
s backed bySharedArrayBuffer
. This is problematic becauseSharedArrayBuffer
is sometimes used to back wasm memory, which will then causeBlob::new(&[u8])
to fail.This isn't an issue for
Blob::new(ArrayBuffer)
, sinceSharedArrayBuffer
isn't actually a subclass ofArrayBuffer
.Blob::new
will have to fall back to copying the buffer when wasm memory is backed by aSharedArrayBuffer
, or just do it unconditionally.Steps to Reproduce
Expected Behavior
It should run successfully.
Actual Behavior
new Blob()
throws an error, which causes a panic since it's not expected to fail.Additional Context
This is actually the case (according to the spec, at least) for basically everything accepting a buffer source, because WebIDL doesn't consider
SharedArrayBuffer
a real buffer source unless the type has the[AllowShared]
attribute. Based on a quick grep of web-sys's WebIDL definitions, only WebGPU is using that right now.I found out about this from
getrandom
's similar issue: rust-random/getrandom#164.The text was updated successfully, but these errors were encountered: