Time spent waiting on entering playmode is a waste and can seriously hinder iteration times.
In an empty project it already is ~1.5s for no appearant reason. In larger projects (Ori and the blind Forest) it got upwards of 20 seconds, up to a whole minute in extreme cases.
The profiler can give some very rudimentary understanding of what's happening here. An empty project looks like this:
The ReloadAssemblies routine obviously is the main offender. The DockArea.OnGUI seems to come from the inspector re-creating and re-caching some stuff.
Digging in to the ReloadAssemblies:
Again it seems that a lot of editor systems here are just busy recreating and re-caching editor related data. ModuleManager is an outlier in that.
This get's worse and worse as project scale increases. Here's a sample from a level of Ori and the blind Forest:
Note: The numbers don't make a lot of sense anymore. I think the profiler doesn't display stuff over 10.000 ms well? Actual playmode time was about 19 seconds.
The biggest standouts are
-Serialize / Deserialize backups takes up the majority of the time. I can only guess what this does, but I assume that this applies unsaved settings from the editor to the new runtime objects. That feels like a really bad way to go about it - the scene didn't have any changes. Unity already keeps track of changes since last save - could it not just reapply those? This is basically doubling play mode times right now
-RebuildScriptCaches: again more cache rebuilding on every playmode for no reason. In a large project like this it's up to almost a second (!)
-SetLoadedEditorAssemblies seems to have increased with project size too
Other issues like the ModuleManager and such are of course also still there.
All in all, this is wasting a lot of time for every developer. The main takeaway is two things:
1. There needs a way to have some caches survive playmode, and not be recreated everytime.
2. The way playmode state is created should be reconsidered, the current way doesn't scale
I really hope UT can improve this.
Thanks for taking a look!