How to open emscripten generated js file in web worker?

255 views
Skip to first unread message

Mahesh Velankar

unread,
Dec 20, 2021, 10:30:16 AM12/20/21
to emscripten-discuss
1. I can successfully open mycode.js (created by emscripten) in my html page and use the wasm by attaching a function to Module.onRuntimeInitialized

2. I wish to do the above activity in a web worker (instead of calling mycode.js in script tags in my html page)
so I wrote a ww.js file and called
var w = new Worker("ww.js");

in ww.js I have this code

importScripts('mycode.js');
Module.onRuntimeInitialized = function() {
  console.log('mycode module runtime Initialized');
}

I am getting errors in the console.
Uncaught (in promise) RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0)

So my question is why the mycode.js "works" from the script tags and does not work from the web worker.

Please help me .
(You must have noticed that I am a newbie !!!)
Or point me to any example code to achieve the above.

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages