Hacker News new | ask | show | jobs
by malcolmwhite 2774 days ago
Using structured cloning for deep copies is clever, but may or may not give you the behavior you want for SharedArrayBuffers. The copied value would be a new SAB with the same underlying data buffer, so that changes to one value will be visible to the other. That's good for most uses of structured cloning, but it's not what I would expect from a deep copy.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

2 comments

The point of structured clone was originally for passing data to web workers. Since the point of shared array buffers is to share data with workers, it makes sense that the structured clone algorithm keeps the SAB identity.
Programs that use SharedArrayBuffers are already defective, so it's no big deal.
Not true. Chrome has enabled SharedArrayBuffers again as of Chrome 68.
Desktop-only, not on Android, right?

Also, a program that only works in one browser, and only due to that browser being willing to open security holes other browsers are not willing to open, is arguably still defective. That said, that might describe a lot of things people are doing nowadays (e.g. anything that uses WebUSB).