WebAssembly: how to pack a Unity WebGL export in WebAssembly (and load it in Chrome 57)?

Hi,

I try to test the current progress of the WebAssembly feature, testing the potential gain on my project.

Browsing through the Web, I have not been able to confirm if it is actually possible to do it right now.

Chrome 57 (canary) offers the possibility to enable the flag for it, but I imagine the Unity’s exported .js is not yet a WebAssembly package, right ?

Thanks by advance for your help,

Yvan

A .js is not a WebAssembly file, no.

But the Unity 5.6 beta has experimental support for WebAssembly, which you can enable in WebGL publishing settings.

Thank you for the answer ! I will test it right now.

Juste export it with Unity 5.6 beta and the right setting, enable the flag in Chromium, and it should work ? Any other step ?

Hi,

I get this error:

[ERROR] Failed running “C:\Program Files\Unity 5.6.0b4\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\python.exe” “C:\Program Files\Unity 5.6.0b4\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc” @“F:\PortfolioViewer_Unity5.6Beta\Assets..\Temp\emcc_arguments.resp”

stdout:
stderr:WARNING:root:–separate-asm works best when compiling to HTML. otherwise, you must yourself load the ‘.asm.js’ file that is emitted separately, and must do so before loading the main ‘.js` file
warning: unexpected number of arguments 4 in call to ‘_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv’, should be 0
warning: unexpected number of arguments 4 in call to ‘_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv’, should be 0
warning: unexpected number of arguments 2 in call to ‘_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv’, should be 0
warning: unexpected number of arguments 3 in call to ‘_ZN6il2cpp6icalls8mscorlib6System6String22RedirectToCreateStringEv’, should be 0
warning: unresolved symbol: glGetInternalformativwarning: unresolved symbol: _ZN4FMOD13DSPConnection6setMixEfwarning: unresolved symbol: glUnmapBufferwarning: unresolved symbol: glMapBufferRangewarning: unresolved symbol: glFlushMappedBufferRangeTraceback (most recent call last):
File “C:\Program Files\Unity 5.6.0b4\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc”, line 13, in
emcc.run()
File “C:\Program Files\Unity 5.6.0b4\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emcc.py”, line 2029, in run
subprocess.check_call(cmd, stdout=open(wasm_text_target, ‘w’))
File “C:\Program Files\Unity 5.6.0b4\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_Win\python\2.7.5.3_64bit\lib\subprocess.py”, line 542, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[u’C:\Program Files\Unity 5.6.0b4\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_FastComp_Win\binaryen\bin\asm2wasm’, ‘F:\PortfolioViewer_Unity5.6Beta\Temp\StagingArea\Data\linkresult_wasm\build.asm.js’, ‘–total-memory=268435456’, ‘-O3’, ‘–mem-init=F:\PortfolioViewer_Unity5.6Beta\Temp\StagingArea\Data\linkresult_wasm\build.js.mem’, ‘–mem-base=1024’, ‘–wasm-only’]’ returned non-zero exit status 3

Any lead ?

Thanks

Please note that the issue happens with these options:

BuildOptions.Development
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.Full;
PlayerSettings.WebGL.debugSymbols = true;
PlayerSettings.stripEngineCode = true;
PlayerSettings.WebGL.analyzeBuildSize = false;
PlayerSettings.WebGL.memorySize = 256;
PlayerSettings.WebGL.dataCaching = true;

But not when changing to:

NO BuildOptions.Development activated
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.None;

This may be a bug. Could you submit a bug report with a repro case, and post the case number here?

Thanks

Will do.

Case number: 872541

Developer builds ran for me in both Nightly and Canary, but normal builds did not. Then normal builds just stopped building at all. Still pretty fragile, but super encouraging that it’s there at all now. Very hopeful.

Thanks for the bug report!
We identified the problem and we are hoping to get it fixed by the time 5.6 is released.

Howdy! This bug looks super similar to the problem I’m having. From what you learned from this one can you see what might be causing me problems still in 5.6.0b7?

The fix has not landed to 5.6 yet, sorry for the delay.

It took longer than expected but the fix is in 5.6 beta11 now.