Game crashes only when export debug is disabled

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By leo-pnt

Hi :)!
The game works perfectly fine from the editor and when export debug is enable.
But, when I export with this option disabled, my game crashes at a very specific moment.

The problem is that I can’t get any output from the exe file… even the log files are very strange as the output is corrupted and in the wrong order (compared to debug mode). Also the most important ones are missing (I mean my print() messages)

Game FPS: 1
Game FPS: 32
Loading resource: res://scenes/mode-menu.tscn
Loading resource: res://postprocess-effects/CRTeffect_layer.tscn
Loading resource: res://scripts/mode-menu.gdc
Game FPS: 59
Loading resource: res://scenes/Team-deathmatch.tscn
Loading resource: res://classes/subMarine.gdc
Loading resource: res://classes/torpedo.gdc
Loading resource: res://classes/weapon.gdc
[...]
Loading resource: res://VirtualJoystick/Joystick.tscn
Loading resource: res://VirtualJoystick/joystick_background.png
Loading resource: res://VirtualJoystick/joystick_handle.png
Loading r

So i’ve identified that the game crashes when ether the player or the AI dies.
After LOTS of tests I suspect to have found the problem (and of course it’s at the worst place :') )
I use queue_free() to delete ai and player nodes. I have mutliple check like that everywhere in my code

if player != null:
    # do player related things

So for me, the exe code doesn’t execute in the same way than with the editor and causes this queue_free() to mess something, do you think that it will solve the problem if instead of deleting nodes I “disable” them to respawn somewhere else ?

Or is it something obvious that I have missed ?

I mean, it’s frustrating that it works on debug but not on release as I may have to modify all the game now ^^

EDIT:
I cleaned ALL my code of all those != null check. It basically uses signals and boolean variables
Now it works

I’m gonna wait for an answer, too, hopefully. I’m having an almost identical problem. In that an enemy node is freed while in the area2d of a projectile node. I think it has to do with null pointers and I even have a check for it, but it’s not throwing any errors out that I can use. It works fine in debug and editor mode. Just not in release build.

Homiedude180 | 2020-12-06 22:52

Same problem, the game runs perfectly in the editor and when exported with debug, but not when exported without. I was hoping to find an answer here…

gneurshk | 2022-04-18 21:51

Did you try removing null checks ? Things like if item != null:

leo-pnt | 2022-04-19 09:54