Constant, incessant"Reload Script Assemblies" - Program crashing, hanging

Yes. Empty clean project in 2021. Hit Play. “Reload Script Assemblies”. Makes Unity unusable wth!?

Yep using 2020.3.23f1 and I dread switching back to editor. Am I going to have to find something else to do for 60+ seconds before I can continue? Like maybe go on the forums and complain about this issue? My project is barely even a mini tech demo yet, this isn’t a problem caused by how much scripts or content I have there is some bug or poorly thought out code causing this problem, it was fine in 2019 for the same project.

I’m using Rider, but I haven’t used any custom asmdef in this project yet. It seems to be worse if I have Rider connected to Unity when I switch back, but I can’t be sure. Either way its not acceptable for Unity to let any external tool break the workflow like this, the dialog should be cancel-able or non-blocking.

Pulled this from the logs, not particularly useful…

RefreshProfiler: Total: 39.834ms
- Completed reload, in 145.454 seconds
Domain Reload Profiling:
    ReloadAssembly (145455ms)
        BeginReloadAssembly (143866ms)
            ExecutionOrderSort (0ms)
            DisableScriptedObjects (36ms)
            BackupInstance (0ms)
            ReleaseScriptingObjects (0ms)
            CreateAndSetChildDomain (142ms)
        EndReloadAssembly (1548ms)
            LoadAssemblies (143695ms)
            RebuildTransferFunctionScriptingTraits (0ms)
            SetupTypeCache (154ms)
            ReleaseScriptCaches (1ms)
            RebuildScriptCaches (83ms)
            SetupLoadedEditorAssemblies (568ms)
                LogAssemblyErrors (0ms)
                InitializePlatformSupportModulesInManaged (4ms)
                SetLoadedEditorAssemblies (0ms)
                RefreshPlugins (1ms)
                BeforeProcessingInitializeOnLoad (112ms)
                ProcessInitializeOnLoadAttributes (441ms)
                ProcessInitializeOnLoadMethodAttributes (7ms)
                AfterProcessingInitializeOnLoad (3ms)
                EditorAssembliesLoaded (0ms)
            ExecutionOrderSort2 (0ms)
            AwakeInstancesAfterBackupRestoration (411ms)

I’m so much used now to getting these “Reload Script Assemblies” that it feels normal… Using 2021.1.0a16.

Are you using Rider? I think I have managed to track my issue down to having Rider attached to the editor. I can reproduce the freeze pretty reliably I think.

No, I’m not.

Disable Directory Monitoring in Editor Preferences, in 2019 to 2020 unity versions this is incurring Package Manager script and assembly reloads regardless of changes. Flagging this off in my personal project reduced my compile times from 36~ seconds to near instant and my work project’s compile times were reduced by about 4.5x.

With Domain and Scene compilation reloading disabled and sub assemblies for all code in my project, I’m nearly ecstatic that Unity is actually FAST ( read: near instant ) for the first time in ever.

2 Likes

Thanks but I cannot find this in the preferences, where is it?

I am on 2020.3.21f1 LTS, but I know in future versions of Unity they’ve removed both Auto Refresh and Directory Monitoring from here. However you can access either from their Editor Preferences values:

m_AutoRefresh = EditorPrefs.GetBool("kAutoRefresh");
m_DirectoryMonitoring = EditorPrefs.GetBool("DirectoryMonitoring", true);
5 Likes

Thanks! I’m bookmarking the script for further investigation. :slight_smile:

I added MySQL.Data.dll to my project. If I don’t close the connection or a reader then the second time I run in the editor it will hang and be endlessly reloading assembly. If I make sure everything gets closed then it is good. Just took awhile to figure that out.

1 Like

i am the same of your case… and i don’t know why it cost more and more times to reload the script even click the play button in editor…that’s make me crazy!!!

i don’t got this setting in unity2021.2.6f1…

I tried and override:

private void ReadAssetImportPreferences ()
{
    m_DirectoryMonitoring = EditorPrefs.GetBool ("DirectoryMonitoring", true);
}

but I can’t: it’s private and, as far as I know, there is no way to make it accessible from outside, is there?

1 Like

Same here with Unity 2022.1.0b2 and VSCode, so this seems not Rider-specific.
Setting the preferences via UnityEditor.EditorPrefs.SetBool ( … ) didn’t help (even though those prefs were initially set to true) but that might be pre-existing values from the older version.

Is there anything we can do, like reporting a bug for this issue?

2 Likes

This happens when pressing play on an empty project and an empty scene in Unity 2021.2.7f1
I tried making a URP and BIRP project but they both are afflicted by incessant Rebuild Script Assemblies.

1 Like

These two values are in the Asset Pipeline category now.

2 Likes

Really? I’ll have to take a look then!
Thanks for the tip!

Edit: Indeed! But disabling “Directory Monitoring” is only for Windows right now…

7785420--982845--Capture d’écran_2022-01-06_17-46-12.jpg

1 Like

thats not solving the problem its passing to another version

2 Likes

Just wanted to drop in here and say +1… facing the same issues noted above. Also, as already noted, this is a major drain on productivity.

@ For what it’s worth… performance, especially of the core iterative loop of “edit code” → “test said code”, is insanely high priority for me as a user and customer of Unity.

Examples:

I just duplicated a material in the hierarchy view, selected material press Ctrl + D. It took nearly 50 seconds.

Updating menu items… 3s
Resolving packages… 42s
Then some menu and view refresh stuff

5 Likes

On my current project I often have to move the Unity editor between my main monitor and my second monitor.
Every time I do this, Unity does the “Reload Script Assemblies” thing! It’s infuriating.