Questions tagged [sharedarraybuffer]

`SharedArrayBuffer` is a JavaScript object that provides for sharing memory across threads.

SharedArrayBuffer (MDN, spec) is a JavaScript object that provides for sharing memory across threads, such as web worker threads in browsers, or worker threads in Node.js.

72 questions
17
votes
4 answers

Is there any way to use SharedArrayBuffer on GitHub Pages?

To use SharedArrayBuffer, we have to add two response headers: Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp Is there any way to add those headers with GitHub Pages so SharedArrayBuffer will work?
14
votes
1 answer

Does `postMessage` or yielding to the event loop or similar sync shared memory?

I don't see anything in the JavaScript spec, the proposed DOM spec extensions related to SharedArrayBuffer, or the current WHAT-WG HTML spec to suggest that shared memory will be synchronized/updated across threads when one thread posts a message to…
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
8
votes
1 answer

Can you store a JS object in a SharedArrayBuffer?

I need to share an object between a client side application and a web worker and I heard about SharedArrayBuffers. This is what I'd like to do. main.js let myWorker = new Worker('/worker.js') let mySab = new SharedArrayBuffer(1024) let myObj = {…
zlowe
  • 474
  • 4
  • 9
8
votes
1 answer

How to make my site compatible with the upcoming Cross-Origin-Isolation changes for SharedArrayBuffer

So I read that there are upcoming changes in Chrome to enable the usage of SharedArrayBuffer specifically "Making your website "cross-origin isolated"". My site makes use of external APIs that don't meet the requirements for this. So what I did was,…
6
votes
3 answers

JavaScript: TextDecoder on SharedArrayBuffer

I am facing a problem with decode() on SharedArrayBuffer. Code: var sharedArrayBuffer = new SharedArrayBuffer(2); var uint8Array = new Uint8Array(sharedArrayBuffer); uint8Array[0] = 20; var decoder = new TextDecoder(); …
5
votes
2 answers

SharedArrayBuffer in an Iframe

So SharedArrayBuffer was recently limited to Cross-origin isolated pages as a security fix. We have a tool that depends on SharedArrayBuffer, I reworked it to work again by moving it to a barebones page stripped of all other site UI and what not and…
donatJ
  • 3,105
  • 3
  • 32
  • 51
5
votes
2 answers

How to use ffmpeg.wasm in Firefox without getting the SharedArrayBuffer?

I'm trying to load ffmpeg.wasm in a react app to do a small video converter project. The code is working fine on chrome, but in firefox dev edition (83.0b) I catch the following error: ReferenceError: SharedArrayBuffer is not defined Here's the…
Pedro Henrique
  • 181
  • 3
  • 11
4
votes
2 answers

Use ShareArrayBuffer from an electron app

We have an electron app which uses ShareArrayBuffer. It was written with a very old version of electron. When we updated the electron version in order to use SIMD instructions in WASM, it started showing an error saying ShareArrayBuffer is not…
4
votes
1 answer

Running ServiceWorker in Capacitor App on iOS

tl;dr Essentially i need to set COOP/COEP headers to enable SharedArrayBuffer functionality in my Capacitor v3 iOS App and running a ServiceWorker to set the headers is the only solution i have found so far. Background to the problem Both Chrome…
Cam
  • 960
  • 1
  • 12
  • 29
4
votes
2 answers

Is it possible to embed a cross-origin-isolated iframe inside a normal page?

(For some people, this question may equal to "if I can't use sharedArrayBuffer in my main site, can I open an iframe and use sharedArrayBuffer inside the iframe?") So I want to use some wasm with sharedArrayBuffer in my site, but it's impractical to…
4
votes
1 answer

How to cast an `ArrayBuffer` to a `SharedArrayBuffer` in Javascript?

Take the following snippet: const arr = [1.1, 2.2, 3.3] const arrBuffer = (Float32Array.from(arr)).buffer How would one cast this ArrayBuffer to a SharedArrayBuffer? const sharedArrBuffer = ...?
Tom
  • 8,536
  • 31
  • 133
  • 232
3
votes
2 answers

SharedArrayBuffer not defined when using Cypress

I'm using Vite and Cypress for dev and testing I'm loading ffmpeg, it loads fine on Chrome but on Cypress, it gives this error ReferenceError: SharedArrayBuffer is not defined Apparently, it's caused by cross origin isolation. I tried disabling web…
unloco
  • 6,928
  • 2
  • 47
  • 58
3
votes
2 answers

Enable SharedArrayBuffer on localhost

I keep getting a 'SharedArrayBuffer is not defined' error when trying to run ffmpeg.wasm. It appears this is on the Webassembly side. Regardless, I know this is an issue that can be overcome with Cross Origin Isolation. However, I'm trying to run it…
3
votes
1 answer

How to detect if a browser supports SharedArrayBuffer?

I'm using ffmpeg.wasm in my site but it only works if the browser supports SharedArrayBuffer. Is there a simple way to test using javascript (browser js or nodejs) if the browser has support to it? One solution I thought was to compare the user…
Fnr
  • 2,096
  • 7
  • 41
  • 76
3
votes
1 answer

SharedArrayBuffer inside Chrome Extension Sandboxed iFrame

I am trying to use SharedArrayBuffer by setting up a document that is cross-origin isolated. However since it is in a Google Chrome extension and I need WebAssembly, I need to run this inside a sandboxed page. I have a sandboxed page which is…
1
2 3 4 5