-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocumented thread (un)safety #20964
Comments
I wonder if there is an option to check in project settings for servers to be truly thread-safe? |
I've found the answer to the second point, the project settings contains There is a problem: |
This should be addressed out of the box in 4.0 thanks to #45852. |
I got this error in a similar context, I'm constructing ArrayMeshes and Shapes in several threads and I send them to the main thread which take care of the scene tree. (I use the Mono Task library to spawn my threads). Sometimes things work flawlessly, sometimes I got the exact same errors as OP in my terminal and sometimes the game crashes. I tried to set the rendering in "Multi-threaded" but it doesn't seem to work. Until now I admitted that nodes and resources instantiation in parallel threads is simply not possible in Godot. But is that really the case ? The doc about the thread-safe API seems to be telling something different about resources :
Can someone explain the exact mechanics that happen under the hood and cause these "casual" errors and crashes ? Thanks. |
As I commented in #18714 we have some basic concepts of thead safety documented in the docs.
I've been working on a procedural generator and trying to speed-up the generation. I decided to use multithreading but I have several doubts/problems.
context: I'm working using C++ GDN.
I'm using std::thread and OpenMP pragmas, does it have implications compared to the use of godot::Thread in relation to interacting with the engine API?
I have the following code to generate some meshes:
If I uncomment the #pragma it only generates the meshes processed by one thread. That's the reason of that? Do I have to generate it only with the main thread? Can that behaviour be circumvented using Nodes or the VisualServer?
After removing the comment in the pragma te generation of concave collisions is way faster (without multithreading takes some seconds to complete) but the generation is unrealiable, it sometimes finishes and sometimes crashes with the following error:
What's the cause of this error? Do I need to use the PhysicsServer in order to have a safe concurrent access?
This class is being loaded as a Singleton and the docs say it's safe to access the server in that case. What about nodes as in my examples?
The text was updated successfully, but these errors were encountered: