Skip to content

crypto is not available inside AudioWorkletGlobalScope #26522

Description

@pioug

Emscripten generates worklet-targeted bundle that crashes in AudioWorkletGlobalScope when random bytes are requested.

Repro: https://github.com/pioug/emscripten-worklet-randomfill

In the repro, a C call to getentropy() goes through Emscripten’s generic randomFill path, which emits a crypto.getRandomValues(...) call but crypto is not available in the audio worklet, so the generated bundle throws ReferenceError: crypto is not defined.

Might be a duplicate of #13224, but my findings point to a breaking change in 5a8d9e5 from Dec 31, 2024.

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.3-git
clang version 23.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/emscripten/5.0.3/libexec/llvm/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions