mandelbrot-threaded-webassembly
mandelbrot-threaded-webassembly copied to clipboard
Browsers no longer letting users to use shared memory
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?
Uncaught DOMException: Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated.
at https://colineberhardt.github.io/mandelbrot-threaded-webassembly/:54:14
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.