godot: Instantiate big Tilemap on thread dont work.
Tested versions
Godot 4.1 and 4.2
System information
Macbook Pro M2
Issue description
When instantiate a big Tilemap on a separate thread and try to return it to the main thread, issues occur. I’ve encounter various bugs while trying to find a working solution. It works fine if i call Thread::wait_to_finish() on the main thread. But passing the built scene with call_deferred, problems occur.
On the attached project, the game freezes on 4.2. Ive also encountered crashes (mostly on 4.1) as shownhere:
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.1.stable.official (b09f793f564a6c95dc76acc654b390e68441bd01)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] 1 libsystem_platform.dylib 0x00000001834f2a84 _sigtramp + 56
[2] SpriteFrames::get_frame_duration(StringName const&, int) const
[3] NavigationObstacle2D::get_vertices() const
[4] NavigationObstacle2D::get_vertices() const
[5] NavigationObstacle2D::get_vertices() const
[6] VariantInitializer<Vector<Color>>::init(Variant*)
[7] Object* ClassDB::creator<ENetConnection>()
[8] Object::get_instance_id() const
[9] JSON::get_data() const
[10] VariantInitializer<Vector<Color>>::init(Variant*)
[11] Object* ClassDB::creator<ENetConnection>()
[12] Object::get_instance_id() const
[13] JSON::get_data() const
[14] VariantInitializer<Vector<Color>>::init(Variant*)
[15] Object* ClassDB::creator<ENetConnection>()
[16] MultiplayerAPI::is_server()
[17] AnimationPlayerEditor::unpin()
[18] CallableCustomExtension::default_compare_less(CallableCustom const*, CallableCustom const*)
[19] SceneTree::get_root() const
[20] Node::get_index(bool) const
[21] Node::get_index(bool) const
[22] RendererCompositorRD::_create_current()
[23] void rx::mtl::GetMatrixUniformMetal<unsigned int>(unsigned int, unsigned int*, unsigned int const*, bool)
[24] RendererCompositorRD::_create_current()
[25] 25 dyld 0x000000018316bf28 start + 2236
What is going on, is this a bug? Or how do i solve it. One must be able to instantiate a bigger scene on a separate thread.
EDIT:
On the current attached minimal project i get the following error multiple times in the log-file:
USER ERROR: Condition "p_elem->_root != this" is true.
at: remove (./core/templates/self_list.h:80)
It does however work with smaller tilemaps
Steps to reproduce
Create a big TileMap and try to loading it and instantiate it using a Thread.
Minimal reproduction project (MRP)
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 23 (10 by maintainers)
It’s indeed not unreasonable, it’s due to a bug, which I’m currently working on fixing, if you can please try testing:
This is due to the same issue as:
Looking into a different improvement on this side as well
I made it work on my M2 as well. I found that Godot had generated 250GB of files somewhere (probobly left the crashed program over night or something). I clean up my computer, and after that the branch 4.3 works like a charm and i can finally instantiate nodes on a thread!
@grusad Are you able to compile Godot from the
masterbranch on the M2 withscons dev_build=yes(to have debug symbols), and see what stacktrace you get if/when it crashes?I don’t know if this can help you, but i tried on Windows 11 with RTX4070 and the output is:
Godot Engine v4.3.dev4.official.df78c0636 - https://godotengine.org OpenGL API 3.3.0 NVIDIA 551.76 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce RTX 4070 Laptop GPU
<PackedScene#-9223372011319851734> Node2D:<Node2D#26122126561> this is not printed — Debugging process stopped —
I don’t see any crash, and i tried at least 10 times.
I had the same issue with Godot 4.2 (or previous versions), but now i tested my game with Godot v4.3 dev 4, and i can’t reproduce the issue. It works perfectly. In my case, the problem is solved with Godot 4.3 dev 4. Nice!