Skip to content

Commit 8bf26bf

Browse files
authored
Fix audio worklet + memory64 (#22731)
There are a two different fixes here, neither of which are needed except in the nightly version of chrome. 1. In the `instantiateWasm` override used in audio worklets return the result of `receiveInstance` rather then directly returning the wasm exports. This means that the resulting object has the needed wrappers applied. This was causing an exception even on older version of chrome, but the tests still passed regardless. With newer versions of chrome the exception seems to cause the worklet creation to fail. (see #18711) 2. Using BigInt when indexing the wasm table. I would have prefered to use `toIndexType` here but that doesn't work in `audio_worklet.js`.
1 parent 0486179 commit 8bf26bf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/audio_worklet.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ class BootstrapMessages extends AudioWorkletProcessor {
138138
// initialize the Wasm Module.
139139
globalThis.Module['instantiateWasm'] = (info, receiveInstance) => {
140140
var instance = new WebAssembly.Instance(Module['wasm'], info);
141-
receiveInstance(instance, Module['wasm']);
142-
return instance.exports;
141+
return receiveInstance(instance, Module['wasm']);
143142
};
144143
#endif
145144
#if WEBAUDIO_DEBUG
@@ -184,7 +183,12 @@ class BootstrapMessages extends AudioWorkletProcessor {
184183
// 'ud' the passed user data
185184
p.postMessage({'_wsc': d['cb'], 'x': [d['ch'], 1/*EM_TRUE*/, d['ud']] });
186185
} else if (d['_wsc']) {
187-
Module['wasmTable'].get(d['_wsc'])(...d['x']);
186+
#if MEMORY64
187+
var ptr = BigInt(d['_wsc']);
188+
#else
189+
var ptr = d['_wsc'];
190+
#endif
191+
Module['wasmTable'].get(ptr)(...d['x']);
188192
};
189193
}
190194
}

tools/emscripten.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,6 @@ def create_pointer_conversion_wrappers(metadata):
11301130
for f in wrap_functions:
11311131
sig = mapping[f]
11321132
wrappers += f"\n wasmExports['{f}'] = makeWrapper_{sig}(wasmExports['{f}']);"
1133-
wrappers += 'return wasmExports;\n}'
1133+
wrappers += '\n return wasmExports;\n}'
11341134

11351135
return wrappers

0 commit comments

Comments
 (0)