Unity performance regressions - CPU usage, Physics.Proccesing, Rendering spikes and more

This thread will cover serious performance bugs that are present from Unity 2017, some are introduced in later versions of Unity, and have not been fixed to this day.
We are currently focused on iOS but there is a high possibility that these same issues are present on other platforms.

Doubled CPU usage
One issue which we noticed is double CPU usage that happens around 150 frames after the scene is loaded or the game app is resumed on some Unity versions and some mobile devices, depending on if fps is locked to 30 or 60fps. For example, you start a game and after the level is loaded you have for the first 150 frames a stable CPU usage of 5ms, after that CPU usage increases to 10ms and stays at that. If you minimize your game and get back into it, this behavior will be reproduced again. This issue often triggers other issues, like jittering in Unity 2017 and 2018, spikes, and unstable fps.

Example:

More examples sorted by Unity version, device, and fps (CPU in the title):

We would like to get an explanation about this and make a bug report if necessary.

Jittering
Jittering is a constant screen tear that happens only when the game is locked to stable 30 fps on Unity 2017.4.32 and Unity 2018.4.31 (the game behaves as it is locked to 10-15fps). This could be some issue related to multithread rendering because we noticed that the same happens on Android when multithread rendering is turned on, once it is turned off jittering does not happen. Changing this setting on iOS does not have any effect. Jittering is closely tied to the above issue with double CPU usage because it always starts when there is a double CPU usage and the game is locked to 30fps. If you minimize and resume the game back, you will again get smooth 150 frames, and after that jittering starts again.
The jittering issue was not reproduced in Unity 2019 and later versions.

We didn’t make a bug report because Unity 2017 is unsupported and Unity 2018 is at the end of the life cycle, without fixing the issue below there is no point in fixing it.

Physics.Processing spikes
The biggest problem currently is Physics.Processing spikes and higher physics CPU load which is a regression from Unity 2017. This issue did not exist in Unity 2017 and it first started to appear in Unity 2018 and it is present also in Unity 2019, 2020 and possibly 2021. This issue appears on many devices, in our case on iPhone 5s, iPhone 6s, and many other devices by user reports on the old issue tracker linked below. It is a huge performance problem, especially on weaker devices like iPhone 5s and iPads with higher resolutions. We could ignore iPhone 5s device because it is old and not many people still use it, however, this device shows that there are some serious problems that will be even more noticeable on iPads that have higher resolutions. Physics.Processing spikes on weaker devices (and maybe on specific higher-end devices) causes very unstable fps, even if you can handle 60fps, spikes will drop it and will cause stuttery gameplay, if you lock it to 30fps, spikes will anyway drop fps below 30fps what will again cause stuttery gameplay.

Example:

More examples sorted by Unity version, device, and fps:

This issue is reported and it is active, but it took 2 months to get any confirmation, and it does not like it is gonna be fixed any time sooner as it should have been:

Other reports related to this:

Rendering spikes
Rendering spikes are introduced in Unity 2019 and they consist of huge Terrain.Details.Render spikes (up to 450ms), Camera.Render Drawing and Camera.Render Culling spikes (up to 150ms).
Terrain.Details.Render spikes can be reproduced every time, on every device on the same point in the sample level and they literally freeze the game, we even experienced a freeze of 1-2sec.
Drawing and Culling spikes are a bit random, but they appear few times in sample level on iPhone 5s, possibly on other devices, but not on iPhone 6s.

Example:

More examples are provided in the bug report and: 95.7 MB folder on MEGA

This issue is reported under id 1312223 and it is still not processed.

Overall performance
We also noticed worse performance in Unity 2019.4.18 than in Unity 2017.4.32 or Unity 2018.4.31 which is more obvious when the device heats up. While we had almost stable fps in Unity 2017 and 2018, in 2019 we get higher fps drops which cause more unstable fps and therefore more stuttery gameplay.

Proofs with a timeline of events and performance status
Here is a detailed timeline of events and performance status which are described above and it is sorted by Unity version, device, and fps lock. To get a clearer view of it c/p it into notepad and stretch it to get lines, go through it and compare with profiler screenshots on:

2017.4.32
iPhone 5s - 30fps
stable fps, no jitter, no spikes, after ~150frames double CPU usage, stable fps, jittering, rare physics spikes, no rendering spikes
iPhone 5s - 60fps
stable fps, no jitter, no spikes, after ~150frames there is NO double CPU usage, stable fps, no jitter, no physics spikes, no rendering spikes
iPhone 6s - 30fps
stable fps, no jitter, no spikes, after ~150frames double CPU usage, stable fps, jittering, rare medium (6ms) physics spikes, no rendering spikes
iPhone 6s - 60fps
stable fps, no jitter, no spikes, after ~150frames double CPU usage, stable fps, no jitter, no physics spikes, no rendering spikes

2018.4.31
iPhone 5s - 30fps
stable fps, no jitter, no spikes but constant huge physics CPU usage, after ~150frames slightly higher physics CPU usage, unstable fps, jittering, constant huge (20ms) physics spikes, no rendering spikes
iPhone 5s - 60fps
stable fps, no jitter, constant big (10ms) physics spikes, after ~150frames there is NO double CPU usage, stable fps, no jitter, constant big (10ms) physics spikes, no rendering spikes
iPhone 6s - 30fps
stable fps, no jitter, small (5ms) physics spikes, after ~150frames double CPU usage, stable fps, jittering, huge (16ms) physics spikes, no rendering spikes
iPhone 6s - 60fps
stable fps, no jitter, small (5ms) physics spikes, after ~150frames there is NO double CPU usage, stable fps, no jitter, medium (5-10ms) physics spikes, no rendering spikes

2019.4.18
iPhone 5s - 30fps
stable fps, no jitter, small physics spikes, after ~150frames double CPU usage, very unstable fps, no jitter, constant huge (17-33ms) physics spikes, often huge rendering spikes
iPhone 5s - 60fps
stable fps, no jitter, no spikes, after ~150frames there is NO double CPU usage, very unstable fps, no jitter, often big (6-17ms) physics spikes, often huge rendering spikes
iPhone 6s - 30fps
stable fps, no jitter, no spikes, after ~150frames double CPU usage, stable fps, no jitter, rare medium (5ms) physics spikes, rendering spikes
iPhone 6s - 60fps
stable fps, no jitter, no spikes, after ~150frames double CPU usage, stable fps, no jitter, often medium (7ms) physics spikes, rendering spikes

2020.2.2
Roughly the same as on Unity 2019.4.18.

The current state of development with Unity
At this moment every Unity version has its own performance problems, the latest Unity version seems to have even more performance issues than older versions. We always try to deliver an optimized version of our products but this becomes more and more difficult.

Unity 2017 – unsupported, jittering on 30fps
Unity 2018 – jittering on 30 fps, physics.processing spikes, unstable fps
Unity 2019 – physics.processing spikes, rendering spikes, slightly worse performance, unstable fps

How we clearly see that Unity has serious problems that are dragged from version to version and even became worse now than before. We would like to get the following explanations and answers:

  1. Physics.Processing regression is introduced in Unity 2018 and it is still not fixed. How long will it take to fix this serious performance issue in Unity 2018, 2019, and 2020?
  2. Why we sometimes (depending on Unity version or device version and fps) have double CPU usage after some amount of frames (in our case 100-200 frames)?
  3. How long will it take to fix Rendering spikes regression which literally freezes the game?

If needed we can provide a sample project for Unity 2017.4.32, Unity 2018.4.31 is provided over bug report, and from that project, you can easily transfer to Unity 2019 and Unity 2020.

We are open to any questions that could help in solving these issues.

1 Like

I used to play Rust since many years back. It’s one of the most popular PC titles made with Unity. Facepunch have had their issues but out of all the people I know, nobody has reported screen tears, jitter or spikes. If these were general Unity platform issues since years back, I would have seen them.

I’d look at your memory model first to see if you’re feeding the stop-the-world garbage collector. At least your profiler images show a pattern of garbage collection. With respect to jitter, I’d double check that your physics is separated from your rendering using best practices.

These are just ideas but then again your post was a general complaint.

On the Double CPU usage problem, this might be caused by the phone lowering the SOC performance after a few seconds of running at max. A lot of modern high end phones like to briefly run the SOC at a higher performance than the phone can thermally sustain, to speed up burst-ey loads such as loading an app.

This could be a specific issue on mobile and maybe is not present on PC. If there would be an issue with our project then these issues would be more or less the same on any Unity versions. The most important part is that this Jittering starts only when the game is locked to 30fps on Unity 2017 and 2018, on 60fps or on later Unity versions it works flawlessly without Jittering. Physics spikes are reported and they are confirmed as unnormal behavior.

Thank you for your suggestions, I will look more into separating physics from rendering, it sounds interesting for the future optimizations.

That could be it. How would you explain that it happens on some Unity version, devices, and fps lock while not on others? For example, look at iPhone 6s, there is a case where this issue does not happen only on Unity 2018.4.31 locked to 60fps.

This is not really an optimization but a must-have. Since you’ve been developing a long time I’m sure you know this, but you need to have all your physics code in FixedUpdate() and rendering code in Update() or onGUI() across the board, the latter of which can be called multiple times per frame. Then with fixedDeltaTime you control the physics framerate and with deltaTime / Application.targetFrameRate the rendering framerate.

All your physics code need to rely on fixedDeltaTime and rendering code on deltaTime. Unless you do this, expect jitter plus other problems.

Yeah, we do all that. It’s for sure a Unity engine-related issue.

1 Like

Bump - 14 days from this thread and there is still no response or signs of solving this

Most important issues:
Physics.Processing spikes

  • reported over the issue tracker on 14.11.2020. 14:37
  • multiple reports on older issue tracker that is marked solved but it is not solved
    Rendering spikes
  • reported over the issue tracker on 04.02.2021. 22:17, waiting for a response

On doubled CPU usage, I’m wondering if you have already eliminated hardware causes. Mobile devices don’t dissipate heat well, so will throttle as they heat up as needed to keep temps down. This can appear as if a process is taking longer, when it is really the CPU is running slower. I don’t know how to check iOS CPU clock speeds, so don’t know how to specifically check for this. But the behavior you’d expect to see is the game starts running fast, then at some point starts slowing down. You pause or exit the game, wait a bit for it to cool, get back into the game and it is fast again… before it starts slowing down again.

On physics differences between 2017 and later versions, there was a big physics upgrade to Unity in 2018.3.0, where they added a bunch of new functionality and upgraded to PhysX 3.4.2. I’m sure that it is too big a hassle to do this kind of testing, but it would be interesting if you were able to isolate your physics problems to specifically being caused by 2018.3.0’s changes. 2018.2.21 is the last version of Unity with the physics working more like 2017.x.

https://unity3d.com/unity/whats-new/unity-2018.3.0

This happens with the cold device, so it is not due to thermal throttling. We could think that it is by device design, but the case with iPhone 6s, 60fps, on Unity 2018.4.31 shows that Unity and fps lock have an impact on this.

About physics, thank you for this info, that maybe could be the cause, I will check it tomorrow on 2018.2.21. and will report back.

2 Likes

Having the same issue… Physics.Processing is taking up all my computer’s resources on 2019.4.21f1 and there’s no info on why inside the profiler.

Physics.Processing spikes
The good news is that we managed to pinpoint Physics.Processing spikes to specific Unity version from which it started. Till Unity 2018.3.14 everything is ok, we have a stable Physics CPU load but from 2018.4.0 Physics.Processing spikes and higher physics CPU load start to appear, they are massive and they are present till the latest Unity versions.

Unity 2018.3.14f1
iPhone6S on 30fps


iPhone6S on 60fps

Unity 2018.4.0f1
iPhone6S on 30fps


iPhone6S on 60fps

*weaker device iPhone5S which have a huge impact on fps because of this can be seen on the link below

More examples: 95.7 MB folder on MEGA

The bad news (kind of) is that our issue tracker regarding Physics.Processing issue was closed as “Won’t fix” with the following explanation:
“The spikes are a side effect of physics thread having to wait on weaker devices. Those spikes do not affect performance and give false increased reading by including thread wait time, which we can do nothing about due to weaker device hardware.
Existing performance issues are caused by either scripting or rendering. To better observe spikes reported by scripting/rendering, physics graph can be turned off by clicking “Physics” label on left side of profiler graph.”

There were no issues like this prior to Unity 2018.4.0 and we don’t see any rendering or scripting spikes in our profiler (examine profiler screenshots) that would be big enough to cause any performance issues. We have contacted back the tester that was assigned to this issue, maybe he could explain and help us understand it in more detail.

Edit: this issue tracker is again active and the above response was removed

The facts are:

  • we don’t have any significant script or rendering spikes (rendering spikes in 2019, 2020 are a separate issue)
  • Physics.Processing spikes and higher physics CPU load are not reproducible on the Unity versions prior to 2018.4.0, from that version they are present on all Unity versions
  • in 2018, 2019, and 2020 we have more often fps drops from stable 60fps, even if we lock fps to 30 fps we still get drops
  • when we see fps drops on the device (iPhone5S) we also see Physics.Processing spikes in the profiler, these fps drops are clearly connected to Physics.Processing spikes.

The older issue tracker that was closed still gets comments about this issue, most of them started after the 2018.4.0 version:
SKIRNERS1 JUL 29, 2019 07:42 - It seems like the issue is back in 2018.4.2… :frowning: At least on iPhone 7+ builds…
LAEUSNB AUG 16, 2019 23:21 - Issue is back on Win10 standalone builds on 2018.4.2f1. Maybe something to do with deleting game objects with rigid bodies.
AUTUMN_737 SEP 03, 2019 00:18 - Spikes present in Unity 2018.4.8.f1
…and many more comments about this issue in 2018, 2019 and 2020.

Rendering spikes
While doing some tests we realized that this is an even bigger issue than we first thought. Spikes are often, massive and they cause very stuttery gameplay. It’s huge regression from Unity 2018LTS where there were no rendering spikes.

Rendering spikes on Unity 2019.4.21 on iPhone5s, we didn’t even move the camera.

I also think something is wrong with the physics.
It’s like all meshes with colliders are involved in all physics calculations, no matter the distance to the objects, or length of rays.

Bump - there is still no changes or response about this

Physics.Processing spikes In 2020 LTS

Physics.Proccesing spikes
We finally got a second response from a Unity team:
In 2018.4.0f1 there were some changes to job scheduling which unfortunately introduced an anomaly in profiler and possibly performance issues on some processors, it looks like this is affecting you as well. This is a known issue and it was discussed internally, unfortunately roadmap for it is pushed back and fix will not be available in nearest future.

We tested on iPhone SE2, and this device does not have Physics.Processing issues on Unity 2019 but surprisingly it has catastrophically huge Physics.Proccesing CPU load on Unity 2017.

So here we have a case where older devices have small issues on new Unity 2019 and new devices have big issues on old Unity 2017. In an ideal case, all devices would work without performance losses, and as we may know “pushed back and fix will not be available in nearest future” means that it will never be fixed and there really is no need to be fixed, because if it ever gets fixed, older devices will be outdated till that time.

Rendering spikes
They are also present on newer devices and there is still no response of any kind.

I am also having weird physics spikes randomly after few minutes of playing, restarting the game on iPhone fixes the problem for few minutes and then it agains lags.
My game does have 200 - 300 rigid-bodies with collision matrix enabled with 2 layers only & also a huge environment. Max Tris : 300K which is normally good for me.
I have also tested a game of Zombie Category with 1.5M Tris they are pretty much stable. The only thing difference other than tris is that Zombie Game do not have much collisions but the game with 300K tris is full of collisions most of the time.

Rendering spikes
Four months have passed since reporting this issue and there is a zero response or action taken regarding this.

2 Likes

this still exists as of today, in unity 2020.3.13f1

Can confirm.

I looked up if theres a bug issue entry in unity tracker, I couldnt find the latest.