You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crypto is not available inside AudioWorkletGlobalScope #26522
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
changed the title [-]Runtime uses crypto which is not available inside AudioWorkletGlobalScope[/-][+]crypto is not available inside AudioWorkletGlobalScope[/+]on Mar 23, 2026
@sbc100 Ah yes, my original app uses generate_uuid. The repro highlights the usage of crypto in the worklet. It would be good if generate_uuid works too if it's a different code path.
@sbc100 Thanks for the quick fix! From what I understand, uuid_generate() won’t work as expected in a worklet unless we override initRandomFill. Is using a shim the recommended solution for now?
Could you open a new bug for uuid_generate in a wasm worker?
I'm not really sure what the best solution would be there, since uuid_generate itself cannot fail. I guess it we can have it fall back from getentropy to just srand?
Activity
[-]Runtime uses crypto which is not available inside AudioWorkletGlobalScope[/-][+]crypto is not available inside AudioWorkletGlobalScope[/+]sbc100 commentedon Mar 23, 2026
Yes, this is looks like its probably a duplicate of #13224.
I'm curious about your findings pointing to #23247 though since that seems related to
generate_uuid. Is your program callinggenerate_uuid?[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.
[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.
[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.
[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.
pioug commentedon Mar 24, 2026
@sbc100 Ah yes, my original app uses
generate_uuid. The repro highlights the usage of crypto in the worklet. It would be good ifgenerate_uuidworks too if it's a different code path.Thanks for working on it!
[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.
[AUDIO_WORKLET] Fix getentropy when called from an audio worklet. (em…
pioug commentedon Mar 24, 2026
@sbc100 Thanks for the quick fix! From what I understand,
uuid_generate()won’t work as expected in a worklet unless we overrideinitRandomFill. Is using a shim the recommended solution for now?sbc100 commentedon Mar 24, 2026
Could you open a new bug for
uuid_generatein a wasm worker?I'm not really sure what the best solution would be there, since
uuid_generateitself cannot fail. I guess it we can have it fall back fromgetentropyto justsrand?