Why is "Domain Reload" sooo slow, and will this ever be fixed?

EDIT: The Auto Refresh setting was moved from General to Asset Pipeline in Preferences!

Here are some relevant release notes I pulled for version 2021. What’s odd is that I don’t see explicitly where “Auto Refresh” was removed. However, I’m on 2021.3.26 now and I don’t see the option. It looks like it was removed from the manual for 2021.2. From what I gather, there were conflicts between Auto Refresh and the Script Changes While Playing hot reload options There are some hints in these notes however about possible alternate methods of controlling when a domain reload occurs, but it’s not very clear. Reading through the release notes also reminded me of having seen a way to profile your domain reloads to know exactly what is causing them to be slow. I’ll see if I can find more info on that again.

2021.1.0
Known Issues

RESOLUTION NOTE (2021.2.X):
Our teams are actively working at resolving this issue, but because this issue is requiring more work than a single bug fix, we are closing this issue and we will give further updates on this forum thread Improving iteration time on C# script changes
Thank you for your feedback, patience and understanding.

Recent post from that thread: Improving iteration time on C# script changes page-13#post-9131365
Hi there! Since I’m the person who closed it, I wanted to chime in on the discussion around this bug:
Unity Issue Tracker - The creating and import of a new script in Editor became really slow in trunk
We did an investigation for this particular bug and found several issues that have been filed internally with other teams (for example - a source control plugin issue, an issue with Mono performance degrading during an Editor session, and issues with the number of packages and source files included by default with more recent versions of Unity). I’ve then closed this particular bug because the changes necessary to completely fix it are too big for a single bug-fixing task.
All that said, I’d like to emphasize that we are continuing to work on improving iteration time (and this includes ongoing work around CoreCLR). Thank you for being patient with us while we work on it!

Features

  • Asset Import: Reduced cost of domain reloads on asset import worker process by removing unnecessary additional domain reloads.
    Improvements
  • Scripting: Script compilation now has a background task progress bar when auto-refresh is disbled.
    API Changes
  • Scripting: Removed: Previously undocumented EditorUtility.CompileCSharp() is removed. Its functionality can be achieved through the supported AssemblyBuilder class.
    Fixes
  • Package Manager: Fixed an issue where the Package Manager wasn’t applying changes in the project manifest when autorefresh was disabled. (1292471)

2021.1.6
Fixes

  • Asset Pipeline: Objects loaded during import in initial script refresh, are now unloaded. (1296506)

2021.1.9
Fixes

  • Scripting: When environment variable UNITY_DIAG_ENABLE_DOMAIN_RELOAD_TIMINGS is set, write detailed timings on everything happening within domain reloads to the editor logs. (1328820)

2021.1.13
Fixes

  • Asset Pipeline: Fixed for loaded native assets that could get unnecessarily reloaded after a domain reload. (1323425)

2021.2.0
Improvements

  • Asset Pipeline: Added summary in the editor log about what happened during a refresh (import).
    Fixes
  • Asset Pipeline: All domain reloads are now done inside asset db. This fixes problem with reloading of asset objects when doing manual refresh. (1341910)
  • Asset Pipeline: Fixed issue with asset reference getting lost, if asset is modified and domain reload is done in the same refresh. (1357812)
  • Asset Pipeline: Fixed issue with missing domain reload when entering play mode and LockReloadAssemblies is set. (1367222)
  • Asset Pipeline: New version of OnPostProcessAllAssets with didDomainReload parameter added. This callback should be used for domain reload related initialization that requires asset operations such as asset loading. InitializeOnLoad method shouldn’t be used for asset operations, because InitializeOnLoad is called before asset importing is completed. (1274994)
  • Asset Pipeline: Updated reload tests to cover async domain reload.

2021.2.2
Improvements

  • Visual Scripting: Eliminating domain reload cost for users when not using Visual Scripting

2021.2.4
Fixes

  • Asset Pipeline: Fixed a performance regression where projects with large numbers of precompiled assemblies might experience slower import times. (1372980)

2021.2.12
Fixes

  • Editor: Fixed an issue where there was no automatic filter out and ignore assemblies that were automatic included as a part of the system library references. (1363463)

2021.2.13
Improvements

  • Scripting: Improved AssemblyUpdater to not try to connect to VCS unless there assemblies under VCS that needs updating. (1353761)

2021.2.17
Improvements

  • Scripting: Optimized searching for scripts when the assembly name is not supplied, can significantly improve performance entering PlayMode amongst other areas.

2021.3.9
Fixes

  • Asset Pipeline: The option to 'Recompile after finished playing` did not work and has been removed. To support the intended functionallity a new option to only auto refresh outside playmode has been added. (UUM-818)

2021.3.11
Improvements

  • Asset Import: Reduced the time taken by refreshing the asset database, which among other things improves the performance of editing prefabs.

2021.3.12
Fixes

  • Package Manager: Fixed an issue where having packages with a lot of versions increases domain reload time drastically. (UUM-12670)

2021.3.14
Improvements

  • Editor: Reduced the time taken by AssetDatabase.FindAssets when used with a custom filter, speeding up domain reloads and other editor operations that made the poor choice of calling this function in the first place.
  • VFX Graph: Reduced the time taken by VFXGraph.CheckCompilationVersion that would previously potentially query all assets on every domain reload.

2021.3.18
Known Issues

  • Asset - Database: Script recompiles in Play Mode when Script Changes While Playing option is set to Recompile After Finished Playing and Auto refresh is set to enabled. (UUM-20409)
    Improvements
  • Editor: Reduced time to rebuild the CreateAsset(…) menu during a domain reload, it previously was scaling badly for projects with many assemblies.

2021.3.23
Improvements

  • Serialization: Improved performance of restoring managed objects during a domain reload (again!).
  • Serialization: Improved performance of restoring managed objects during a domain reload.

2021.3.24
Improvements

  • Editor: Reduced impact of Shader Graph package on performance of domain reloads by making node class cache populate on-demand.

2021.3.25
Changes

  • Editor: Removed automatic upgrade code for UniversalRendererData from alpha & beta builds of 2021.2 to current as it is no longer required and was incurring a domain reload performance cost.
    Fixes
  • Asset Pipeline: Prevent script re-compilation when ‘Recompile after playmode’ and ‘Auto-refresh’ are set. (UUM-20409)
  • Editor: Objects now keep their non-serializable state when reloaded. (UUM-7785) :eyes:
1 Like