I have developed a tower defense game. When I export the game and run it, the game sometimes freezes when loading levels, with the GPU usage reaching 100%. Subsequently, the computer freezes and becomes unresponsive, requiring a restart.
I can’t find the reason because it only occurs occasionally. Typically, it appears during the first export run after I make changes to the content, and then it runs normally afterwards.
The same situation applies to the game I sent to my friends, and I believe it’s the same for players who purchased my game, hence the high refund rate.
I have tried multiple versions of Godot, but the situation remains the same.
I’m just puzzled why it sometimes freezes and sometimes doesn’t. It’s hard for me to reproduce the issue, making it extremely difficult to troubleshoot
I think it has something to do with exporting, because I have never experienced any freezing issues when running the level scene in the editor.
I used this plugin to obfuscate the code, and I’m not sure if it’s related
What I’m wondering is, if somewhere in the code (like, say, map_custom.map_init()) there’s a loop that can become endless if it gets the wrong random value.
“Occasionally the CPU goes to 100% and it freezes forever.” sounds to me like it’s spinning in a loop and the exit condition for that loop is never firing. If it only happens sometimes, it’s probably a specific value that does it, and a random number generator or something similar that occasionally generates the bad value.