Unity hangs on open during script compilation

This is driving me nuts.

Every so often, a project that was fine, will just hang when I reopen it. It always seems to get stuck on the script compilation step: “Compiling Scripts: ScriptCompilation: Cs Assembly-CSharp”

Does anyone have any idea why this happens or how to reliably fix/prevent it?

Usually the project was working fine before I close it. There are no script errors. Sometimes it’s after a crash. I’ve tried wiping out the temp folder and Library/ScriptAssemblies. Sometimes even nuked the entire Library folder. Occasionally it starts working again. Sometimes nothing works for a while and after a bunch of attempts it works again.

Currently on Unity 2020.2.9f but it’s happened with many versions and many different projects in the past for a long time.

It really seems like the script compiler is super brittle and doesn’t have any recovery for hanging or exceptions. It’s not infrequent that a simple code change recompilation just crashes the editor entirely.

I’m not going to say that Unity has never crashed, but I don’t think I’ve ever met software that hasn’t crashed ever. But a consistent issue with restarting has never been an issue that I have seen. I can say that I have more issues with Unity on a mac than a PC, but overall not like what you seem to describe.

This is on a Mac, for what it’s worth. The M1 Mac Studio, specifically, but I’ve had it happen on Intel iMac and Mac mini too.

Usually it’s happening on the splash screen during the compilation step, but it just happened in the editor while recompiling for me too. Anecdotally, it doesn’t seem to be using a lot of CPU when it hangs, so maybe a race condition in threading or a mutex lock of some kind. Maybe something is waiting on a condition that never occurs.

It’s not even a crash where there’s a dump I could report with. I’m just left scratching my head at it. ¯_(ツ)_/¯

I met the same issue.Sometimes i can pass script compilation after scripts changed.But most time i failed, unity editor hang on “Compiling Scripts: ScriptCompilation: Csc Assembly-CSharp”,cpu seems not doing any work.Remove script cache in library will fix, but it sucks.

My Env:
MacOS 13.0
Unity 2022.2.7f1 (Intel version)

I have the same problem.Has anyone found a solution yet?

I just started experiencing this recently and the only thing that appears to consistently unblock me is trashing the Library folder and letting it rebuild. There’s probably something specific in there I can delete without having to rebuild the entire project, but I still need to investigate.

FWIW I’m on 2022.3/macOS and suspect it’s related to something in the DOTS suite which I know relies heavily on codegen.

EDIT: This has been happening more and more so I did some digging: deleting Library/Bee appears to force recompilation and unstick whatever was getting stuck, which is faster than deleting the entire Library dir and having to rebuild all assets in all dependencies. I’m sure there’s something more granular inside that Bee folder I can delete, but at this point I’m just trying things out and observing results. Very unscientific. Would appreciate someone at Unity shedding some light on this one.

Bumping this thread because holy hell is this bug annoying. I have to restart Unity every ~15m and delete the Bee folder just to get Unity to open my project. Would love some insight in how to best handle this one.

I’m also facing the same problem, and it’s driving me crazy. Every time I make a code change, I have to exit Unity and delete certain folders in the Library to resolve it.

I am facing the same issue as well in Version 2023.2.2f.

I was having this issue for the whole day (Macbook Air M1, Sonoma 14.2.1, Unity version: 2022.3.15f1), even after updating the project to a more recent version, and deleting the Library folder contents, reinstalling Unity Hub and the Editor, recloning my Git repository, nothing could fix it.
Then I noticed that my Unity project folder was being backed up by iCloud. After I removed it from the directory that was being backed up, I recloned it in a local directory and the project opened normally without any issue. I searched for this fix and found out that OneDrive, GoogleDrive and other cloud sync solutions are causing this issue as well.

Please any fix on that issue ?? i also have it with unity 2022.3…
Can someone from unity team can take action on that problem please…

Something I’ve found extremely effective is to split my project up into smaller assemblies. This appears to make domain reload when recompiling with burst extremely fast as well.

This may require pretty big project architecture changes but highly recommended.

Do still have the issue ?
If no, which workaround have you done ?

I’ve experienced the issue once now in several weeks time, instead of 15 times a day. The workaround is what I’ve just described of splitting my project up into smaller assemblies.

That helped me: I tried to delete the folder, but couldn’t because it was locked by bee_driver.exe (I forget the exact name). I looked at the task manager, killed that process, tried again: Then it was still locked by Unity.ILPP.exe or something!
This time I found half a dozen of those, killed them all: success! project loads now.

I suspect we don’t actually having to delete Library/Bee nor Library/ScriptAssemblies, just killing old zombie processes is probably enough to pass the next launch.

Hi there!
Try this solution Linux editor stuck on loading because of bee_backend w/ workaround
Don’t look at the title of the post about Linux, I am on a m3 mac, and the solution described there solved my problems.

Upd.
It seems like a coincidence, the problem returned the next day. The only solution is to delete the Bee folder.

Deleting library\bee worked for me on Windows. Thank you!

This problem (MAC) usually happens if your project is on icloud, some files get transferred to icloud if unused for some time and when unity try to recompile when it opens it has to wait for the whole thing to get downloaded again. Don’t put your unity project on an icloud or any cloud. Have it local.

Not my case.

sometimes it freezes and the issue resolves when I disconnect the debugger (at least with rider). Often when this happens, the debugger no longer connects and I have to reboot Unity.