Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

"Compile WebAssembly Module" build process briefly freezes computer on every build attempt

Discussion in 'WebGL' started by BradyIrv, Nov 24, 2018.

  1. BradyIrv

    BradyIrv

    Joined:
    Jan 16, 2018
    Posts:
    12
    Has anyone ever experienced temporary system freezing when building for WebGL platform using Unity 2018, I've tried building on both 5.3f1 / 14.3f1 Engine versions. To clarify, the builds complete successfully, however my system freezes consistently and builds take longer than I believe they should.

    My keyboard's RGB and input, open browsers/Youtube and mouse will all freeze for a few seconds. Then repeatedly freeze another couple times during every attempt to build. This is consistent with my Laptop and my rig, as well as across multiple project attempts both small and large. Additionally, build times exceed 5-10 minutes for projects as small as 3 scripts (with minimal code), 1 scene, and 30 images.

    In my rig I have a GTX 1080, i7-6700K @4.0GHz, m.2 ssd for my OS, 1tb ssd for my software... so it's not a matter of hardware. I only experience this issue with WebGL for 2018 and have not tried other versions of Unity. I am aware that WebAssembly underwent changes in the crossover from 2017-2018 and I'm curious if anyone else has experienced this issue / if anyone found a fix.
     

    Attached Files:

    adnanzmn97 likes this.
  2. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    This is because one of the last steps in the WebAssembly build process is completely multi-threaded which actually makes the WebAssembly build part incredibly fast. The side-effect is that all your CPU cores being maxed out can result in your system momentarily being unresponsive - this doesn't mean the build process is slower than it could be.

    If system responsiveness is something you're really after in exchange for slightly longer build times you could manually tweak either the process priority or the process affinity of asm2wasm.exe, although generally I find the process doesn't take more than 20 seconds or so on a full project.

    WebGL builds are unfortunately expected to be long, most of the time is spent during the IL2CPP process - for faster iterative builds you can do a few things like building development builds instead. Having said that, a practically "empty project" doesn't take more than around 90 seconds for me to compile with the same CPU. One thing that reduce your build times is excluding your Unity projects from your virus scanner as Unity has documented here (Optimizing IL2CPP Build times) - regardless of using SSDs or an I7 CPU, this can be quite noticeable.
     
    SearchTree, adnanzmn97 and BradyIrv like this.
  3. BradyIrv

    BradyIrv

    Joined:
    Jan 16, 2018
    Posts:
    12
    Thank you for the information, I will look into the information you've provided and also consider a CPU switch to something like an AMD Ryzen series to handle a heavier workload.
     
  4. UMT_Cats_Eye

    UMT_Cats_Eye

    Joined:
    Oct 12, 2020
    Posts:
    3
    i experience the same issue and i am on a Mac Mojave. Do i need to change my computer to a stronger type or do i wait it out while it give the the spinning wheel of death for 100 hours.
     
  5. UMT_Cats_Eye

    UMT_Cats_Eye

    Joined:
    Oct 12, 2020
    Posts:
    3
    Below is what it says for me
     

    Attached Files:

  6. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    940
    It is unfortunately a known issue that build times to WebGL can be slow. We are looking for ways to speed things up, but there are no immediate wins to be had to improve this.

    Currently when iterating on builds, disabling compression and doing a Development build should be a little bit faster to finish a build.

    In the current Unity version (2020.2 and older in case someone is reading this in the future), you can also try doing an asm.js build for iteration, by setting the C# build pref

    PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Asm;

    That may speed up the build a little. You can try out the attached build script to quickly test that out. See the instructions inside the file. In the future we are migrating to a different compiler backend that will drop asm.js support, so that advice will then no longer hold.
     

    Attached Files:

    unnanego likes this.
  7. RamblingCoder

    RamblingCoder

    Joined:
    Jul 13, 2013
    Posts:
    16
    I have the same issue if I use the default webGL template. If I change to the minimal template then it completes the webAssembly step in under a second. Go back to the default template and it takes 15-20 minutes. I am running on a fast PC with a Samsung EVO 960 Nvme drive, so it has nothing to do with the speed of my drive.

    Anyone have any suggestions on how to get this to perform better? 20 minutes is a LONG time to complete the final step for webGL.
     
    unnanego likes this.
  8. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    188
    I haven't found any solutions so far. And I'm not using the default template at all(
     
  9. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    832
    This is completely random for me on 2019.4

    Sometimes it takes seconds, sometimes it takes about 15 minutes, same scene and same scripts.

    Is there a way to make it more reliable? @jukka_j
     
  10. GamerFawn

    GamerFawn

    Joined:
    Sep 6, 2020
    Posts:
    2
    Same problem here. I'm not sure if it's stuck or if it's just taking a very long time.
     
  11. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Anti-virus can be triggered by file access and creation processes adding to the build overhead.
    • Most AVs allow you to exclude folders which can allow you to get the AV to ignore the build process executables e.g. ignore the Unity folder.
    • Or you could watch the process and add the executables used in the build process, I think there are quite a few programs and python scripts involved.
    Other things to consider for speed: RAM utilisation, CPU thread counts and speed of project SSD.

    Look on the bright side the DirectStorage API should be out later this year and could turbo charge NVMe SSD access times, in theory ideal for building/loading/saving your game files.
     
    Last edited: Jan 4, 2021
  12. RamblingCoder

    RamblingCoder

    Joined:
    Jul 13, 2013
    Posts:
    16
    It isn't my anti-virus software. I can disable it entirely and it still behaves this way. But if I switch to a minimal webGL template it finishes almost instantly.
     
  13. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    940
    I believe if you see these "it completes almost instantly", it is because you did not actually do any changes to C# code. If there are no scripts to be rebuilt, then the build pipeline skips building any code (which is the slow part atm), and only assembles the assets and code together.

    See this thread https://forum.unity.com/threads/webgl-builds-are-completely-unusable.961341/ for a bit more information on the roadmap.
     
    enhawk likes this.
  14. Deleted User

    Deleted User

    Guest

    The heck, im tryna do that on my intel i3 pc rip
     
  15. BradyIrv

    BradyIrv

    Joined:
    Jan 16, 2018
    Posts:
    12
    If you're not building on Unity 2018 it's most likely irrelevant since there has been so my iterations of the Editor since this post.