Answering my self, the solution was provided by Paul Adenot which seems to
work for my usecase.
The idea is to createObjectURL from the workletprocessor and the file where
you define the objects you need access to.
I guess it's understandable that we cannot have "real time" access to the
Module object because we provide the worklet with a Class definition, which
explains why what I was trying to do wouldn't work, and didn't make much
sense.
On Monday, January 27, 2020 at 12:49:59 PM UTC+1, Mehdi Sabwat wrote:
>
> Hi,
>
> I want to be able to import the Module object from another file (a
> worklet-processor in my case).
> The problem is that if I have a worker, it will evaluate the "export
> default Module", I guess it's because of a "eval(...)" in importScript().
> I tried appending :
> if (ENVIRONMENT_IS_WEB == 1)
> {
> export default Module;
> }
>
> but I am getting this error :
> Uncaught SyntaxError: Unexpected token 'export'
>
> Here is the context :
> <script async type="module" src="./experimental.js"></script>
> <script type="module">
> import Module from "./experimental.js";
>
> console.log(Module.wasmMemory.buffer.byteLength);
> </script>
>
> I tried a lot of things, including using -s MODULARIZE=1, which does not
> help because (in my case) it slows down the application a lot. And even
> with that, I couldn't use the same Module object instance in the worklet.
>
> There is an example here
> <https://github.com/GoogleChromeLabs/web-audio-samples/tree/master/audio-worklet/design-pattern/wasm-ring-buffer>
>
> that works setting aside the fact that the audio context won't start
> because it's not initialized after a user gesture, but it won't work in my
> case with:
> +#include <emscripten.h>
> #include "emscripten/bind.h"
>
> using namespace emscripten;
> @@ -53,6 +53,11 @@ class VariableBufferKernel {
> unsigned bytes_per_channel_ = 0;
> };
>
> +int main(){
> + EM_ASM(Module["noExitRuntime"] = true;);
> + return 0;
> +}
>
> I put the logs in a file.
>
> Anyone has an idea on what I should do to try to solve this issue?
> Thanks
>
> Regards
> Mehdi
>
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/59f67869-9f51-497a-af53-74fe893bee1f%40googlegroups.com.