Importing of default unlit shader takes more than 80 seconds

Hello,

I’m working on a project where importing of shaders is very slow. What’s surprising is that even if I just create a new default unlit shader, Unity takes up to 80 seconds to import it. The progress bar displays “Re-serializing assets” during that time.
I attached a profiler screenshot which shows how after initially importing the shader, AssetDatabase.V2.Hotreload takes a very long time. It looks like it is for some reason compiling other shaders afterwards and File.Open is called over 9000 times.
I also attached an export of the profiler.

Here’s what I get in the Unity log during an import.

It displays compiler errors of other shaders, for example ‘Universal Render Pipeline/Particles/Lit’. (some buildin shaders of URP are broken right now which is ok for our project.).
Importing in this project is generally slow so it might be that there is something generally wrong with it.
We use a custom AssetPostprocessor that generates Materials from imported textures based on naming conventions, so maybe we mess something up in the asset database?
I know from a Unite Talk (

) that Unity might be keeping track of what assets depend on each other, so it might be that it for some reason thinks that the newly generated shader is connected to (all?) other shaders.

Interestingly enough, after reimporting the entire project importing shaders works faster, (around 20 seconds for a simple unlit shader), but over time, it takes longer and longer. Also, it’s a 30 GB project, so I can’t just reimport all the time.

Does anyone have an idea how one would go about debugging this. Since there is nothing in the log I don’t really know how to approach this problem.

Best regards,
Henning


6629197–755818–ShaderImportProfilingData.7z (8.1 MB)

1 Like

Just in case somebody else has this problem: It looks like it is caused by the Cache Server. If I disable it, shader importing takes the time you’d expect. So for now our workaround is that the people who frequently edit shaders disable Cache Server. I will check if it’s fixed in the current Unity version and report a bug if not

1 Like