RigidBody anim graph node crash when scaling

Hej,

The rigid body anim graph node crashes for us when used with a scaled up mesh.

This only happens when the player is in an area with a lot of actors.

The crash happens because the node tries to allocate to much memory (See the attached crash log).

Too much memory is allocated because the array of actors that it considers for the collision is too big with several hundreds if not thousands of actors.

Looking at the code it looks like that the map `FAnimNode_RigidBody::ComponentsInSim` is never shrunk.

The two functions that should do that, `PurgeExpiredWorldObjects()` and `ExpireWorldObjects()` have no code for PhysX.

[Image Removed]

[Image Removed]

[Attachment Removed]

Steps to Reproduce

  1. Add “RigidBody” node to an animation Blueprint
  2. Set it’s alpha to 0.5 (should be the same result with higher values)
  3. Set “Simulation Space” to “World Space”
  4. Enable “Transfer Bone Velocities”
  5. Enable “Overlap Channel” and set it to “Pawn”
  6. Add a “Transform (Modify) Bone” node after the rigid body node and set the scale to 6 or 7
  7. Attach a mesh with the animation blueprint to your player pawn
  8. Move around an area with a lot of physics actors (or actors in general?) that collide with the “Pawn” channel
    [Attachment Removed]

Hi Paul,

Apologize for the delay in response. I followed your Reproduction Steps and was unable to experience the crash where it allocated too much memory. How many actors was the mesh colliding with, and are there any other steps that might be missing so I can better reproduce it?

Additionally are you able to reproduce this issue by importing this mesh (or similar) into a vanilla 4.27 project? If you can also provide that sample project so I can try to reproduce it that would be great. Thank you.

Regards,

- Jon

[Attachment Removed]

Hi Both,

Thank you for investigating Jonathan. [Content removed] but this is a very old version of our software. Are you in the process of upgrading?

Best

Geoff

[Attachment Removed]

Hi Paul,

That makes sense. If you can work around for the moment then this all gets a lot easier when you are on UE5 since we have complete source and it is in active development.

Best

Geoff

[Attachment Removed]

Hej,

I don’t see an attached file in your post.

The crash doesn’t happen when the mesh collides with something.

It happens when moving through an environment that has a lot of actors that would collide with it.

This is the crash callstack:

Goat2!AssertFailedImplV() [C:\BuildAgent\work\GS3_BC\UE4\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:104]
Goat2!FDebug::CheckVerifyFailedImpl() [C:\BuildAgent\work\GS3_BC\UE4\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:508]
Goat2!ImmediatePhysics_PhysX::FLinearBlockAllocator::Alloc() [C:\BuildAgent\work\GS3_BC\UE4\Engine\Source\Runtime\Engine\Public\Physics\ImmediatePhysics\ImmediatePhysicsPhysX\ImmediatePhysicsLinearBlockAllocator_PhysX.h:57]
Goat2!ImmediatePhysics_PhysX::FSimulation::GenerateContacts() [C:\BuildAgent\work\GS3_BC\UE4\Engine\Source\Runtime\Engine\Private\PhysicsEngine\ImmediatePhysics\ImmediatePhysicsPhysX\ImmediatePhysicsSimulation_PhysX.cpp:701]
Goat2!ImmediatePhysics_PhysX::FSimulation::Simulate_AssumesLocked() [C:\BuildAgent\work\GS3_BC\UE4\Engine\Source\Runtime\Engine\Private\PhysicsEngine\ImmediatePhysics\ImmediatePhysicsPhysX\ImmediatePhysicsSimulation_PhysX.cpp:547]
Goat2!FAnimNode_RigidBody::EvaluateSkeletalControl_AnyThread() [C:\BuildAgent\work\GS3_BC\UE4\Engine\Source\Runtime\AnimGraphRuntime\Private\BoneControllers\AnimNode_RigidBody.cpp:734]

`PxTransform` is 28 bytes and `PageBufferSize` is 65536.

So when there are more than 2340 transforms in ShapeSOA.LocalTMs (ImmediatePhysicsSimulation_PhysX.cpp:711), the game will crash.

You don’t need that many actors at once. Because the array is never cleared you only ever need to encounter that many total actors/components in the surrounding.

[Attachment Removed]

Hello, I am still unable to reproduce the crash still, but based off your findings and digging a bit into the PhysX code I am seeing how this could potentially blow up if you are not using Chaos, it looks like ComponentsInSim::PurgeExpiredWorldObjects is only purged when using Chaos Physics but not when using PhysX. I will escalate this to Epic as I don’t see a fix for this yet.

-Jon

[Attachment Removed]

Hej,

We are currently porting our game to UE5, but that will take a few month.

Right now I’m preventing the issue from happening by limiting the mesh’s maximum scale.

That’s not optimal but ok for now.

If the issue is fixed in UE5, then I can re-visit that once we are done with the port.

[Attachment Removed]