ashtonmeuser / godot-wasm

Interact with WebAssembly modules from Godot

Home Page:https://github.com/ashtonmeuser/godot-wasm/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web/HTML5 export

ashtonmeuser opened this issue · comments

Just allowing Godot Wasm to be used as a module is not enough to export for web/HTML5. This is because Wasmer (the Wasm runtime used by this project) is not able to be comiled to Wasm by Emscripten which is what is happening internally when compiling the web/HTML5 Godot export templates. The following error is presented.

[bin/godot.javascript.opt.js] Implicit dependency `modules/wasm/libwasmer.javascript.opt.a' not found, needed by target `bin/godot.javascript.opt.js'.

I see a few solutions to this but none that are a simple addition to this project.

  1. Use a Wasm runtime that is able to be compiled to Wasm such as Wasm3. This library is should be able to be compiled by Emscripten. Unfourtunately, it does not seem to adhere to the Wasm C API and would therefore require a significant rework of this project or a shim to add API equivalence.
  2. Create a small shim library that exposes the Wasm C API (which is used by this project) and translates the relevant Wasm interactions to JavaScript. Because the browser has a Wasm runtime, including another runtime e.g. Wasmer or Wasm3 seems superfluous. This seems like the more sensible option.

Can you provide a design for the option exposes the Wasm C API?

In https://github.com/ashtonmeuser/godot-wasm/blob/master/config.py I would return False if the platform is web for now.

Can you provide a design for the option exposes the Wasm C API?

I'll play around with this to see how feasible it is and update this issue. In short, we'd need to override parts of the Wasmer implementation of the Wasm C API to be a bridge to JS. Wasmer cannot be compiled to Wasm but that's okay because there is obviously already a Wasm runtime exposed to web exports that is accessible by JS.

In https://github.com/ashtonmeuser/godot-wasm/blob/master/config.py I would return False if the platform is web for now.

Done. Only supporting Linux, macOS, and Windows.