Aargh, wasm doesn't work


Sorry to bother you all again, but I’ve been following the WebAssembly tutorial here. I’m particularly interested in the part where you can call wasm code from haxe:

package arm;
import iron.data.*

class MyTrait extends iron.Trait {
    public function new() {

    function init() {
        Data.getBlob("main.wasm"/*changed this to Networking.wasm*/, function(b:kha.Blob) { // Load wasm blob
            var wasm = Wasm.instance(b); // Create wasm module
            var rot = 0.0;
            notifyOnUpdate(function() {
                rot += wasm.exports.test(); // Call function from wasm module!
                object.transform.setRotation(0, 0, rot);

And I tried to… but my C wasm file has probably gone wrong because I get:

Trace: TypeError: WebAssembly Instantiation: Imports argument must be present and must be an object
    at new $hxClasses.iron.data.Wasm (krom.js:9598:18)
    at krom.js:545:15
    at Function.iron_data_Data.getBlob (krom.js:1844:3)
    at $hxClasses.arm.WasmCall.init (krom.js:544:18)
    at f (krom.js:35441:242)
    at iron_App.render (krom.js:1202:4)
    at Function.kha_System.render (krom.js:18121:3)
    at kha_SystemImpl.renderCallback (krom.js:18239:13)

So I hope you enjoy my third post about a bug, I’ll try to lighten the conversation in the future. If anybody can help me out here, it would be greatly appreciated.

–EDIT-- whoops, I forgot there’s no such thing as bool in C, I fixed that (although pastebin doesn’t show it). All the same, I still get the same error… This does at least prove that https://webassembly.studio/?f=qi0imd4j9t does not catch (most?) compile errors.

–EDIT 2-- I actually had some extra errors, see (presumably) bug-free version here. It still complains. I’m frankly very annoyed that the webassembly.studio website doesn’t catch my stupid c errors, but I guess you can’t have everything. For now, I’ll roll with gcc for error check.


In addition, using wasm normally (i.e. wait for call onUpdate(), do stuff) doesn’t work either… Not even an error message in the terminal.


@Liverwurst can you please drop an issue at https://github.com/armory3d/armory/issues with the final C source(or wasm studio link) you ended up with?


Sure thing, I’ll try to get to it by this evening, bit busy at the moment. I’ll post to the thread when I’ve done it.


Okay, I posted issue #769.