Open SdgGames opened 1 year ago
A temporary fix exists by adding the items on the main thread:
YourGridMap.call_deferred("set_cell_item", Vector3i(X, Y, Z), ID)
This won't cause any noticeable slowdown on the main thread, as it is only adding the block. The other code that surrounds it will still be running on their own thread.
Godot version
v4.0.beta4.official [e6751549c]
System information
Windows Server 2022, Vulcan
Issue description
Creating a GridMap from a secondary thread throws errors and eventually causes a crash. This issue is in Godot 4, so I don't think that it's related to 42917
The GridMap is not a child of the scene tree when its contents are being modified. The following error is emitted while calling
gridmap.set_cell_item
Additionally, the game will randomly crash at times.
Steps to reproduce
Start a secondary thread. From the secondary thread, create a GridMap. Do not add as a child of the scene yet. Call
set_cell_item()
multiple times to populate the GridMap. Errors will randomly appear, and the game might crash.Using Reproduction Project: Pressing the "Start" button will cause errors to show up in the debugging output Pressing the "Start" button multiple times in will eventually cause the game to crash.
Minimal reproduction project
GridMap.zip