UProceduralMeshComponent UpdateCollision Degrading performance over time

When playing in editor, updating collision for a UProceduralMeshComponent will take longer and longer to complete each time it’s updated, the time it takes to complete also stays the same when stopping and starting the game, it only goes back to normal when the editor is restarted. This doesn’t seem to be a problem in packaged builds, just play in editor.

This seems to be a problem in the physics cooking code, updating the visual mesh works perfectly.

Here’s a comparison of a packaged build and PIE.

Packaged build:

PIE:

Packaged build will stay at the same fps when updating the mesh but PIE will quickly drop to a low fps.

Hey Mykei-

Could you post the setup for your procedural mesh component? I would like to test this issue on my machine and want to make sure that I’m following the same steps that you used.

Cheers

I made a minimal test actor that degrades performance over time.

100 quads updated every frame with 4 mesh sections (this wouldn’t normally happen in a real game but it replicates the bug) I’m not sure if it happens with just 1 mesh section or it takes a much longer time for performance to degrade, I’ll run it for a while to test.

Confirmed that performance still degrades over time with 1 mesh section, it just takes much longer.

I ran the profiler and found that UBodySetup::CreatePhysicsMeshes() is taking the most time

I’ve narrowed it down to
GetDerivedDataCacheRef().GetSynchronous(DerivedPhysXData, OutData);
Replaced it with
DerivedPhysXData->Build(OutData);

That completely fixes the performance issues in PIE.

The fix is in engine code, I’ll request to have it included.

Hey Mykei-

I’m glad to hear that you were able to find a solution for the issue. Was the fix you found inside your own code or the engine code? If you made the change you mentioned to source code you may want to consider entering a pull request to have your fix included into the engine. You can find instructions on how to do this directly on GitHub: https://github.com/

Cheers

Hi,

In this case the DDC is getting thrashed with new data every frame. I think the right approach is to allow users to tag a bodysetup as requiring runtime cooking. This would be a bool that you would set to true when doing runtime cooking on a component.

Because of backwards comparability we can’t use this flag to determine which assets are not using runtime cooking, but we could issue a warning so that any asset which is cooked at runtime without the flag would be known by the user. This would allow us to make the behavior more strict over time.
Of course if the flag is set you’d never check the DDC.

If you are willing to make this change I’d be glad to integrate it!

Either way thanks for bringing this up it’s a definite issue.