I’m having stutter problems every five seconds or so in my game on iOS. When connected to the profiler I see that Camera.Render creates some spikes and I don’t know why. Here are screenshots of the profiler:
Showing four spikes, three of them from Camera.Render, one from GFX.WaitForPresent
Any idea of how I can find out where the spike comes from?
Setup:
Unity 5.6.0f3
Linear Color Space
Metal Graphics API
Run on iPhone 6s Plus
No Shadows
Deactivated Post Processing effects
I don’t see those spikes on Android and if you look at the parts that are not spikes I would say we got quite good performance with room to fill. It also is not the garbage collector, no instantiation is happening during the game, everything is pooled.
I tried to dig deeper with Instruments, but I don’t really know how to allocate the problem there either, the values seem quite normal/good.
Quick update: I did notice that the game does not show this stuttering when using OpenGLES3 rather than Metal. This however limits our possibilities for post processing effects, so I would like to stick to Metal. I made another project to test some of the shaders as well as loading and unloading of meshes, sadly I couldn’t reproduce the problem.
Anyone else experiencing spikes with metal? What can be the cause for this?
Just to be clear: With Camera.Render in self? Or something like GFX.WaitForPresent? If it’s the latter one, you are doing gpu heavy stuff, so the cpu has to wait for the gpu.
If it is like in my case, I’m wondering how your stats are (Screenshot of the Rendering info like draw calls would be interesting).
Also, what plugins are you using? Maybe we can find a common enemy. I didn’t find a definitive solution, I did do a lot of refactoring and it got better, I didn’t profile the game lately, but I still see some spikes with Rendering in self eating up a lot of CPU time and still can’t quite tell how to interpret that information.
This is a screenshot of Deep Profile from the iPhone 6S using OpenGLES2. We are using few custom fonts in the scene and the only plugin is Vectrosity from the Unity Asset Store (Unity Asset Store - The Best Assets for Game Making)
Looks like I have the same problem, but I’m having spikes every second when there is enough graphic load to drop fps from 30(limit) to 28. This happens only on ipad air first gen.
Switched to gles3.0 and spikes disappeared, but fps dropped to 10-15.
@ilyad :
Oh wow, that looks bad. Maybe this is a problem with the iPad model? Are you able to reproduce this with an empty app? Did you file a bug report?
@terence410
Hi and welcome to the forum. Did you profile on the device? If so, take screenshots like I did with the specific entries that create the overhead. Something “similar” can have very different root causes.
Hi Eyal,
saldy I can’t give you a definitive answer. We started showing all objects in the game in the loading screen so we can be sure that all shaders, textures and meshes are loaded to the GPU. This seemed to help, but we didn’t get rid of the problem. At that point we also hadn’t had the time to profile precisely, so we just went with our gutt feeling that it helped. Really interesting that your BatchRenderer.Flush takes such a long time even though you have so little draw calls… Did you take a look at the profiler timeline of that frame? Seems like something is blocking the thread I would say. Please keep the thread updated if you have any progress!
It is funny that they add tons of performance improvements tricks - that are ON by default - but have tons of issues with them… This I guess is the one thing I don’t like about unity…