Build time taking almost a day - URP

Hi, I am experiencing some weird, extreme long, build time since I got the latest Unity 2021.2.0b1

On the 2021.2.19a I was able to build it in around 10 seconds, and first builds around 3 - 5 minutes.

Since I got the latest, it has been around 15 hours and it is still going.

It seems to be stuck in Compiling Shaders Variants (which, for whatever reason, also compiles the Deferred even though I am just using Forward)

I am making a build for Windows. I am working with Multiplayer, I just wanted to do a fast test on the progress I’ve done.

I’ve worked on massive projects before, thousands of shaders, and the build was around 1 - 3 hours. (There were some PCs that was able to build that in 8 minutes, for unknowing reasons.)

My current project is still in early stages, very small, I am working alone and I deleted almost all shaders in the project.

Not sure if it is a bug or not, but it started at the exact time I updated to the latest version.

Thank you.

1 Like

If you still have it, editor logs of the build process would be helpful

Hi @RenOli ,

Could you please submit a bug report with a reproduction project attached?

1 Like

Hi, any advance in this topic? I have a similar problem in Unity 2021.2.0b13:
The “Compiling shaders” phase is taking a very long time in build, i think it should be a bug because it tries to compile high number of variants as seen in the next image:

7581055--939658--upload_2021-10-18_10-54-21.png

This is not the first try on making a build, but every time I tried in “mono” ended with an “OutOfMemory” error after several hours stuck in “Compiling shaders”.

This last build i’m making now is made in IL2CPP, but the only thing i see is that the build is a bit faster, but still slow for a non massive project, asset folder is only 5.9Gb and there are less than 10 custom shaderGraph-made shaders. Is this any known issue solved in a next patch? Or is it an isolated case, if i need to provide info please tell me what do you need.

Project is now in Unity 2021.2.0b13 using the Universal Render Pipeline.

Thanks in advance

Hi @jaguero_1 ,

Can you please try updating to b16 to see whether it helps with this problem? A couple of fixes and improvements to shader variant stripping and the incremental build pipeline have landed in the last updates.

Hi @LeonhardP , thanks for the advice, but the build is still taking too long so far;

7583794--940093--upload_2021-10-19_8-31-30.png

I let the computer on while it was away, but i don’t know if the hdd tuned off, so i will wait a bit longer to see if it can complete it or if it crashes, if you have any ideas on what can be causing this long times, i will be glad to hear and try any solution

Check your task manager - is Windows Defender running? You might try to add Unity install directory and the project directory from Defender’s ignored directories, as it might be continually scanning all the temp files created by the shader compiler.

Hi @Baste , Windows defender is not running, but i have another antivirus, i don’t know if it is the problem as in task manager all the CPU usage was used by “unity shader compiler”. Anyway, it has ended shading compiling right now, so i will try another build after the build had finished without the antivirus to see if anything changes.

@jaguero_1 Do you have URP asset assigned to your main graphics RP asset? If not, I think the shader preprocessor takes early out and doesn’t strip ANY of your URP shaders (means it will take forever to get them compiled then).

Hi @rz_0lento . Yes, i do have it

I tried “strip unused” and “strip all” and i didn’t notice changes in time.

Actually I’m trying to change the project to an SSD to see if the problem is the HDD.

Well, it crashed again, dont know if having a very small SSD could be the problem

7586956–940594–Editor.log.txt (4.96 MB)

Well, apparently changing to the SSD solved the problem, time now went from 19 hours to less than 30 minutes, don’t know if it could be better, but at least is a reasonable time, besides not having the problem in previous versions, maybe the antivirus overcharged the HDD as @Baste suggested.

Thank you all for the help!

Builds are thousands of tiny files so seek time on a traditional hard drive is the bottleneck rather than data itself. SSDs are good at this. But 30 mins for a build is too much even for a final game. In these scenarios one is best off separating assets that won’t change into asset bundles and then just compiling code becomes the main thing for each build you do - and should take a few minutes at most.

The exception being shaders - these can be a hot mess for compile times but can also be cached if I’m not mistaken, between builds.

Can attest to the last point. On my project the first build after a reimport for Android/iOS takes about an hour (all about those shaders), all subsequent ones are within 5-10 minutes.

This is also happening to me.

My project now takes 2 hour + to build if the shader is changed. Previously this takes around 30 minutes tops.
And every time I switch build target, it’s like all the build cache is cleared that every variant needs to be re-compiled again. HDRP seems normal, only URP is experiencing this issue.

If you’re affected by regressions like this, please submit a bug report with a reproducible attached to it so we can investigate.

Happening to me too. I have tried all the above fixes. Just building the simple construction sample scene takes hours. You guys added A LOT of variant keywords.

1 Like

Hey,

This is reproducible for us as well. Incremental game build went up from a few minutes to closer to 1 hour.
Empty URP example project incremental build: 40 → 102 seconds

Bug report 1383867

4 Likes

Been testing since 2021.2, and all the way up to 2021.2.6f1, super long build times, mostly due to shader stripping I believe. In 2021.2.6f1 particularly, unverified but it seems to have made the build size larger as well.