Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Unity switches to WebAssembly as the output format for the Unity WebGL build target

Save for later
  • 2 min read
  • 16 Aug 2018

article-image

With the launch of Unity 2018.2 release last month, Unity is finally making the switch to WebAssembly as their output format for the Unity WebGL build target. WebAssembly support was first teased in Unity 5.6 as an experimental feature. Unity 2018.1 marked the removal of the experimental label. And finally in 2018.2, Web Assembly replaces asm.js as the default linker target.

unity-switches-to-webassembly-as-the-output-format-for-the-unity-webgl-build-target-img-0

Source: Unity Blog


WebAssembly replaced asm.js because it is faster, smaller and more memory-efficient, which are all pain points of the Unity WebGL export.

A WebAssembly file is a binary file (which is a more compact way to deliver code), as opposed to asm.js, which is text. In addition, code modules that have already been compiled can be stored into an IndexedDB cache, resulting in a really fast startup when reloading the same content. In WebAssembly, the code size for an empty project is ~12% smaller or ~18% if 3D physics is included.

unity-switches-to-webassembly-as-the-output-format-for-the-unity-webgl-build-target-img-1

Source: Unity Blog


WebAssembly also has its own instruction set. In Development builds, it adds more precise error-detection in arithmetic operations. In non-development builds, this kind of detection of arithmetic errors is masked, so the user experience is not affected.

Asm.js added a restriction on the size of the Unity Heap; its size had to be specified at build-time and could never change. WebAssembly enables the Unity Heap size to grow at runtime, which lets Unity content memory-usage exceed the initial heap size.

Unity is now working on multi-threading support, which will initially be released as an experimental feature and will be limited to internal native threads (no C# threads yet).

Debugging hasn’t got any better. While browsers have begun to provide WebAssembly debugging in their devtools suites, these debuggers do not yet scale well to Unity3D sizes of content.

What’s next to come


Unity is still working on new features and optimizations to improve startup times and performance:

  • Asynchronous instantiation
  • Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at $19.99/month. Cancel anytime
  • Structured cloning, which allows compiled WebAssembly to be cached in the browser
  • Baseline and tiered compilation, to speed-up instantiation
  • Streaming instantiation to compile Assembly code while downloading it
  • Multi-Threading


You can read the full details on the Unity Blog.

Unity 2018.2: Unity release for this year second time in a row!

GitHub for Unity 1.0 is here with Git LFS and file locking support

What you should know about Unity 2018 Interface