Download

Performance Problem - Physics strangely expensive after loading a game

Hey folks, I’ve been struggling with this issue for a while and I sure could use a hand!

In my project, after loading a 10+ hour game, some (and only some) of the physics are in the 40-70ms/f range. It actually gets progressively worse as I re-save and load the game.
Specifically it’s the ScScene.postBroadphase stat under “stat PhysxTasks” (attached a screenshot of it).

I’ve ruled out a bunch of things so far:

  1. The number of actors and components are stable. I count them using TObjectIterator and there are no extra objects after loading the game.
  2. Pruning methods don’t seem to affect postBroadphase. I’ve tried both MBP and SAP.
  3. The problem is carried along with the save game, so loading the game on another computer will have the same problem.
  4. Destroying all the actors (using the DestroyAll) improves postBroadphase BUT if I start walking around with the character, it jumps all the way back to 40-70ms/f

I’ve profiled and found that the slowdown is within a function


void SimpleAABBManager:postBroadPhase(PxBaseTask*, PxBaseTask* narrowPhaseUnlockTask)

But I can’t figure out how to use this information because this is in the third party Physx files and I can’t debug them or modify them (This is the file that function is from:


Source\ThirdParty\PhysX3\PhysX_3.4\Source\LowLevelAABB\src\BpSimpleAABBManager.cpp

I could really use some help figuring this out if anyone has any suggestions?

EDIT:
This turned out to be an engine bug ( https://issues.unrealengine.com/issue/UE-76873 ). Calling RecreatePhysicsState in key places resolved the issue for me.