Exporting 2D game in Release only - Occasionally seeing ERROR: Scene instance is missing, causing crash

Godot Version

Godot 4.4 Stable.Mono

Question

Hi everyone,

This is only happening for me (I’m developing on Windows using C#) after exporting a build in Release mode. It is NOT happening in Debug - nor is it happening if I Export with Debug enabled).

I see in my log file under the user:// area this error

ERROR: Scene instance is missing.

My game unloads a PackedScene which is the game map when the player transitions across the game-world boundary and loads another PackedScene for the next map. Each PackedScene by design has a TileMapLayer set as the first sibling of the scene. I do this pattern in every scene for consistency for my game logic to operate.

When running my game occasionally the game crashes with the above error - I repro by moving the player across the edge of the map repeatedly - sometimes the crash happens within the first few attempts, sometimes quite a lot (upwards of 30 times).

I use .Free on the scene node to free the map. I used to call QueueFree but using either approach leads to the problem eventually.

It feels like some resource memory issues or something deep in the engine’s resource-loading logic (I’m only speculating here).

For some reason, Godot is failing to load the packed scene programmatically… some of the time.

I tried the temporary fix in this post, unfortunately the problem still occurs.

Its odd that in debug mode (and in-editor) the problem never occurs and is the best hint to the possible suspect engine area I have.

Logging with debug does not help because for some reason running in Debug suppresses the error.

I’m going through looking for other game-logic causes but haven’t turned anything up that’s suspicious.

Any help greatly appreciated!

The first area I check when debugging any Godot issue on Windows that only appears in an exported version is a resource - especially an image file - that has a capital letter in the filename. I’ve seen this cause all sorts of weird problems.

1 Like

Thanks for your suggestion!

It turns out I had commented out the code I used in the other forum post when trying to optimize my game! (I thought there was a memory leak).

I am publishing a private build to steam and trying to understand the process, but I was never overwriting the data folder containing dll’s for the code (the folder called data_GAMENAME_windows_x86_64). It was a multitude of user errors here!

I put back the code in the other forum post and replaced the whole folder contents before testing again and no crash!

The hint that led me there was i wasn’t seeing any log messages from changes I was making to try and narrow down the cause of the crash - I was abusing GD.PrintErr (wrongly I might add!) to print messages in the logs ← normal Prints are omitted in Release builds, yet I wasn’t seeing the PrintErr’s being logged. Not until I replaced the data folder!

All in all, it was a red-herring of sorts and Ive put back the original code - no crashes!

However, it does highlight some engine issue in release mode because I’m relying on work-around code.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.