Search Unity

WebGL Roadmap

Discussion in 'Web' started by jonas-echterhoff, Jun 18, 2015.

Thread Status:
Not open for further replies.
  1. devsquid

    devsquid

    Joined:
    Dec 16, 2013
    Posts:
    3
    Hey Jonas, it seems like currently Unity3D's WebGL output results in a large JS file (no offense, I'm glad you guys are tackling WebGL for your engine). I am curious what you guys see as the eventual output size of the engine alone? What if I don't take advantage of many of Unity3D's built in systems. What is the expected time frame to get to that size?

    Thank you, I am trying to choose a framework for a future project and this is important to it. :)
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Before getting into more detail on this subject (which has been frequently been discussed on this forum), did you read this manual page: http://docs.unity3d.com/Manual/webgl-building.html ? Are you looking at the size of the Compressed folder only?
     
  3. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    197
    Jonas, Is there any progress in the amount of memory - ?
     
  4. devsquid

    devsquid

    Joined:
    Dec 16, 2013
    Posts:
    3
    Yes I have. By pre-compression do you mean gzip or like the closure compiler. I would be interested in pre-gzip post closure compiler... I understand that size has been discuss, but I am curious what your target size of the JS output of your engine is. (not what it is today, but what your team is realistically shooting for)

    I saw mentioned you are considering breaking your Engine into modules. I imagine thats quite an undertaking, but there could be a lot of real benefit to that. Is that a serious consideration or just speculation?
     
  5. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Why do you care about pre-gzip sizes? In the end, you should host gzip, so that should be the size that concerns you. As for realistic build sizes: We've been able to get a minimal Spinning Cube project down to a 1.2 MB download at a Hack Week. This is the total gzipped size for code & data (ie, everything which is downloaded). This was a HackWeek project and cutting many corners, which would not be realistic for shipping. I think 2 MB gzipped for a minimal project is a more realistic goal right now (though i would love to get below that eventually).

    This is actually not just a consideration, but what we are shipping right now. Unity will strip out modules not used (such as Physics, Particles, Animation, Audio, etc). There are some things where we can probably get better at splitting more code off into modules, but the more important thing right now is to give users information on what is being stripped in their project and how, so that people actually have tools to analyze and optimize builds for size. We have specific plans for this, and some groundwork has been done, but I currently don't expect anything of this to ship before 5.4.
     
    jcarpay likes this.
  6. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    That sounds promising!
     
  7. devsquid

    devsquid

    Joined:
    Dec 16, 2013
    Posts:
    3
    Yes of course you should host gziped and closure compiled JS. However i'm curious about the pre-gzipped file to better help me compare it against other engines and to get an idea about its RAM consumption.

    So assuming the gzip compression is around 50% you guys are shooting for the base engine to be around 3mbs. Thats pretty good to hear! Thank you.

    I understand this is new territory and the Unity3D engine does a ton. So I don't want to be disparaging here. But that is still to large for my use case. The project is a fairly minimal 2d game and we are shooting for around maybe 1.5mb max pre-gzipped JS file. (honestly we imagine we can get it easily below 1mb) I really like the Unity3D game engine and I think 3mbs for a WYSIWYG 3D game engine is pretty impressive.

    Thanks :)
     
  8. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    197
    Onsterion likes this.
  9. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    471
    Will these errors ever get fixed:
    http://forum.unity3d.com/threads/we...dll-unityengine-rendering-sphericalha.282003/
    As well as the fact that all WebGL builds are always displayed as Development Builds

    This is a big issue for us, and we've been waiting for a fix for this for over half a year now.
    I've filed a bugreport back then but have gotten no reply whatsoever, and it seems like nothing has changed since then.
     
  10. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Uhm. The error in the forum post you quoted was from a 5.0 beta build, and has been fixed later in the 5.0 beta ages ago. "All builds being displayed as Development builds" - this is the first time I hear of this. What is the case number of your bug report?
     
  11. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    471
    Case 701377
    http://fogbugz.unity3d.com/default.asp?701377_e6mr4ma7vsni7rbg

    I was aware it was a bug in a beta build, but I was not aware it was supposed to be fixed, as these forum threads ended without anyone mentioning it being fixed. That explains though why no one complained about it anymore.
     
    Last edited: Aug 25, 2015
  12. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    That bug report has no repro project and steps, and no explanation of what is actually wrong ("WebGL builds always behave as Development Builds" does not tell me how they behave "as a Development build", and how they should behave instead).
     
  13. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    471
    It's as if the checkbox "Development Build" is ignored, and it simply always builds a Development Build:
    In the build it displays "Development Build" in the right-bottom corner, and it logs all errors, which are the 2 errors mentioned in the thread I linked to:
    • Unable to find type [UnityEngine.dll]UnityEngine.Rendering.SphericalHarmonicsL2
    • Unable to find type [UnityEngine.dll]UnityEngine.SharedBetweenAnimatorsAttribute
    I didn't add a project back then, as it was my understanding back then that it was a universal problem with the WebGL build.
     
  14. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    As I wrote, these errors have been fixed in the 5.0 final release. Also, I have never heard of the "Development Build" switch not working. Are you using the latest version of Unity? Also, did you try using Build & Run (to make sure you are testing the right set of build results)?
     
  15. Steven-1

    Steven-1

    Joined:
    Sep 11, 2010
    Posts:
    471
    I've created a new project and updated everything from the asset server. I no longer have these problems, there are other problems but they seem unrelated. (It's likely that these new problems are my own fault, so I think everything is ok)
     
  16. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    197
    but... starting loading is still very heavy((.. my game can't run on 32bit on a Chrome(only Mozilla).
    Unity 5.2 will be out by 8th September. Are we see some good news about webGL?
     
    Last edited: Aug 28, 2015
    jonkuze likes this.
  17. diegopit

    diegopit

    Joined:
    Aug 29, 2015
    Posts:
    4
    Hi,

    Same question here. Are we going to see some improvements in version 5.2?

    Thank you,
    Diego
     
  18. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    https://unity3d.com/unity/beta
    There might be some that I missed.
     
  19. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    197
    Looks a very optimistic, but a direct question: Will webGL work on 32 bit browsers(Can we run an AngryBots as example) - ?
     
  20. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Why don't you test it? The release candidates are already available.
     
  21. vivekjha

    vivekjha

    Joined:
    Apr 16, 2015
    Posts:
    2
    We are making our game on unity 5.1.1f1 for webgl platform and our demo product is ready. It works fine on the desktop browsers but the only problem we have is running it on mobile browsers and we really need it to run on mobile browsers.
    Our game is a complete 2D game, and we tried running it on mobile browsers, but the game just loads the first scene and freezes.
    So, I am in real need of any kind of help which can make it run on mobile browsers. I have seen html5 webgl games now running in mobile browsers, so I guess unity's webgl games can also run on mobile browsers.
     
  22. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    If it didn't work before it will probably not work with 5.2. There are no magic bullets in this release.
    There are some memory related changes planned for 5.3 but these too will not solve all problems of the memory issue.
     
  23. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    As mentioned in several places already we don't support mobile browsers yet. Some lightweight games can run and maybe even some Unity ones but the browsers/JS and the hardware are just not there there for <every> Unity game to just work out of the box.
     
  24. frodoe7

    frodoe7

    Joined:
    Jul 25, 2014
    Posts:
    37
    me too
    I am also suffering from the WebGl game size after building it
    I made totally empty project with one empty scene , and it`s size reaches 120 MB !!
    it`s impossible for games production
    I avoided this platform because of this issue
    if there`s any way to fix it , it will be good !
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I find that hard to believe, since an empty scene here builds to 14.6MB uncompressed/2.7MB compressed. The size is a little on the large size, yes, but nowhere near what you're saying.

    --Eric
     
  26. vivekjha

    vivekjha

    Joined:
    Apr 16, 2015
    Posts:
    2
    Thanks for replying.

    So, any advice on what should we do now, as we cannot just wait for the technology to upgrade. Ofcourse we can just launch our demo product for the desktop version only but for the mobile browsers can we do anything? except for making it as a store app.
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you can't wait for WebGL on mobile to become viable, then the only other option is to use what's available now. So you answered your own question.

    --Eric
     
    Schubkraft and vivekjha like this.
  28. frodoe7

    frodoe7

    Joined:
    Jul 25, 2014
    Posts:
    37
    I am working on Unity 5.0 version
    maybe , you solved this issue with the upcoming releases
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Well, there's no point complaining about that when using a version that's so out of date. Update to the latest, especially with something like WebGL that gets a lot of development. Anyway, still no, for an empty scene with Unity 5.0, it generates 18.9 uncompressed/3.5MB compressed, which is worse than newer versions but still nothing like 120MB.

    --Eric
     
  30. frodoe7

    frodoe7

    Joined:
    Jul 25, 2014
    Posts:
    37
    I built empty project with one empty scene in a folder called "webGLGame"
    and it`s size : 133 MB
    the "webGLGame" folder consists of 3 folders (Compressed , Release , TemplateData) and 2 files (.htaccess , index.html)
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's not relevant since you only look at one folder. i.e., what is the Release folder? The Compressed folder? Since one of those is all anyone actually loads. (And ideally you would just use the Compressed folder for distribution.) You don't load everything. And again, using 5.0 is pointless. Use 5.1.3, or 5.2 when it's released in a few days.

    --Eric
     
    arumiat likes this.
  32. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    I'm not sure if this was asked already, so sorry if it was, but I'd like to know if Unity uses some optimized JS port of box2d or if the b2d it uses for web deployment is converted from the native code along with the rest of the engine. Thanks in advance.
     
  33. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    It is converted from native code along with the rest of the engine.
     
  34. Lockethane

    Lockethane

    Joined:
    Sep 15, 2013
    Posts:
    114
    @jonas echterhoff Any more updates/ guestimates on browser timelines on the features like webgl2 or web assembly?
     
  35. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    223
    I believe WebGL2 is included in 5.2's builds - but not yet fully supported by any major browser. WebAssembly I can't imagine coming in the next 6 months.
     
  36. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    For WebGL 2.0, Both Firefox and Chrome have experimental support in their nightly builds these days, but disabled by default (and Unity has experimental support starting in 5.2, also disabled by default). So you can test it now (please file bugs), but I'd expect at least half a year (quite possibly longer) before seeing this enabled in release browser builds. MS has it listed as "Under Consideration" on https://dev.modern.ie/platform/status/webgl20/. Apple, who knows? :)

    CORRECTION: Actually experimental WebGL 2.0 support in Firefox has already reached release builds. You can turn it on in about:flags. No need to use a Nightly build.

    WebAssembly does not have any testable implementations I know of yet. I'd expect to see some previewable builds around GDC next year, maybe.

    For Shared Array Buffers (making threads work in JS), both Firefox and Chrome have experimental builds which support the feature (I believe Firefox has it in their nightlies). I'd expect Unity to start supporting this feature in 5.4. (Edit 2016: This will definitely not be in 5.4!)

    SIMD.js is also testable in Firefox and Chrome nightly builds AFAIK. The problem with that, is that we won't be able to support it with a common code base, so we'd have to let you make separate builds to run on SIMD.js enabled browsers and non-SIMD.js enabled browsers, which is somewhat annoying. Not sure when we will start offering such an option, possibly 5.4.
     
    Last edited: Mar 24, 2016
    kenshin likes this.
  37. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Thank you Jonas!
    This post is very useful to understand realistically the current situation :)
     
  38. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    223
    Could you generate the SIMD.js alongside the other JS, and just load the right file depending on the browser as part of a single build?

    Secondary question - the Unity Engine parts of the JS are probably going to be fairly commonly loaded; some big JS libraries (e.g. jQuery) have a single web-wide CDN variant in Google's Hosted Libraries, so they're always in the browsers cache and minimise download time.

    Could you modularise the outputted JS file, so you can keep the Unity engine components in a seperate JS (perhaps one for each major chunk of functionality that's normally handled by stripping?) - then look at a similar hosted solution - so users who access unity webgl content frequently, have the common bits cached between sites?
     
  39. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Yes. Are you ok with builds taking twice as long? :)

    This is a very frequently asked question. We could. I doubt it would have any of the benefits you hope in practice, as you would lose the benefits of stripping engine code which is not needed, and to actually benefit from caching, two pieces of content would have to be built with the exact same build of Unity (which, given weekly patch releases is unlikely).
     
  40. AFrisby

    AFrisby

    Joined:
    Apr 14, 2010
    Posts:
    223
    Yep, they already take 30 minutes for me. I go and grab lunch while waiting.

    Could you get stripping back by combining multiple files? E.g. "unity.core.js" + "unity.physics.3d.js" is what's downloaded in a simple physics game.
     
  41. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Partially, yes. But there is an overhead to splitting stuff into separate files and calling between them, which grows the more files we have. And we currently do stripping on a class granularity, not only a module granularity. Ie, we strip the code for "WheelCollider" if you don't use it, not just all of physics.
     
    AFrisby likes this.
  42. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Personally, and I believe most users are with me on this, if we could count that the final product is going to reflect exactly or at least very closely what we see on the editor, then the build time doesn't really matter that much. At the moment WebGL is mostly PCs, so you don't need to have an actual build to test it properly like on mobile (provided you can rely on the results from the editor). Performance is more important than a few minutes imho; specially because from my tests, it only works good on Firefox. Even though I didn't manage to see 'only' a 50% drop in performance, the real life results in my case were much worse than that. On Chrome it's like 10% the speed of native binary (win 7 64 here). Perhaps my system needs a cleanup or something, because generally Chrome is faster than Firefox on most JS/HTML5 (if we can trust on the benchmarks from the interwebs). Anyway, just my opinion.
     
  43. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    Recently I noticed reduced performance in WebGL on Chrome vs Firefox which really annoys me because the main reason for the switch to WebGL in the first place is because of Chrome. All the while Firefox is kicking it's ass in performance. All browser Gamers should just abandon Chrome and go Firefox. Mozilla seems to care more about the browser gaming user base than Chrome anyway.
     
    AlanGameDev likes this.
  44. Lockethane

    Lockethane

    Joined:
    Sep 15, 2013
    Posts:
    114
    Thanks for the update. It's unfortunate that so many pieces out of your guys hands have such longs timelines.
     
  45. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Hehe, another reason is we could keep using the plugin until webgl is ready to rock :). Chrome blocked the plugin (effectively for at least 90% of the users) and webgl sucks on it, so there's no good alternative to make your games playable on it. Missing the flash target? Hehe, just kidding :). They should at least make it easier for the users to activate the plugins, like a question on top bar or something, but it seems that in the future you won't be able to activate them at all.
     
    jonkuze likes this.
  46. StealThePixels

    StealThePixels

    Joined:
    Apr 2, 2015
    Posts:
    68
    Hi guys, suppose i want to ship a free game, monetized by ads, and pretty large in size (over 300 MB ).
    We already plan to deploy on Android, iOS, Windows Phone and Windows 8/10 (Windows Store) which support ads and let you install the game just once, without the need to load it from the network each time.

    But we want to deploy for Windows Vista/7 and Mac as well, and in this case, building as PC/Mac standalone is not an option because ad networks don't accept that format.
    So for those platforms the only option is WebGL via browser.
    In a WebGL game we can put ads either in-game and/or around it in the web page.
    The problem is size...

    Is there the possibility for the user to "install" a WebGL game just once, like you do for mobile games?
    After it is installed, the game would be loaded from local but i still want it to require internet connection to play, expecially for the ads to work but also for multiplayer matches.
    The user should be required to visit the game's webpage to play, but the game is loaded from local cache or install folder.

    Is that possible?
    Thanks
     
  47. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    You can use the local browser storage for caching some if your stuff but it is not very big and the size also varies between different browsers.
    You can get around that by using Asset Bundles a lot so the player gets to the menu/start pretty fast and then you load what is needed to play after that.
     
  48. Mr-Tsunami

    Mr-Tsunami

    Joined:
    Jul 15, 2015
    Posts:
    21
    How can one close webgl app and free resources?
    Application.Quit() isn't working. Removing canvas just hides scene. Setting Module.noExitRuntime = false and calling Module.exit(0) freezes firefox.
    _emscripten_cancel_main_loop() seems just pauses the loop with no memory freed.
     
    Last edited: Sep 27, 2015
  49. Mr-Tsunami

    Mr-Tsunami

    Joined:
    Jul 15, 2015
    Posts:
    21
    Also have to admit - what a pain in the arse this webgl publishing process! Just updated from 5.1.3 to 5.2.1 and unity doesn't see my JS functions anymore. Did you guys somehow change the scope of emscripten or what? Looks like Application.ExternalCall can execute only global functions now.
     
    Last edited: Sep 28, 2015
  50. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Then please report a bug with a repro project and ping the number here.

    And please make new threads for issues and use this one for roadmap related discussions only.
     
Thread Status:
Not open for further replies.