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

Add option 'wasm' to compile to WebAssembly in web export #6994

Merged
merged 1 commit into from
Oct 31, 2016

Conversation

leonkrause
Copy link
Contributor

@leonkrause leonkrause commented Oct 31, 2016

e.g. scons p=javascript wasm=yes

WebAssembly is experimental, so disabled by default.
The standard is still in flux, so the compile toolchain is occasionally broken.
Compiling for WebAssembly requires the incoming-branch of Emscripten.
Running WebAssembly requires nightly browser builds with WebAssembly flag enabled.

If LLVM_ROOT in ~/.emscripten is set to Emscripten's "fastcomp" fork of clang, Godot will be compiled per asm2wasm (i.e. first compile to asm.js as usual, then translate that to wasm). This method of compilation currently has better chances of finishing successfully.
If LLVM_ROOT points to clang built with experimental WebAssembly backend (-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly), the output will be translated per s2wasm to WebAssembly. This method should eventually offer better performance.

The HTML shell file now uses $GODOT_BASE, a placeholder for the base filename, instead of $GODOT_JS, $GODOT_MEM and $GODOT_FS.

WebAssembly is still experimental, so disabled by default.

The HTML shell file now uses $GODOT_BASE, a placeholder for the
base filename, instead of $GODOT_JS, $GODOT_MEM and $GODOT_FS.
@reduz
Copy link
Member

reduz commented Oct 31, 2016

This is fantastic, I am going to start spending more time on webassembly in 2 months (and html5 backend in general), did you manage to try godot in wasm mode? How did you find it performs (and loads?)

@@ -351,24 +351,7 @@
};
};
//]]></script>
<script type="text/javascript" src="$GODOT_FS"></script>
<script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Emscripten now inserts this piece of code in place of the {{ SCRIPT }} placeholder at compile-time, because we pass the --shell-file argument to the linker. This code was so far hard-coded, but for WebAssembly we need different code here, so we leave it to Emscripten.

@akien-mga akien-mga merged commit 681575f into godotengine:master Oct 31, 2016
@leonkrause
Copy link
Contributor Author

did you manage to try godot in wasm mode? How did you find it performs (and loads?)

Answered this on IRC, but for everyone else interested in my experience so far:

  • Only managed to compile per asm2wasm
  • Seems faster than asm.js
  • No new bugs identified so far
  • Loading time after download is about 10s, hoping for a speedup here
  • .wasm binary size is 13.7MB when compiled per asm2wasm

@leonkrause leonkrause deleted the wasm branch October 31, 2016 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants