help wanted
倉庫指標
- Star
- (27,361 star)
- PR 合併指標
- (平均合併 19天 10小時) (30 天內合併 147 個 PR)
描述
Hey guys, I have a hard time integrating WASM + Emscripten with Audio Worklet. He's how we tried to do it:
- We are downloading and compiling .wasm file from the main thread.
- We are instantiating Emscripten's WASM module in the main thread
Module.instantiateWasm = (imports, successCallback) => {
wasm.then((wasmBinary) => {
WebAssembly.instantiate(new Uint8Array(wasmBinary), imports)
.then((output) => {
$window.Module.testWasmInstantiationSucceeded = 1;
successCallback(output.instance, output.module);
})
});
return {};
};
- We are sending wasmModule and wasmMemory to AudioWorklet, thanks to the patch you did on message port
- From AudioWorklet thread we wanted to instantiate it by passing its' memory and module, like that:
AudioWorkletGlobalScope.Module['instantiateWasm'] = function(imports, receiveInstance) {
AudioWorkletGlobalScope.wasmInstance = new WebAssembly.Instance(module, imports);
receiveInstance(AudioWorkletGlobalScope.wasmInstance, AudioWorkletGlobalScope.Module.wasmModule);
return AudioWorkletGlobalScope.wasmInstance.exports;
}
but this is problematic. To do that we need to import Emscripten glue-js output file in AudioWorklet context. So I've tried to do something like that: audioCtx.audioWorklet.addModule('wasm/sndt.js') but it didn't work since Emscripten is not prepared to work in the AudioWorklet context.
Best, Jacek.