Skip to content

Commit

Permalink
Error on wasm worker creation when SAB is not available
Browse files Browse the repository at this point in the history
This should have been part of emscripten-core#22710
  • Loading branch information
sbc100 committed Oct 11, 2024
1 parent ff27062 commit cd30372
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/library_wasm_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ addToLibrary({
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_eval_expressions
$_wasmWorkerBlobUrl: "URL.createObjectURL(new Blob(['onmessage=function(d){onmessage=null;d=d.data;{{{ captureModuleArg() }}}{{{ instantiateWasm() }}}importScripts(d.js);{{{ instantiateModule() }}}d.wasm=d.mem=d.js=0;}'],{type:'application/javascript'}))",
#endif

_emscripten_create_wasm_worker__deps: [
'$_wasmWorkers', '$_wasmWorkersID',
'$_wasmWorkerAppendToQueue', '$_wasmWorkerRunPostMessage',
Expand All @@ -156,6 +155,12 @@ if (ENVIRONMENT_IS_WASM_WORKER
addEventListener("message", _wasmWorkerAppendToQueue);
}`,
_emscripten_create_wasm_worker: (stackLowestAddress, stackSize) => {
if (typeof SharedArrayBuffer != 'undefined') {
#if ASSERTIONS
dbg('create_wasm_worker: environment does not support SharedArrayBuffer, wasm workers are not available');
#endif
return 0;
}
let worker = _wasmWorkers[_wasmWorkersID] = new Worker(
#if WASM_WORKERS == 2
// WASM_WORKERS=2 mode embeds .ww.js file contents into the main .js file
Expand Down

0 comments on commit cd30372

Please sign in to comment.