- Home /
Build hang on compiling scripts in Unity 2018.2
Since we upgraded to Unity 2018.2.11f1 from 2017.4 we're getting random hangs in our automated build process. The hang seems to mostly occur after a successful build when Unity is reimporting scripts. This stops the unity process ending and therefore hangs our automated build setup. I have a workaround in python to manually kill the process if it thinks this has happened, but its still very annoying and adds time to our build turn around. We're running a python build script that runs unity via batchmode on a TeamCity server build machine on our network.
We are consistently seeing that Unity 2018.3 hangs while building our project in batchmode as well as on UCB. It completely breaks our pipeline but Unity seem O$$anonymous$$ with it. Highly frustrating.
Answer by LukeFireproof · Sep 16, 2021 at 01:44 PM
Hi! This was a while ago and I've had loads of issues with similar thing since but I think the was ultimately down to the cache server failing silently. So if you're using that I'd recommend either switching it off or swithing to the new v2 cache server which seems much better for build stuff. Python-wise all I did was check if the editor log had any new input and if it didn't in minutes I'd kill the process and try again.
I also run KillUnityRelatedProcesses() before and after a build run to clean up any leftover processes. It's all a huge pile of hacks but it works most of the time now!
def KillUnityRelatedProcesses():
KillVBCS()
KillUnity()
KillUnityShaderCompiler()
def KillVBCS():
KillProcess("VBCSCompiler.exe", True)
def KillUnity():
KillProcess("Unity.exe", True)
def KillUnityShaderCompiler():
KillProcess("UnityShaderCompiler.exe", True)
def KillProcess(processName, recursiveKill = False, killcount = 0):
if GetArgs().allowKillProcesses != 1:
return
if killcount > 99:
return
else:
if killcount > 0:
time.sleep(0.5)
tasks = os.popen('tasklist').read()
if processName in tasks:
print("Killing process: " + processName)
try:
os.system("taskkill /F /im %s" % processName)
if recursiveKill:
KillProcess(processName, True, killcount + 1)
except WindowsError as e:
print("Coudn't kill process %s. Error: %s" % (processName, e))
This is perfect, it solved my problem as well. It's kinda hacky but yes it does get the job done, it seems to be the only way to get rid of this problem. Thank you so much buddy, really appreciate it : )
No problem man. I know how infuriating these problems can be!
Answer by visualtaggy · Sep 13, 2021 at 04:58 PM
@ LukeFireproof can you please help me by telling how you used python to estimate the process is over and terminate it? I am having the same problem :(