mandelbrot-threaded-webassembly icon indicating copy to clipboard operation
mandelbrot-threaded-webassembly copied to clipboard

Browsers no longer letting users to use shared memory

Open Smithangshu opened this issue 4 years ago • 2 comments
trafficstars

Browsers no longer letting users to use shared memory with out setting the appropriate flag in setting. Is there any workaround for this without changing flag?

Smithangshu avatar Jun 18 '21 11:06 Smithangshu

Uncaught DOMException: Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated.
    at https://colineberhardt.github.io/mandelbrot-threaded-webassembly/:54:14

stepheneb avatar Jan 04 '23 23:01 stepheneb

The only way to work around this is to add the following headers to the response that serves the html page. If you are hosting the code locally and using VSCode's Live Preview extension, you can do this by setting the default response headers in the settings.json for that extension:

    "livePreview.httpHeaders": {
        "Cross-Origin-Opener-Policy": "same-origin",
        "Cross-Origin-Embedder-Policy": "require-corp"
    },

If you are hosting on github pages, there is currently no way to modify the headers returned by the server but you can use a hack to workaround this: https://github.com/gzuidhof/coi-serviceworker

Of course, if you are using your own server then you can configure it to respond with the appropriate headers to requests for your page.

alexspurling avatar Jan 02 '24 21:01 alexspurling