The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I create terrain segments (Mesh and ConcavePolygonShape) in separate worker threads and then assign them to MeshInstance and CollisionShape in scene tree in the main thread. I'm randomly getting these errors and weird problems that look threading-related:

E 0:00:00.571   get: Condition "!id_map.has(p_rid.get_data())" is true. Returned: __null
  <C++ Source>  ./core/rid.h:150 @ get()
E 0:00:00.571   shape_set_data: Condition "!shape" is true.
  <C++ Source>  modules/bullet/bullet_physics_server.cpp:138 @ shape_set_data()

This is what I do in the threads:

var collision_vertices = PoolVector3Array()
collision_vertices.resize(dimensions.x * dimensions.y * 6)

<set up geometry in collision_vectices array>

var shape =

The shape is then passed to main thread using call_deferred() and assigned there to CollisionShape existing in scene tree. The errors appear even if I only create the shapes in the threads and don't use them anywhere.

It looks like this happens only if I use more than one worker thread. Documentation warned about accessing same resources from more than one thread but I don't see what is causing the problem here.

in Engine by (71 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.