Document some deadlocks in the physics server code

Add some comments documenting locations where
PhysicsServer3D::soft_body_set_mesh() can deadlock.

godotengine/godot-proposals#12670 has a proposal for some alternate
thread-safe soft body APIs.  In the meantime it seems worth at least
documenting some of the current pitfalls in the code.
This commit is contained in:
Adam Simpkins 2025-07-10 13:47:30 -07:00
parent c6d130abd9
commit cb25b933e7
2 changed files with 8 additions and 0 deletions

View file

@ -136,6 +136,10 @@ void GodotSoftBody3D::set_mesh(RID p_mesh) {
return;
}
// TODO: calling RenderingServer::mesh_surface_get_arrays() from the physics thread
// is not safe and can deadlock when physics/3d/run_on_separate_thread is enabled.
// This method blocks on the main thread to return data, but the main thread may be
// blocked waiting on us in PhysicsServer3D::sync().
Array arrays = RenderingServer::get_singleton()->mesh_surface_get_arrays(soft_mesh, 0);
ERR_FAIL_COND(arrays.is_empty());