Builds taking much longer on 2021.2

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?

2 Likes

@oobartez please check the Editor log, it should say, how many variants come from the cache and how many are actually compiled.

@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.

2 Likes

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.

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:

2 Likes

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.

3 Likes

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.

4 Likes

The fix will also be available in 2020.3.19f1 and 2019.4.31f1.

4 Likes

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.

@kfireven Please check the last two messages above.

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.

@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?