Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Performance degradation
#1
Hi,

I am creating an iOS app using Unity as a Library.

There is a body model in the Unity scene that is pre-loaded with the following structure:

Root Object (Obi Solver, Obi Fixed Updater)
  • Bone Object

  • Mesh Object (Mesh Collider, Obi Collider)
In this setup, I want to dynamically load an Addressable cloth prefab (Obi Skinned Cloth, Obi Skinned Cloth Renderer) under the Root Object. However, I'm experiencing performance degradation over time after the prefab is loaded.

Is there a way to resolve this issue?

Thanks in advance.
Reply
#2
Hi,

When facing any kind of performance issues, use the profiler. Otherwise all you can do is blind guess.

Take a screenshot of your profiler in timeline mode, then share it here so I can help you interpret it and discover what the culprit might be.

kind regards,
Reply
#3
(15-04-2024, 07:53 AM)josemendez Wrote: Hi,

When facing any kind of performance issues, use the profiler. Otherwise all you can do is blind guess.

Take a screenshot of your profiler in timeline mode, then share it here so I can help you interpret it and discover what the culprit might be.

kind regards,

Thanks for the reply!

I have taken screenshots of a few steps from the profiler. Is this the right way to do it?

   
   
   
   
Reply
#4
(15-04-2024, 08:35 AM)Nightfall Wrote: Thanks for the reply!

I have taken screenshots of a few steps from the profiler. Is this the right way to do it?

Hi,

These screenshots are really zoomed into the timeline, so it's not possible to see what's going on. Obi is taking 7 ms/frame which isn't too bad, however your entire frame is taking more than 1000 ms/frame so there's something clearly wrong.

Either zoom out, or export the profiling session (small disk icon at the top-right corner of the profiler) and send it to support(at)virtualmethodstudio.com so that we can take a look at it ourselves.

kind regards,
Reply
#5
(15-04-2024, 09:22 AM)josemendez Wrote: Hi,

These screenshots are really zoomed into the timeline, so it's not possible to see what's going on. Obi is taking 7 ms/frame which isn't too bad, however your entire frame is taking more than 1000 ms/frame so there's something clearly wrong.

Either zoom out, or export the profiling session (small disk icon at the top-right corner of the profiler) and send it to support(at)virtualmethodstudio.com so that we can take a look at it ourselves.

kind regards,


Hello,

I just sent you the profiler data file via email. Please let me know if there is anything wrong with it.

best regards,
Reply
#6
(16-04-2024, 01:57 AM)Nightfall Wrote: Hello,

I just sent you the profiler data file via email. Please let me know if there is anything wrong with it.

best regards,

Hi,

Took a look at your profiler data. No wonder it's slow, you're updating physics 17 times per frame:

[Image: JTf4InP.png]


This is the hallmark of death spiraling, which happens when:
A) your timestep is too small.
B) your max allowed timestep is too high.
C) there's something else causing physics to be extremely slow, which in turn forces Unity to update physics multiple times per frame (up to the max allowed timestep) to try and catch up with rendering.

First step is to look at your project's time settings, and making sure that max allowed timestep is set to a small multiple of the timestep. For instance if you're using 0.02 seconds as the timestep, your max allowed timestep should be 0.04-0.06. This will allow a maximum of 3 (0.06/0.02) physics updates per frame.

Zooming the profiler into one step reveals that more than 90% of the time is spent on collision detection and response. The actual cloth simulation takes less than 5% of the time:

[Image: AF5QAne.png]

So my guess is either you have tens of thousands of contacts being generated, or you have a extremely complex collider (possibly your body MeshCollider) in the scene. Keep in mind that MeshColliders are really, really costly and that distance fields are almost always a better option.

Also be mindful of your solver's collision margin and continuous collision detection settings. These determine how many contacts are generated for each particle, if you use a large collision margin or full continuous collision detection, more contacts will be generated and as a result, collision detection/response cost will increase.

As a last note, it sounds like you're trying to add garments on top of a body/mannequin and rely purely on collisions for them to stay in place. This is NOT how character cloth is made in games since it is a brute-force, hugely costly solution. You can't even have deformable MeshColliders in Unity without rebuilding them every frame, this alone can tank your frame rate. Character clothing relies on skin constraints (or similar approaches) in all engines.

kind regards,
Reply
#7
Thank you for the detailed response!

I'll take a deeper dive into it
Reply