- Home /
Other - Issue resolved, and post isn't even past moderation yet anyway.
Native debugging
I've been getting an annoying issue on my project where the game suddenly permanently freezes. It occurs at random times and I haven't been able to find the specific part of code that is causing it. It's a spaceship game and by heavily increasing the number of spaceships spawned, I find that the freeze occurs a lot quicker. Usually it happens randomly (like after a few minutes of letting the game run) but when there's lots of spaceships it happens after 5-10 seconds of running the game.
The freeze occurs both when running in Unity editor with or without profiler and when "Build and Run"-ing.
I've already gone through my code base to look for possible while-loops that could be getting stuck etc. Usually those are easily found by pausing VisualStudio when attached to Unity, but in this case I end up with "No compatible code found", indicating that we're getting stuck somewhere in Unity's native code.
I've been trying to follow the steps in this thread https://forum.unity.com/threads/usererror-how-to-find-your-infinite-loop.378384/ but after attaching to the Unity.exe process and pausing execution, I am getting stuff like "object.c not found" / "mini-runtime.c not found" etc.
And Watching on "mono.dll!mono_pmip((void*)0x0d51f480);" gives "Module mono.dll not found."
Can anyone help me on debugging the issue?
EDIT: After some searching, I've found that the files VS was asking for are in the installation location of Unity, in my case C:\Program Files\Unity\Editor\Data\ So that's a step ahead.
Now I've got the following stacktrace:
0000024503e881b5() Unknown 00000245042bf543() Unknown 0000024503e96553() Unknown 0000024503e93934() Unknown 0000024503e93b20() Unknown mono-2.0-bdwgc.dll!mono_jit_runtime_invoke(_MonoMethod method, void obj, void params, _MonoObject exc, _MonoError error) Line 2809 C mono-2.0-bdwgc.dll!do_runtime_invoke(_MonoMethod method, void obj, void params, _MonoObject exc, _MonoError error) Line 2921 C [Inline Frame] mono-2.0-bdwgc.dll!mono_runtime_try_invoke( MonoMethod ) Line 3026 C mono-2.0-bdwgc.dll!mono_runtime_invoke(_MonoMethod method, void obj, void params, _MonoObject exc) Line 2968 C Unity.exe!scripting_method_invoke(class ScriptingMethodPtr,class ScriptingObjectPtr,struct ScriptingArguments &,class ScriptingExceptionPtr ,bool) Unknown Unity.exe!ScriptingInvocation::Invoke(class ScriptingExceptionPtr ,bool) Unknown Unity.exe!Coroutine::Run(bool ) Unknown Unity.exe!Coroutine::ContinueCoroutine(class Object ,void ) Unknown Unity.exe!DelayedCallManager::Update(int) Unknown Unity.exe!`InitPlayerLoopCallbacks'::`2'::UpdateScriptRunDelayedDynamicFrameRateRegistrator::Forward() Unknown Unity.exe!ExecutePlayerLoop(struct NativePlayerLoopSystem ) Unknown Unity.exe!ExecutePlayerLoop(struct NativePlayerLoopSystem ) Unknown Unity.exe!PlayerLoop(void) Unknown Unity.exe!PlayerLoopController::UpdateScene(bool) Unknown Unity.exe!Application::TickTimer(void) Unknown Unity.exe!MainMessageLoop() Unknown Unity.exe!WinMain() Unknown Unity.exe!_scrt_common_main_seh() Unknown kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown It seems the freeze issue is coming from Coroutines? My game relies heavily on Coroutines and I've heard that Unity's Coroutines are quite fragile. Could it be that my freeze issue is due to my usage of Coroutines to control flow? And that would explain why it occurs more when there are a lot more spaceships in the scene, as that would mean a lot more coroutines happening. Any advice?Unity.exe!Random_Get_Custom_PropValue(void) Unknown