- Home /
Why does unity keep hanging when run through the command line?
I have been using the fairly new Unity Test Tools to write tests for one of our features and while it works when running through the GUI in unity, I have been running into issues when triggering this through the command line for automation purposes using Jenkins.
Everything seems to be going ok until it gets to the end, at which point it hangs at the following point:
Writing results to file...
Batchmode quit successfully invoked - shutting down!
System memory in use before: 0.86 GB.
Unloading 1 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)
System memory in use after: 0.86 GB.
Unloading 0 unused Assets to reduce memory usage. Loaded Objects now: 859.
Total: 7.906044 ms (FindLiveObjects: 0.039674 ms CreateObjectMapping: 0.042262 ms MarkObjects: 5.027706 ms DeleteObjects: 0.012314 ms)
Refresh, detecting if any assets need to be imported or removed ... 0.006445 seconds (Nothing changed)
Cleanup mono
This only seems to happen at random times, more often when I’m running our larger test suite. Any suggestions you have to help diagnose this problem would be great.
Happens to me now also when running a build from command line. Or specifically through Jenkins.
Answer by Dave-Hampson · Apr 22, 2015 at 09:59 AM
If you have -quit on the command line then this sounds like a bug
Some guidelines for submitting bugs are here: http://answers.unity3d.com/questions/578888/how-can-i-report-a-bug-most-effectively.html
(As a workaround, kill the Unity process)
edit Is it ADB.EXE which is blocking shutdown?
Answer by jiguangdongyu · Oct 19, 2016 at 08:59 AM
I have faces this problem because I run wrong command line "-excuteMethod", not "executeMethod"...
Answer by tudonca · Aug 01, 2019 at 02:40 PM
I had the same issue on Unity 2018.4
I was able to fix this by manually calling AssetDatabase.Refresh() at the end of my build script, before Unity initiates the batchmode shutdown.
Answer by Ryu8179 · Oct 29, 2021 at 11:48 AM
I had the same problem with Unity 2021.2.0b8. adb.exe
was blocking it. (I confirmed that killing the adb.exe
process from Task Manager solved the hang tentatively.)
In my case, I was running UnityBuild from a Windows batch file and had a problem with Cleanup mono
hanging when running UnityBuild in the scope of setlocal enabledelayedexpansion ~ endlocal
as shown below.
PlayerBuild.bat
setlocal enabledelayedexpansion
.
. other code
.
"C:\UnityEditor\2021.2.0b8\Editor\Unity.exe" -batchmode -buildTarget Android -quit -logFile - -projectPath %WORKSPACE% -executeMethod JenkinsBuild.Build
.
. other code
.
endlocal
Removing setlocal enabledelayedexpansion ~ endlocal
solved this problem.
Answer by aimatme · Dec 14, 2021 at 02:51 PM
Same problem (hangs at the cleanup mono) with Unity 2021.2.6 in Windows Editor batchmode with -quit
adb.exe is in process list, but I cant solve the problem with described solutions