Godot: add_child operation is unsafe in Thread ?

Created on 8 May 2018  路  4Comments  路  Source: godotengine/godot

Issue description:
I tried to use add_child with Thread for loading scene and it often crashes or do other invalid behavior. Maybe a note about it should be added to documentation of Thread ?

discussion documentation core

Most helpful comment

The SceneTree is not thread-safe. There should be more emphasis on what is and what isn't thread-safe, because some things like resources should be thread-safe for example (loading them is), but nodes aren't. I am myself curious about the details on this, and what are the guidelines since any mistake on this can lead to painful headbanging in an undefined future.

All 4 comments

The SceneTree is not thread-safe. There should be more emphasis on what is and what isn't thread-safe, because some things like resources should be thread-safe for example (loading them is), but nodes aren't. I am myself curious about the details on this, and what are the guidelines since any mistake on this can lead to painful headbanging in an undefined future.

I would like to see Godot in general become more ready to allow multithreading in games (it's starting to happen more and more now as 8-core chips become mainstream).

Having the addition and removal of data being thread safe would be great (as it can become a bottleneck in more complex games).

It's my understanding that you need to use attach_thread / detach_thread to access such Godot APIs from a different thread from the one Godot uses for dispatching events.

It's more or less similar to what other UI toolkits provides.

Was this page helpful?
0 / 5 - 0 ratings