WebGL: WebAssembly and Feature Roadmap

June 18, 2015 in Technology

Yesterday, engineers from Google, Microsoft and Mozilla (makers of Chrome, Edge and Firefox) announced that they are working on a new cross-browser technology called WebAssembly. This is very exciting news, as this will greatly help improve the Unity WebGL experience.

Although it is technically defined as a new, independent standard, from our perspective, WebAssembly is essentially a bytecode format for the asm.js JavaScript subset (asm.js is used to deploy Unity code to WebGL). Compared to the currently used text-based representation, the bytecode format is significantly reducing the size footprint of code compiled to asm.js. This leads to faster downloads of code, and, more importantly, to being able to parse and compile the code much faster and using much less memory. This will improve the startup times of large compiled JavaScript codebases, and reduce their memory requirements — both of which are currently some of the more common issues developers face when targeting the WebGL platform.

We plan to switch Unity WebGL to output WebAssembly bytecode once the feature becomes available in browser releases. On browsers which don’t natively support the feature, the bytecode can very efficiently be translated to text-based asm.js code using JavaScript – which in most cases still results in faster content load times due to the download time improvements.

Experimenting with a prototype WebAssembly format on a build of our AngryBots demo, we saw the size of the generated JavaScript code go from 19.0 MB of asm.js code (gzip-compressed to 4.1 MB) down to 6.3 MB of WebAssembly code (gzip-compressed to 3.0 MB). This means that the amount of data the browser needs to process gets reduced by 3.0x, and the compressed download size gets reduced by 1.4x. Actual results may change based on the project used, but we expect to see very relevant improvements to anyone caring about WebGL deployment in Unity.

For more information on WebAssembly, see the FAQ here.

In light of this announcement, we would like to give further updates on the current status of our WebGL efforts, and on ecosystem changes we expect to happen over the next year — and on things we plan to be working on, which includes further build size improvements, SIMD.js, Shared Array Buffers (which bring threading support to JavaScript) and WebGL 2.0. So, I’d like to invite you to check out and discuss our WebGL Roadmap forum post, which has a lot of additional information.

If you are at Unite Europe in Amsterdam next week, check out my WebGL talk on Wednesday, or visit me at the hands-on labs to ask questions.

Comments (23)

Subscribe to comments
  1. Regan Music

    August 4, 2015 at 12:52 am / 

    As excited as I am about WebGL, it’s just not a viable platform to export to at the moment for web playable games. I will continue to use Unity Web Player as my weapon of choice because I’ve had TONNES of issues with WebGL builds that I just don’t get when using the unity web player.

    A short list of problems I experienced while building last night.

    – Not all the usual post effects are supported (ambient occlusion).
    – Generally slower frame rate for NO bloody reason.
    – Alpha is handled HORRIBLY, almost would have to cut the use of particle effects. or fade-in tweens.
    – I get an uninvited doppler effect on all my sound even when i make damn sure that doppler is disabled!
    – I had to download a special media package from microsoft just so my sound files wouldnt get lost when compiling for WebGL.
    – Bump sliders are ignored, if you have a normal or bump map, your only choice is to have it at FULL BUMP!

    So I decided to build to Unity Web Player instead and just deal with the fact that ppl cant play the game on chrome.

    I’m really looking forward to the future of WebGL, but right now I’m scratching it from my list of options.

  2. Super Duper

    July 12, 2015 at 12:13 am / 

    Do you guys and gals envision a webassembly based plugin architecture? I think that could add so many possibilities. Maybe it would be neat if you could get a bunch of players using the Oculus Rift inside of a sound studio where everyone is playing an instrument. You wouldn’t need to worry if everyone has the right platform and you wouldn’t be limited to managed code. I imagine Webassembly Plugins could connect Unity3D to a vast ecosystem of webassembly code that the rest of the web has access to, and that could make Unity3D more “web like”.

  3. Ash Blue

    June 23, 2015 at 1:20 am / 

    Our game playadnc.com was exporting a file so large for WebGL, it crashed the browser while loading. Anything that can reduce file size is a huge step forward for the WebGL compiler.

  4. Glauber

    June 22, 2015 at 1:13 pm / 

    That’s awesome! I hope this could improve anyway the compilation time for Unity editor too. It takes ages to produce a WebGL build nowadays…

  5. iulian

    June 19, 2015 at 11:08 pm / 

    How long will take to have WebAssemblies usable in practice, easy to work with, and effectively working at least on Chrome and Firefox ? I need this solution yesterday. I have planned and developed on last few months a complex project Unity WebPlayer based. My project looks completely unusable on the light of recent NPAPI changes. I am forced to switch to WebGL or to a similar solution in terms of 2-3 weeks.

  6. hcetiner

    June 19, 2015 at 6:26 pm / 

    please no microsoft. they first have to fix IE :D

  7. hcetiner

    June 19, 2015 at 6:26 pm / 

    please no microsoft. they first hafe to fix IE :D

  8. Daniel

    June 19, 2015 at 11:51 am / 

    This is great news! Well done to everyone working on this fantastic technology.

    Are there any plans to support UnityAds / Everyplay in WebGL to be run within your game rather than having to run ads within the page?

  9. dusho

    June 19, 2015 at 7:23 am / 

    Hm.. WebAssemblies as byte code.. Is it possible then even to skip JavaScript (C# -> C++ -> JavaScript) and go directly .NET -> WebAssemblies ? Should be possible with new .NET Core and Roslyn being fully open, right

    1. Jonas Echterhoff

      June 19, 2015 at 1:42 pm / 

      I expect that eventually, emscripten will directly output WebAssembly, and not emit JS first and convert that.

      1. dj

        June 19, 2015 at 6:50 pm / 

        I need a cut scene so what can I do

  10. Devang

    June 19, 2015 at 6:38 am / 

    Impressive! Looking forward to those WebAssemblies!!!

    Big thanks!!!!

  11. koblavi

    June 18, 2015 at 9:05 pm / 

    That’s awesome news. It’s great that all the vendors came together (for once) to adopt this standard and decided to put developers first instead of their egos! Did’t see apple & opera listed though, but then again I’m not surprised.

    The last post about NPAPI’s exit the the way forward with WebGL sounded more grim than promising. But with this new announcement, most of the issues regarding WebGL will be sorted!

    Timelines? When do we get to preview this? Unity 5.2?

    1. Jonas Echterhoff

      June 18, 2015 at 9:37 pm / 

      As for Apple: Apple typically does not openly communicate their plans. WebKit does have an open bug on it filed by an Apple engineer. Interpret into that what you will: https://bugs.webkit.org/show_bug.cgi?id=146064

      As for timelines: For WebAssembly, definitely not 5.2, or 5.3 for that matter. It is already very hard to predict when we get our own stuff ready to ship. It’s much harder for multiple third party vendors.

  12. Ben BearFish

    June 18, 2015 at 8:20 pm / 

    Does anyone know if this includes Internet Explorer? I know Edge and the other browsers are the future, but it’d be nice if IE was supported for a unified experience when developing for the browsers.

    1. Sean

      June 18, 2015 at 8:59 pm / 

      I wonder if MS is a bit in limbo with this since they’re working on Spartan. Maybe they won’t be adding new features to IE after W10 release.

      1. Haim

        June 18, 2015 at 9:09 pm / 

        microsoft is not supporting explorer and in development of Edge (formaly known as spartan), as written in the first paragraph of this article.

    2. m_gol

      June 18, 2015 at 11:14 pm / 

      IE is dead. IE11 will receive security fixes for a looong time but that’s about it. All new development goes into Edge, IE is frozen for eternity.

  13. Onsterion

    June 18, 2015 at 6:36 pm / 

    Awesome!!!!!! +10

  14. Ben

    June 18, 2015 at 6:12 pm / 

    Well this is super-exciting news! One big question : what’s the ETA? Are we looking at months or years for WebAssembly to roll out in browsers/Unity?

  15. Dave Voyles

    June 18, 2015 at 5:07 pm / 

    I love that Unity continues to adopt and implement the latest web features. Makes the life of us web devs much easier, but also forces the browser creators to continue to evolve.

    As much as 3x improvement in size? That’s incredible. And the power you get from WebGL (and specifically asm) is staggering. With WebGL 2.0 in the future I’m confident we’ll continue to close the game between native vs. web performance.

    Keep doing what you’re doing Unity, love it.

  16. Thrawn

    June 18, 2015 at 11:51 am / 

    Impressive! Looking forward to those WebAssemblies!!!

  17. Dylan

    June 18, 2015 at 9:53 am / 

    Awesome!

Comments are closed.