user9009597
user9009597

Reputation: 19

How to post wasm.instance.exports object to and from WebWorkers?

I can't post wasm.instance.exports object to and from WebWorkers. Any help would be appreciated.

Upvotes: 1

Views: 312

Answers (1)

ColinE
ColinE

Reputation: 70160

The messages sent via the postMessage API must be serializable. The exports from a WebAssembly module are functions (and tables, memory etc...) exported by your compiled module. None of these are serializable.

In order to invoke these exported functions, you’ll have to do it indirectly, i.e. post a message that describes which function to export, and the parameters to supply.

Upvotes: 0

Related Questions