Released game crash but runs flawlessly in editor

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

I just completed my first tower defense game. My game runs fine in the editor that I could play an hour long. Unfortunately, the released game behaves very differently. It just stopped functioning and stopped working error appears after the first wave. The Command prompt (debug) didn’t tell me anything.
Please help, this incident really hurts my heart

Would it be possible to share that game, or reproduce a smaller project in which the crash happens? Is it random or 100% happening when you do something specific? Usually when those things happen I remove stuff until it stops happening, which helps identifying the place where the crash occurs, eventually nailing down why it happens. It’s a good time to investigate this because Godot 3.1 is on its way for release and devs are dedicated fixing bugs right now.

Zylann | 2019-02-15 14:01

the game is 140mb. Is there any appropriate place to upload it?

About the issue, it is 100% happening on the first 90 seconds. In some cases, the game doesn’t crash but all of the turrets just stopped functioning like they are all aiming something that doesn’t exist. btw I have set_physics_process()that keep switched ‘true’ and ‘false’. Then I have a dozen of ‘export (PackedScene)’.

no clue how this was happened. I’m very lost right now because the editor works fine and didn’t show any error and I can play forever on it.

Kompaktive | 2019-02-15 14:57

It occurred to me as well that a bad bug occurs in a large project, so the most stupid simple (but also boring) way of dealing with that really is to remove stuff until it works, typically all stuff not needed for the repro (other levels, textures, music, editor plugins…), or to attempt a C++ debugging session in release mode in the hope that it catches something (never done that in release tho). If you want to upload the 140mb project, I’d say zip it and use a file hosting service such as Framadrop (select 7 days expiration, should be enough to share for now), WeTransfer or Google Drive.

You can also try to upgrade your project to Godot 3.1 beta4 and see if the crash still occurs (although it could be interesting to find what is the real cause of the crash).

Zylann | 2019-02-15 18:51

The Lone Builder.zip - Google Drive
Here. When you placed the turret, the first symptom is all turret will stop altogether. Then followed by the ‘stopped working’ error. The game runs fine without placing turret at all.

Kompaktive | 2019-02-15 23:21

I tried the game, placed some turrets but thet don’t do anything. Then I realized I had to move on top of the turrets to finish them and make them operational: then they started firing. I survived the first wave, then the second had way too many enemies. Retried several times. I had no crash though. Which system are you using?

I had another go, this time using generators too: then I had a crash, where sound first started twitching, then the game closed.

Would it be possible to look at the project or is it closed source?

Zylann | 2019-02-16 02:22

Hi. I followed your advice, the one you said stupid simple and boring. in addition, I reread and illustrated them all in my mind (so basically I’m was becoming a robot for that moment) one line by one line.

Then I discovered my own programming mistakes that the engine itself ignores it (It even does flawlessly in the editor). It was that the turret was trying to shoot a non-existent, recently queue_freed object, that caused a chain problem:
-) A particle doesn’t know where to appear
-) Turret keeps aiming THAT target
-) and so on and so forth

Reworked turret’s code and everything works flawlessly… for real. This is the most terrifying bug I have ever made that I was so close to giving up Godot. This is such a relief that it was my mistake, not Godot.

Thank you very much for your effort. I really appreciate it. Your advice worked for me.

Kompaktive | 2019-02-16 06:23

Hmmm, accessing freed nodes should have been raised by the engine I think…
Which line of code caused the issue exactly?
If I try to access a freed node in Godot 3.1 it properly reports Invalid get index 'position' (on base: 'previously freed instance')..
If I try this in Godot 3.0.6, I once got an error, but sometimes it doesn’t and freezes without info.

Zylann | 2019-02-16 13:17

It should in 3.0.6 too. But in this particular case, I don’t know why the editor was kind of ‘forgiving’.

Kompaktive | 2019-02-16 23:03