ashtonmeuser / godot-wasm

Interact with WebAssembly modules from Godot
https://github.com/ashtonmeuser/godot-wasm/wiki
MIT License
178 stars 11 forks source link

Support Wasm reference type #36

Open ashtonmeuser opened 1 year ago

ashtonmeuser commented 1 year ago

See Wasm proposal.

Blocked by https://github.com/wasmerio/wasmer/issues/3858.

fire commented 1 year ago

@ashtonmeuser Do you think this will get unblocked from the wasmer codebase in the next 6 months?

A workaround may be needed since there is no activity on the issue.

ashtonmeuser commented 1 year ago

Good question. I truly don't know. I'll ping the maintainer because that seems like a massive gap in their C(++) library. I'm also a little hesitant to use a workaround for this as it's quite a bit more involved than the simple patch applied earlier.

Once Wasmer enables reference types, implementation on our end should be relatively straightforward (see https://github.com/ashtonmeuser/godot-wasm/tree/wip/reference).

ashtonmeuser commented 1 year ago

@fire No response from the Wasmer folks. I'll poke around with using Wasmtime as the runtime as it should be pretty much a drop in replacement as Godot Wasm uses no bespoke Wasmer API and instead sticks purely to the WASM C API to which Wasmtime also conforms.

In the meantime, have you considered simply passing the object instance ID to the module as an int and then to peel the "reference" out of Wasm simply use godot_instance_from_id? It's completely opaque to the module. If you're super super concerned about safety (e.g. one module brute forces a Node instance ID it should know), you could keep a whitelist of instance IDs accessible to each Wasm module on the Godot side.