Hi,
I started getting crashes in Unity editor 2022.3.39f1 on entering play mode, here is the last part of editor-prev.log after a crash. It seems to happen randomly in 5-10%
crash.txt (14.2 KB)
I didn’t add any new plugin lately to cause this behaviour compared to previous period of work on the same project.
Please ask for any further details i could provide.
Crashes, errors, etc., are 99% of the time user error!
It is most likely you wrote a script with a bug.
And that mean it is…
Time to start debugging!!! Here is how you can begin your exciting new debugging adventures!
Debugging can allow you to get all the information you need to discover what the problem is. Once you actually know the problem, only then will you be able to create a solution…
The most coming issue that happens is one of the following:
- the code you think is running isn’t
- the code is running sooner or later than you think
- the code is running less or more often than you think
- the code is running somewhere else than you think it is
- you haven’t look at the previous errors or warnings in the console
To help gain more insight into your problem, I recommend literally sprinkling Debug.Log() statements everywhere near the source of the problem to display all the information in realtime.
“When in doubt, Debug.log it out!"
Hi, and thank you for your feedback,
but it’s not related to our code, it wasn’t changed, nor the plugins added or modified.
Now I got a crash purely on double clicking another scene file to open within unity editor, before even entering the play mode.
Editor-prev.txt (44.4 KB)
Update: the case gets even more weird:
We have 3 scenes, let’s call them A, B1 and B2
If I open the project on scene A:
a) If I open the scene B1 and then B2, all works fine
b) If I open the scene B2 from A directly, editor crashes
You can learn a lot just by looking at the top of the stacktrace that is last logged:
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at UnityEditor.AssetDatabase:OpenAsset <0x000f6>
...
You can see in both instances the crash is somewhere within the AssetDatabase as it tries to “open” an asset file. That’s telling something already.
I can imagine a few things that might cause this:
- corrupt files in Library (close project, delete Library folder, wait till complete, try again)
- using AssetDatabase methods in runtime code (that’s a no-no yet it happens in the editor)
- having a broken/corrupted asset in your project
- antivirus (these are always suspect, more so if they are 3rd party)
Try making a build. This should point out any script errors related to UnityEditor API used in runtime code. But it can’t catch all of these if they are properly enclosed with #if UNITY_EDITOR
.
If there are no obvious candidates, divide and conquer. Make a copy of the project and start stripping down scenes until the crash goes away to narrow down potential candidates.
Hi CodeSmile,
thank you for your feedback.
- The project builds without issues.
- I’ve tried to delete library folder and rebuild the project - didn’t help.
- I am not using AssetDatabase in runtime code / I am using it within #if UNITY_EDITOR many years
- I am using only Windows Defender.
Update:
I narrowed it down to one canvas’ game object being enabled in the saved scene
if that game object is enabled and scene saved, from A opening scene B2 - crash
if that game object is disabled and scene saved, from A opening scene B2 - no crash
(that object is enabled by code in play mode and used with dynamic ui elements)
just delete the culprit gameobject and recreate it.
maybe you are lucky and it works.
if it doesn’t work then create a new empty scene, copy all the stuff from the scene that has issues.
maybe you are lucky and it works.
off course first check the code. if it crashes the entire editor is probably because there is an infinite loop or something like that. those usually will kill both unity and unreal from my experience.
Still, I need to double-check. Just for example, this would execute the AssetDatabase method at runtime in the editor:
void Awake()
{
#if UNITY_EDITOR
AssetDatabase.AnyMethod(); // illegal runtime call of AssetDatabase method!
#endif
}
At most such use should be limited to OnValidate or similar editor-only MonoBehaviour messages. Ideally prefer to use Editor(Window) or similar editor-only classes to make calls to AssetDatabase. Post your code if you are unsure if your code may run at runtime.