Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Softbody lags SEVERELY but only during collision
#5
(12-09-2023, 03:01 AM)creekat Wrote: Oh! I see. The softbodies I use are averaging at 190-200 particles. I don't think this is a lot?

Hi!

No it's not a lot, but depending on how many softbodies you have it can get costly. The ObiSolver component shows some basic statistics in the inspector (amount of particles, amount of simplices, amount of contacts). With just 9 softbodies, you shouldn't have any trouble whatsoever.

Took a look at your profiler data, the cause of performance degradation is obvious: all physics are being updated 16 times every frame!

[Image: 8Xtcmls.png]

This is called "death spiraling", and happens when a frame takes longer than usual to render. As a result, Unity is forced to update physics multiple times per frame in order to catch up with the extra time, but this may cause the next frame to take even longer which exacerbates the problem. You can tell Unity to stop updating physics after a given time threshold, this is called "maximum allowed timestep" and can be found in the Time settings:

https://docs.unity3d.com/Manual/class-TimeManager.html

Lowering the maximum allowed timestep to a small multiple of the fixed timestep will prevent bad cases of death spiraling. Eg, if your fixed timestep is 0.02, setting the maximum allowed to 0.06 will ensure physics is updated at most 3 times per frame (0.06/0.02 = 3).

Now, typically frames should not take too long in the first place. However in your case it happens because collision detection isn't being compiled by Burst, but being run in a single thread using regular C#. This is extremely slow (in the following picture, green bars are the time taken by Burst methods, while the darker ones is time taken by non-Burst methods. You can see Burst takes a tiny amount of time to do its job, while most of the time is spent on the blue bars):

[Image: qAT3fpR.png]


As to why this is the case, no idea. Maybe you've unintentionally disabled Burst compilation for these specific jobs, or your Burst version is too old (these methods require generic method support, which older Burst versions didn't support). I'd suggest updating both Obi and Burst, see if that makes a difference.

(12-09-2023, 03:01 AM)creekat Wrote: One more thing also. I mentioned this in the original message, but everytime I restart Unity, the settings for Jobs always return back to default. This means I have to disable the jobs debugger, safety checks and leak detection every single time. When I build an Android version of the game, how are these settings set? What are the settings of Jobs in-game when users play with a smartphone?

These settings are editor-only. In standalone builds, Burst is enabled, safety checks and debugger disabled (since your players can't debug your game or get warnings in the console). See Unity's Burst documentation for details.
Reply


Messages In This Thread
RE: Softbody lags SEVERELY but only during collision - by josemendez - 12-09-2023, 07:19 AM