When I first open my project I can enter play mode in a couple of seconds, but at some point, that time spikes and it takes longer than before for every time I press Play until I restart Unity. Once starts happening it happens even if I’m just playing a new Empty scene without doing any changes at all. I used the Profiler and I tracked that it seems to get stuck in:
SpriteAtlasManager.OnEnterPlayModePreAwake > Write asset changes to disk.
I also noticed that sometimes if in the middle of this I create a new empty scene and I press Play it runs immediately, but if I just stop it and Play it again it does the same thing, taking up to a minute.
Does anybody know what might be happening and how to solve it?
Thank you very much
Here I leave attach a screenshot of the profiler of Entering Play Mode on an empty scene.
I found that it does a similar thing just sometimes when I save a scene, no matter how minimal the change in the scene is. Here is a screenshot of that profile
Using 2020 LTS over a bunch of minor versions, this issue caused me so much time loss. my project took 4 minutes to save or play or even exit unity. i finally profiled it and came to the same result as this thread. I then disabled the SpritePacker which ‘fixed’ this issue.
Edit > Project Settings > Editor > Sprite Packing Mode. either disable this or set it to build only. (not always).
(this is a hacky work around for something that should be working)
Does this still happen? Can you repro this problem AND supply a native stack trace?
I put together a guide on how to do that here: Debugging Editor freezes and hangs [Windows Only]
If the editor is stuck a long time doing something, and there’s no good info from the profiler, the native stack trace could help us figure out if it is indeed a mutex or something else that’s taking a really long time.