No, it doesn't work like that. The Int16Array
is just an interface wrapping over ArrayBuffer
, which is where the real binary data are stored. When you transfer the ownership, the Int16Array
is invalidated (set to 0 length). In your worker, new Int16Array
is created and assigned to the old ArrayBuffer
. I crated this image for you:
- Post message removes buffer from the typed array.
- Everything that is not Transferable (that is
ArrayBuffer
) is serialized to Structured clone, array buffer is transfered - The
Int16Array
object has no longer a buffer and therefore is invalid - Structured clone is deserialized and that creates new
Int16Array
instance, this instance receives transferred ArrayBuffer
Obviously, interpreter cannot have an idea that you returned the ArrayBuffer
back, so the typed array remains invalid forever.