emscripten-core / emscripten-core/emscripten

In docs, mention CORS with respect to Audio Worklets

Open
#20,454 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

https://github.com/emscripten-core/emscripten/issues/20349#issuecomment-1762155539 encountered problems with SharedArrayBuffer. Neither of the tutorials mentions CORS, so this was an inevitable error: https://emscripten.org/docs/api_reference/wasm_audio_worklets.html, https://github.com/emscripten-core/emscripten/blob/main/test/webaudio/audioworklet.c.

Proposed solution: Add docs. At https://emscripten.org/docs/api_reference/wasm_audio_worklets.html, right after "Compile the code with the linker flags -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 to enable targeting AudioWorklets.", this text is added:

"Web browsers prohibit sharing data between threads unless CORS headers are set. If you try to open the html file you just compiled, you will receive the error `SharedArrayBuffer is not defined`. To fix this, host the html file with a web server that sets CORS headers. For example, you can run `python3 \[this python script\]` to serve all files in the same directory, then navigate to http://127.0.0.1:8000/your_file_here.html. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements) for more information."

The [python script is this one](https://github.com/emscripten-core/emscripten/files/12907932/localcorswebserver.txt). The extension should be .py; github doesn't let me upload .py files.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.