CPU Usage Not Constant on iOS 11.2 (Metal) in Profiler and Xcode FPS CPU time != Profiler

Greetings…

.

I’ve been trying to get a consistent/constant baseline for CPU usage on iPad Pro 9" with Metal enabled. I had a look at this Bug: Unity Issue Tracker - [iOS] Gfx.WaitForPresent spikes on Metal every few minutes which I suspect is responsible but it talks specifically about GFX.WaitForPresent and I’m seeing spikes in Physics, Other and Renderer. I have not filed a bug at this point, first wanted to ask it here. Thank You in advance to anyone providing insight.

.

Background: I have an empty scene with a plane and a cube, rigid body on the cube it’s just sitting on the plane with a box collider. Lights are disabled, skybox disabled, background track is looping/playing, frame rate is set to 60. When I run this on the iPad and open up the profiler I see frame rate on the CPU reported below 250FPS (that’s great!) but then I see spikes that reach to 100FPS (for no reason), some even to 60FPS or even 30FPS (although the latter does not happen often). The graph pattern is such that CPU usage goes low to ~250FPS then after a moment (2-3sec) it rises to a spike. Sometimes the spikes happen in the middle of the 250FPS section (if you take my meaning). When I remove metal and use OpenGL 2.0 I see a constant CPU usage, with metal I see this pattern of spikes and low usage (all over the place). With metal I see this even if I enable the Experimental renderer for metal in the Player settings. My concern is that when I start to add more and more functionality to the game these spikes will grow bigger proportionally.

.

  • Am I the only person seeing this on iOS metal? Or is this understood and accepted behaviour?

.

The bug listed above states that iOS throttles the CPU usage to keep power usage small, then when a frame takes a bit longer to render it get’s caught and we see a spike. In essence it’s like working with a slower CPU for one or two frames. However what I’m seeing in the profiler seems to be all over the place disarray. Another thing I noticed was in Xcode Debug Navigator->FPS. When using OpenGL 2.0 with a device that is not Metal capable it shows the CPU usage that aligns with what Profiler is showing. If I run OpenGL on my iPad that is Metal the CPU in Xcode is 0 (not reported). I assume that this is an Apple bug or it just can’t report in this circumstance. Lastly when I use Metal on the iPad Pro the CPU is always reported at around 16.6ms (which is the maximum for 60 FPS that my game is set at). Doesn’t matter what is going on in the scene the CPU hovers around this area and never goes lower then that. This is not consistent with OpenGL 2.0 reporting with a GL device as noted above.

.

  • Why is the CPU usage reported in Profiler (connected to device) so different to what Xcode is reporting? It seems Xcode is reporting max that I can have while profiler is showing the real value. Anyone else seeing this? Is this Apple or Unity issue?

.

If anyone can shed any answers or at least confirm what I’m seeing I would very much appreciate it.

.

Thank You,
Regards.

.

PS: Sorry about the dots between the paragraphs but the paragraphs are not being respected in my browser. I’m using Safari (latest). Also tried HTML tags but they don’t work either.

we experienced very similar issues. Which includes sample project made by Unity

I think this is a pretty common problem, but funny that not many people share such experience and many will say it’s probably caused by GC. But i wanted to emphasis that we already make the project without GC, but the problem still exist.