I’m building a game for android and wanted to profile my game because I noticed low framerate. When profiling I noticed that clearing the buffer takes 10ms, which is 72%. I honestly don’t understand how it could take that long. I’m using Unity 2019.1.0f2, building for Android and playing/profiling on a Huawei P20 Lite. I’m using the forward renderer (not the new rendering pipeline) and the lowest quality settings.
Any help is highly appreciated. Thanks in advance!
The CPU is waiting for VSync on mobile. It’s actually only working for 2ms and waiting the rest of the time. I’ll include the CPU Usage next time.
I know the Huawei P20 Lite doesn’t have a strong GPU. I’m still trying to actually understand where the time consumption comes from. I want to learn. I’ve created an empty project, set the camera Clear Flags to “Don’t Clear”. I’ve once rendered nothing, then 1 cube, and then 100 cubes. The results:
nothing: pretty much 0 ms
1 cube: ~7ms
100 cubes: ~12ms
I noticed that going from nothing to just one cube incurs a big overhead. Also interesting to note is that once the clear flag was changed, Unity allots the time to Render.Mesh instead, because it actually doesn’t get any faster.
I’m rendering a simple cube with an unlit shader which has nothing but a color property, and Unity tells me it takes 7ms. I assume that there is some initialization happening in the background that Unity doesn’t tell me about, which takes a lot if time, and Unity simply adds it to the ms of whatever calls it first. First it was Clear, now it’s Render.Mesh.
I’ll just accept that profiling the GPU isn’t as transparent as it could be and work with what I have.
It can be more transparent if you use vendor-specific profilers, one from ARM in your case.
I’m pretty sure that the data you get in the Unity profiler for the CPU time is accurate. If the CPU is waiting for VSync that much, then it has nearly nothing to do for it. The GPU might’ve finished the work already as well, but there’s no possibility to turn VSync off on mobile. As long as you’re hitting your target frame rate, you’re good
So, if cpu is waiting for vsync for too long, there is nothing i can do to solve?
I have the same problem btw. Getting 11 fps on low-middle spec android phone (but it can run other games smoothly). Scene and Models are not complicated. I couldnt find why the game is lagging too much.