Skip to content

In docs, mention CORS with respect to Audio Worklets #20454

@ad8e

Description

@ad8e

#20349 (comment) 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 for more information."

The python script is this one. The extension should be .py; github doesn't let me upload .py files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions