Description
Godot version
v4.0.2.stable.official.7a0977ce2
System information
Windows 10
Issue description
I started a brand new project last week and I was testing an exported version of the game just to test my scene switcher and to make sure that everything was working as intended (in a previous Godot 4 project I made the exported game would also crash randomly when switching scenes). After exporting the game and running it, the scene switcher worked great for the first few attempts, and then crashed on about the 4th scene switch. I spent hours rewriting and reformatting my code and nothing seemed to work so I deleted the project and started from scratch, rebuilding everything I had made from the ground up. After running the new game in the editor, I then exported it and ran it just to be 100% sure that everything was working. I switched levels about 10 times and it worked flawlessly. I closed the .exe and re-ran it just to make sure that it wasn't a fluke and on the 3rd level change it crashed. I spent more time trying to fix it and nothing worked so I went onto the Godot discord for help and after a few hours of discussion, I finally found the culprit:
The game runs perfectly fine in a debug export version of the game and in Godot itself, it's just the normal .exe export that's causing issues, which isn't good since that's obviously the version used for distributing the game publicly.
When I looked up the error in the Godot GitHub it became apparent that one of my resource IDs was corrupted, which shouldn't be possible considering this project is obviously a completely different project file than the first one. This is super frustrating and is clearly beyond my ability to fix and I can't continue work on my game until the issue is resolved.
Steps to reproduce
1.) Export a normal version of the game (NOT a debug export) and run it.
2.) The game starts in a top-down hub world where you use the arrow keys to move. Move towards
the flag and when you get close to it a "play" button will appear in the top left. Press it to switch scenes from the hub world to level 1.
3.) Once you're in level 1, run towards the right until you see the flag at the end of the level. Run into it to change scenes back to the hub world. (use space to jump and left and right arrow keys to move)
4.) Repeat steps 2 and 3 until you crash. Switch between scenes/levels 10 times. The game should crash before you reach 10 the first time you launch it. If you switch levels/scenes 10 times and nothing happens, close the .exe and re-launch it and try again and it should crash on the 2nd-4th scene switch. On very rare occasions the game will crash when you press the play button in the hub world.