Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

WebGL build is slow

Discussion in 'Web' started by JanetEscGames, Oct 22, 2018.

  1. JanetEscGames

    JanetEscGames

    Joined:
    May 2, 2018
    Posts:
    5
    It seems to take 6 minutes to build a simple game for WebGL on my MacBook Pro. A build for MacOS takes about 10 seconds. This make it very slow to debug issues that only happen on the WebGL build. The various build options seem to do nothing.
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    Welcome to the world of Unity WebGL development :eek:

    The only things I have found to help are making your code base smaller, stripping out managed engine features like physics, and getting a faster computer.
     
    Shizola likes this.
  3. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    173
    40-45 minutes for EMPTY project! Without assets, one new empty scene... A build for Win, Android < 1-2 minutes!
    For a project placed on RAMdisk assembly time is reduced to 15-20 minutes.
    And at the stage of "compiling asm.js" computer it becomes completely inoperative - the buttons do not react to the mouse cursor, even the clock in Win is no longer updated!

    Unity 2017.4.14f1 (all other earlier version - same problem)
    Win7, i7-2670QM CPU 2.20GHz 4Gb RAM
    -And All Everything(!) except this WebGLassembly - works great!
    But WebGL target build - is @#$^& !!! :mad:
    :(

    Since the rejection of the webplayer there is no way to publish in the WWW !
    And it has been going on for years ...
    It's all just disgusting.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, it's slow, and no, there's not much you can do about it. It a Rube Goldberg contraption that compiles things to other things in multiple steps before finally ending up as Javascript, and frankly I'm impressed it works at all. ;)

    There's something seriously messed up with your computer. An empty project takes 1 minute 5 seconds to build for WebGL here, same build for macOS is like 2 seconds. There's no way a standalone empty scene build should be taking you minutes. Maybe it's the relatively small amount of RAM you have.

    --Eric
     
  5. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    Standalone Win
    * Mono - 10 seconds
    * IL2CPP - 3 min 50 sec

    WebGL
    * first time - 4 min
    then even below one minute.

    i7 2600k with 8GB ram (win7 64bit)
    Unity 2018.1.9f1 (64-bit)
     
  6. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    I have 64 gb ram and an AMD 3900X and it builds really fast for UWP, but for WebGL it takes literally over 10 minutes using every core.
     
    EvOne likes this.
  7. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    This is a known issue. We are working on improving compilation times for Unity 2021.2 release, which should hopefully get things comparable to other platforms.
     
  8. EvOne

    EvOne

    Joined:
    Jan 29, 2016
    Posts:
    173
    Prior to the transition to WebAssembly, the project compilation under the WebGL took 45 minutes on my computer...
    -just an empty project
    Sometimes the compilation has also completed the error.
    Everything hung up, the interface buttons were not pressed, even the clock was stopped in the taskbar...

    "It will be fun, they said" (c) Bruce :D

    Now it 12-15min. But I have only 4GB RAM here and before your comment, I thought the problem is only in this.
    But ... 64gb! And the same compilation time? :eek:

    -"Something is rotten in the state of Denmark" (c) W. Shakespeare, ‘Hamlet’ :D
     
    Last edited: Feb 24, 2021
    vakter23 likes this.
  9. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    just as another data point for you - I have one of the fastest desktop CPUs, a Ryzen 5990X (12 cores/24 threads) and 32GB ram. My build time is about 5 minutes for a medium sized webgl project. The current webgl compilation pipeline in Unity barely utilizes multiple cores.

    The current build process is largely single threaded and is not hugely memory intensive, so the problem is less than the process is inherently slow and more that 1) it’s not utilizing all available resources/cores and 2) there are many extra compilation stages vs other build targets (e.g why not go from IL to WebAssembly directly instead of via c++, emscripten, asm.js etc)

    Sounds like the unity team is well aware of these limitations and I’m excited for the upcoming releases that will streamline the process and speed up the remaining parts.
     
    EvOne likes this.
  10. MangoFusion

    MangoFusion

    Joined:
    Jan 15, 2020
    Posts:
    2
    My build times are currently well over 10 minutes on a fairly simple project with a 2019 MacBook Pro.

    I remain somewhat skeptical on 2021.2 given the apparent lack of progress on this issue within the past 3 years for what would presumably be an important market segment for Unity. That and my unity window just hanged again for 10 seconds....
     
  11. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    I had a weird occurrence of building in less than a minute. It happened exactly once. A glitch in the Matrix or is there something related to cache?
     
  12. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    if you don't modify any code (e.g. just modify variables visually with the inspector), Unity should not need to rebuild the whole IL2CPP codebase, which is the majority of the time spent during compilation. easy enough to experiment to see if that's what was happening
     
    Nyanpas likes this.
  13. MarkPocock

    MarkPocock

    Joined:
    Jun 18, 2019
    Posts:
    3
    What's the progress with this? I am on 2021.2.0b1 and what used to take 25-30 mins in 2020.3 with the same settings now takes over 2 hours o_O, its frustrating to say the least...
     
    Nyanpas and EvOne like this.
  14. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Also echoing the above post. I upgraded to the latest 2021 recently yet somehow WebGL-builds are seemingly taking even more time than they used to? I didn't change anything in the build settings from 2020.
     
  15. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,882
    First time build is always too slow
    4 minutes for a complete game (a parking game with 2 scenes) on the Ryzen 5 3600xt and a ssd drive
    30 seconds for the next time build
     
  16. Nyanpas

    Nyanpas

    Joined:
    Dec 29, 2016
    Posts:
    406
    Doesn't happen here for some reason. I'm on a Ryzen 3900X.