Anyone else having the editor forever beachballing on play ?

The short version: Everything seems to work just fine until I press “play”. Then I stare at a beachball until I hard terminate Unity. No error messages or actually any messages in the console.
The only thing I see is that it produces AssetImportWorker log files in the Logs folder. No error messages in them. But it creates plenty of them, right now its up to 23, with 3-4 new ones per minute.

Unity support can’t reproduce it. I can with high reliability. Might be machine specific. I’m now having this in the second project of mine. I’ve already deleted the Library folder. This is a project I’ve been working on for two years, so it’s not like it’s new or something. This started happening recently.
Very simple scenes (like my main menu, which has only UI elements) work. Of the 3D scenes I’ve tried so far, none have worked.

MacOS 10.14
Rest of the system continues working. Unity process is showing 70-99% CPU activity on one core while this happens, the activity monitor marks it red as “doesn’t react”.

I’m asking if anyone else has had this or similar problems and what, if anything, solved it for you.

Sounds like you have an endless loop somewhere in code that runs when you load a 3D scene.

Unity will lock up 100% of the time EVERY millisecond your scripting code is running.

Nothing will render, no input will be processed, no Debug.Log() will come out, no GameObjects or transforms will appear to update.

Absolutely NOTHING will happen… until your code either:

  • returns from whatever function it is running

  • yields from whatever coroutine it is running

As long as your code is looping, Unity isn’t going to do even a single frame of change. Nothing.

No exceptions.

“Yield early, yield often, yield like your game depends on it… it does!” - Kurt Dekker

Beyond that, start bisecting:

Delete ALL the code, see if the 3D scene still locks up.

If it does, then it’s not the code.

If it runs, restore all the code and destroy HALF of it.

lather rinse, repeat.

Keep in mind the lockup might be in your Packages too, so try removing all packages while you’re ransacking things.

I haven’t changed any code since last it worked. And I am very, very certain that I don’t have any endless loops that would run anywhere. Yes, it looks like an endless loop, but it’s not in my code.

Solving this with trial-and-error is going to be one hell of a joyride, because every time it happens I need to force-quit and completely reload the project, which by itself takes a few minutes.

How long would it take (particularly compared to making another post on the forum saying it would take too long) to delete every single CS file in your project and launch the 3D scene?

Obviously I’m assuming you use source control correctly. I take this as a given to actually do software engineering.

$ find -f . | grep \.cs$ > allcsfiles.txt

I’ve checked my own code, of course. If nothing else works I’ll go over it with a comb. But like I said, this is the 2nd project of mine this happened to, the projects share no code.

Note: Why would I DELETE my scripts when I can just selectively disable the game objects they’re attached to? tsk.

I’m curious how you plan to disable GameObjects when you cannot open the scene.

You also might want to read about Editor scripts and also about the InitializeOnLoad and RuntimeInitializeOnLoad attributes.

EDIT: oh yeah, also all the OnEnable/OnDisable, etc. noise that can run on non-MonoBehaviours

There’s many ways code can be run.

Attach a debugger to Unity and pause execution from the debugger while it is frozen. Then check where in the call stack the main thread is in Unity. You may find it is in your code (or maybe not).

I can open the scene. I cannot PLAY the scene.

Well aware of that. I use very few editor scripts.

facepalm of course. Why I didn’t think of that? Thanks. The most obvious solution and I just didn’t consider it.

Did some debugging yesterday and found the problem in the init between two assets. Classic deadlock.

1 Like