Help Performance degradation - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Help Performance degradation (/thread-4172.html) |
Performance degradation - Nightfall - 15-04-2024 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)
Is there a way to resolve this issue? Thanks in advance. RE: Performance degradation - josemendez - 15-04-2024 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, RE: Performance degradation - Nightfall - 15-04-2024 (15-04-2024, 07:53 AM)josemendez Wrote: Hi, Thanks for the reply! I have taken screenshots of a few steps from the profiler. Is this the right way to do it? [attachment=2034] [attachment=2035] [attachment=2036] [attachment=2037] RE: Performance degradation - josemendez - 15-04-2024 (15-04-2024, 08:35 AM)Nightfall Wrote: Thanks for the reply! 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, RE: Performance degradation - Nightfall - 16-04-2024 (15-04-2024, 09:22 AM)josemendez Wrote: Hi, Hello, I just sent you the profiler data file via email. Please let me know if there is anything wrong with it. best regards, RE: Performance degradation - josemendez - 16-04-2024 (16-04-2024, 01:57 AM)Nightfall Wrote: Hello, Hi, Took a look at your profiler data. No wonder it's slow, you're updating physics 17 times per frame: 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: 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, RE: Performance degradation - Nightfall - 17-04-2024 Thank you for the detailed response! I'll take a deeper dive into it |