godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.51k stars 20.05k forks source link

Released project has a chance of crashing with Camera2D and a large TileMap upon reload_current_scene #75413

Open fiaKaiera opened 1 year ago

fiaKaiera commented 1 year ago

Godot version

v4.0.1.stable.official [cacf49999]

System information

Windows 10 64-bit

Issue description

In an exported Release file on Godot, if a TileMap node has a large number of tiles present in the scene, and a Camera2D node is present, upon calling get_tree().reload_current_scene(), the game has a chance of crashing without any errors, which can scale by the number of tiles present in the scene.

The game will not crash at all if get_tree().reload_current_scene() is called in debug mode. This bug is not present in Godot 3.

Edit/Update: The same outcome can be achieved if the Camera2D node is added after the scene is reloaded. A workaround fix for this is having the Camera2D node exist outside the current scene.

The conditions for the bug:

Expected outcome:

Current behavior:

There are no errors and nothing is reported upon crashing in both the editor and on the released game with the verbose console option enabled.

Steps to reproduce

Minimal reproduction project

The provided project has a script that automatically runs get_tree().reload_current_scene() every 0.2 seconds, with the provided scene given to easily replicate the crash once exported.

Godot4TilemapTest.zip

Calinou commented 1 year ago

Can you reproduce this when exporting the project with debugging enabled?

fiaKaiera commented 1 year ago

No, the crash does not happen at all when exported with debugging enabled.

Lilith-In-Starlight commented 1 year ago

Doesn't happen only with tiles, a large amount of Sprite2D nodes apparently suffices for this.