ArticulationLinkComponent not thread-safe - Missing PhysX 5 scene locking for various API mehtods #18506
Labels
feature/physics
This item is related to the physics subsystem.
kind/bug
Categorizes issue or PR as related to a bug.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
priority/major
Major priority. Work that should be handled after all blocking and critical work is done.
sig/simulation
Categorizes an issue or PR as relevant to SIG Simulation
Describe the bug
The ArticulationLinkComponent (implemented for the PhysX 5 gem and used extensively by the ROS2 gem) does not correctly employ
PHYSX_SCENE_READ_LOCK
/PHYSX_SCENE_WRITE_LOCK
to lock the scene before reading/writing the physx scene, resulting in unsafe access, runtime assertions, and potentially lost physics state updates.Since PhysX continually raises assertions in O3DE debug builds for this issue, it further makes debugging any other issues in levels with ArticulationLinks practically impossible (at least without hacks for automatically terminating the raised debug-breaks).
The fix should be straightforward, as in wrapping all methods reading / writing the physx scene with adequate scoped locks.
The ArticulationLinkComponent already wraps reads/writes correctly in four methods. The same logic just needs to be applied to all getters/setters.
Assets required
A project that reads/writes articulation link states at runtime, e.g. the ROS2 manipulation template levels.
Steps to reproduce
Since the PhysX API raises assertions, the best way to investigate them is
debug
configurationExpected behavior
API methods exposed by the ArticulationLinkComponent should work correctly and be safe to use
Actual behavior
API methods exposed by the ArticulationLinkComponent raise assertions, may cause stale reads, lost updates, and pollute debugging workflows with numerous assertions per simulation tick
Screenshots/Video
Found in Branch
both main & development
Commit ID from o3de/o3de Repository
3aba99a
Additional context
Example of proper implementation in https://github.com/o3de/o3de/blob/3aba99af74ad59cd50d22b9eab9d58686b345cc8/Gems/PhysX/Core/Code/Source/RigidBody.cpp
The text was updated successfully, but these errors were encountered: