Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Builds taking much longer on 2021.2

Discussion in '2021.2 Beta' started by oobartez, Aug 13, 2021.

  1. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    After upgrading to Unity 2021.2.0b6 standalone builds are taking much longer. Especially subsequent builds seem to recompile everything, including all shaders, even when they haven't changed. Has anyone else seen this behaviour?
     
    futurlab_peterh and kfireven like this.
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    @oobartez please check the Editor log, it should say, how many variants come from the cache and how many are actually compiled.
     
  3. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    @aleksandrk Thanks for replying. So in Editor.log I see lots of entries like these:
    So it looks like they do come from the cache. But our observation is that subsequent builds are now much longer than before, even when we only make a small change in code. I do not recall the build process getting stuck for so long on shader compilation in Unity 2021.1.

    As a side note, the project uses forward rendering, so it's somewhat surprising that Deferred Punctual Light is on the list.
     
    futurlab_peterh and kfireven like this.
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    I'm preparing a PR right now to make things faster when preparing shader compilation.
    Check if you have "Optimize mesh data" enabled in Project settings - turning that off may give you a significant boost.
     
  5. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    I turned off "Optimize Mesh Data" and "Vertex Compression" and the builds now take 77 s instead of 192 s, thank you @aleksandrk!

    It's also good to hear about the upcoming optimization to how shaders are built.

    I noticed that some of our own URP shaders have tens of thousands of "potential variants". Is that a problem or just a standard part of the stripping process? Here's an example:
    While another shader seems to be processed hundreds of times over and over with 0 variants:
     
    Last edited: Aug 13, 2021
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    It's not a big problem - those variants are what the shader declares. If they get stripped to some sane amount (40 in your case is quite sane), then it's not a big deal.
    That's mesh data optimisation.

    I'll let you know when the fix appears in 2021.2.
     
    NotaNaN, Ruchir and oobartez like this.
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    A fix can/will be found in 2022.1.0a7, 2021.2.0b13, 2021.1.22f1.
    2020.3 and 2019.4 to follow - I'll post here when I know the fix versions.
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    The fix will also be available in 2020.3.19f1 and 2019.4.31f1.
     
  9. kfireven

    kfireven

    Joined:
    Oct 18, 2016
    Posts:
    38
    Android build time takes more than 2 hours when 'optimize mesh data' is checked, and only a few minutes when not checked (2021.2.0b12).

    I have just 1 very simple scene, is this normal? If it is, there should be a warning next to it about the build time.
     
  10. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    @kfireven Please check the last two messages above.
     
  11. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Thanks for the info too. My IL2CPP build, with just my playground scene, was taking 5 minutes to build in 2021.1, but then I upgraded to 2021.2.0f1 one or two days ago and the build time went up to 25 minutes... I thought it was just the first build "maybe it couldn't use the previous backup stuff or something", but no, it happened on subsequent builds too. But disabling Mesh Optimization cut the build time to about 3 minutes and a half! That was cool, but still, I hope they fix the issue soon. The increase in build time with that option enabled is way too large... But I will try updating to 1f1 just in case.
     
  12. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,023
    @Alverik the original issue was fixed in 2021.2.0b13, looks like you have something different there.
    Can you please post (or DM me) the Editor log with a long build time?