Cross origin sharedmemory atomic int64


  1. We control and

  2. loads an iframe, which loads

  3. and are both running Rust/wasm32 code we control

  4. this is all running in latest Chrome

Question: Is it possible to setup a shared memory, between and, where we have an atomic int64 in the shared memory ?

XY problem: I have Rust/wasm32 code running in different iframes; and I want a simple way, without going into vector clocks, of defining a total order for events that happen in different iframes.

I'd prefer to use shared memory instead of paying the price of postMessage/onMessage constantly.


I don't believe there's any way to directly share memory between multiple iframes even if they have the same origin.

You can use a SharedWorker in the same origin case to have a memory region that is accessible from multiple iframes, but you still have to communicate with the worker via messages from the iframes.

You need

  • a SharedArrayBuffer
  • access to the iframe window object to send a postMessage.
  • set HTTP headers to disable isolation between them so they can use shared memory

Once you have shared a buffer between windows you pass it to wasm.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.