Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create WebAssembly version #18

Closed
ThorstenBux opened this issue Jan 8, 2018 · 12 comments
Closed

Create WebAssembly version #18

ThorstenBux opened this issue Jan 8, 2018 · 12 comments

Comments

@ThorstenBux
Copy link

Issue by jensarps
Wednesday Mar 16, 2016 at 11:34 GMT
Originally opened as https://github.com/artoolkit/jsartoolkit5/issues/17


Now that Chrome and Firefox start shipping WebAssembly support, it might be a sweet thing to look into https://github.com/WebAssembly/binaryen, to squeeze out a bit more perf.

@ThorstenBux
Copy link
Author

Comment by jeromeetienne
Monday Jan 30, 2017 at 22:54 GMT


i love the idea. Now we need to find somebody to do it.

any volunteers ? :)

@ThorstenBux
Copy link
Author

Comment by ZoltanVeres
Friday Oct 20, 2017 at 09:37 GMT


Any progress on this?
If not can somebody spec. out the details on how the folder structure should like, where to put the compilation scripts, etc? Thanks!

@ptone
Copy link

ptone commented Mar 4, 2018

Looks like emscripten can target WebAssembly with a flag

https://github.com/kripken/emscripten/wiki/WebAssembly

@ThorstenBux
Copy link
Author

thanks @ptone

I've added the build step for webassembly here ThorstenBux@6f88ec1

on a private branch. After build it fails to load the .wasm file. I haven't looked into as of why but maybe someone would like to pick it up.

@Sithdown
Copy link

Sithdown commented Jun 3, 2018

Any news on this?

@hjeldin
Copy link

hjeldin commented Jul 4, 2018

@ThorstenBux i built your repository, it appears that the various .wasm/.wast files are created in the /build directory, but are loaded from /examples.
The paths can be overridden in artoolkit.debug.js:1540-1548':

var wasmTextFile = 'artoolkit.debug.wast';
var wasmBinaryFile = 'artoolkit.debug.wasm';
var asmjsCodeFile = 'artoolkit.debug.temp.asm.js'; 

I'm still trying to figure out where they're set during compilation, i figure there must be some compile option that allows to specify the actual path you want.

@ThorstenBux
Copy link
Author

@hjeldin Not sure what you are aiming for. Yes the wasm files are build to build directory that is what is configured. And the examples work by running a https server directly from the root directory. So the build directory is accessible to them.

But currently the examples can't successfully load the wasm files afaik?

@ThorstenBux
Copy link
Author

Sorry @hjeldin after some research I found what you mean: emscripten-core/emscripten#5104 digging into that.

@hjeldin
Copy link

hjeldin commented Jul 4, 2018

@ThorstenBux It seems that enabling -s SINGLE_FILE=1 as compile flag results in ~10 MB for debug and a whopping 579KB for the minified version.

I'm currently unable to test since, if i got it right, loading is now async.
I edited artoolkit.api.js in order to dispatch an event to the window object when loaded.
I also needed to postpone the functions binding done in runWhenLoaded() to the postRun callback, otherwise no functions would be loaded. I believe this may also be related to #40 too, since the error is the same.

if (window.Module) {
    window.Module.postRun = function(){
        runWhenLoaded();
        var event = new Event('artoolkit-loaded');
        window.dispatchEvent(event);
    }
} else {
    window.Module = {
        onRuntimeInitialized: function() {
            runWhenLoaded();
        }
    };
}

This fundamentally changes the user workflow, so i can't tell if this is the best option available.
I'm experiencing other issues too, i'll try bumping the version of artoolkit5 you're using to the commit that is currently used in this repository and report back.

@ThorstenBux
Copy link
Author

@hjeldin you are awesome 👍 with your help I've got it working. One second I'll push to a branch including a working example.

@ThorstenBux
Copy link
Author

ThorstenBux commented Jul 4, 2018

see here: https://github.com/ThorstenBux/jsartoolkit5/tree/webassembly-support

example in examples/simple_image_wasm.html

@ThorstenBux
Copy link
Author

ok, I'd say it is working, documented and tests are written. Also opened a PR to pull into upstream and should be there soon. Please have a look and give feedback. I'm closing the issue for now.

ThorstenBux pushed a commit that referenced this issue Jan 21, 2020
Adding NFT examples with WASM and a Worker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants