Search Unity

High FPS in Profiler while actual FPS on android device is very low

Discussion in 'Android' started by kendogar, Apr 29, 2020.

  1. kendogar

    kendogar

    Joined:
    May 24, 2016
    Posts:
    10
    Hey,

    I have this issue that confuses me a lot:

    I'm developing a mobile game using Unity 2019.1.14f and am currently testing the game's performance on device.

    First I tried to run the game on my iPhone 8 and I'm having solid 60 fps constantly. Then I changed the build target to Android and did run the game on my Huawei P20.

    Now the confusing thing is: The on screen fps counter I'm using shows around 13fps, but you don't even need that to see that the game is lagging like crazy. I've attached the Unity Profiler to the device while it is running and the profiler states that the game is running at nearly 60 fps (target framerate is set to 60 for this test). The last time I've had this issue was due to me using the post processing stack which threw thousands of exceptions per second on my android phones due to incompatibility issues, but this is not the case here. Using adb logcat there are no errors popping up.

    I have the feeling that I'm missing something very basic...

    TL,DR: Why is my game running at roughly 12 - 15fps while the profiler states it is running at 60fps ?
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    Did you check if any of the CPU Usage Profiler Module's chart labels have their little colored squares disabled (black)? That might be hiding time in the graph from you. What does the Profiler window show for you?
    What does the toolbar of the CPU usage module state your CPU time was?
    What does Timeline view show about how long it took to finish the frame?
     
  3. kendogar

    kendogar

    Joined:
    May 24, 2016
    Posts:
    10
    Thank you for your reply.
    I've attached a screenshot of my Profiler window and I now am quite positive that I don't really know how to properly read it in order to fix my android performance problems...
     

    Attached Files:

  4. kendogar

    kendogar

    Joined:
    May 24, 2016
    Posts:
    10
    Well adding a "GPU Usage"-Profiler showed me that naturally not only the CPU Usage is relevant. This very much showed me that the GPU is the bottleneck in my case.Thanks for pointing me in the right direction, I assume that my question is answered (and new problems have shown up :) )
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    No worries. In your version of Unity, that is no longer supported and therefore won't receive bugfixes, there's still two bugs:
    1. that time spend in the Others category will only show up on the graph, if a sample is selected
    2. That the grey Semaphore.WaitForSignal sample is attributed to Others, instead of two whatever it occurred in.
    These are fixed on 2019.3 and iirc 2019.2
    So yeah, your version sadly happens to be hiding time spend on the Render Thread (while rendering or waiting for the GPU to finish) when only looking at the CPU usage graph. The time shown by Timeline view fits though. 35ms for this frame and probably more for some others and you'll get the FPS you see in your on screen fps display.
     
  6. kendogar

    kendogar

    Joined:
    May 24, 2016
    Posts:
    10
    Thanks for the heads up, I guess I should upgrade to 2019.2, but I'm kinda scared of breaking things for my current game prototype by upgrading...

    Anyways! While my original question is fully answered, I looked into the time my game spends rendering things in order to find out what slows everything down (turns out it is Opaque rendering) I've noticed that for most frames the engine spends around 29ms in the "Clear"-Step of RenderForwardOpaque.Render. Do you know what this means and how I can work on that?
     
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    I'd actually suggested to upgrade to 2019.3 as 2019.2 has lapsed out of support as well.
    2019.3 is in pure stabilization phase and moving towards LTS, i.e. 2 years of support with only receiving bugfixes and platform ask updates (to allow people to continue deploying to these platforms). But yes, make a backup before you upgrade.

    Regarding the clear time, not off the bat. Is that in the render thread, main thread or on the GPU?
    Also there's a lot of material on learn.unity3d.com on how to optimize rendering and GPU usage. I have a feeling that, just going through some of the commonly advised practices is going to help you get that time down.
     
  8. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    BTW, one difference between the Huawai P20 and the iPhone 8 is the amount of pixels on the screen. Now, there's also different GPUs and generally comparing Metal vs OpenGL/Vulkan that can have an affect, but it might hint at that you are fill-rate bound.

    Unless you meant iPhone 8 Plus in which case the pixel difference isn't quite as huge.
     
  9. kendogar

    kendogar

    Joined:
    May 24, 2016
    Posts:
    10
    So I've spent some more hours optimizing yesterday and without going into too much detail the takeaway is that I have much to learn concerning rendering optimization and what does and does not work on mobile phones.

    At the end of last evening, I've managed to reach 50 - 60 fps on all of my testing devices, allowing me to have stable 30 fps for all my android devices. The biggest impact was shadows, deactivating those gave me almost 25 fps so I've replaced them with a handful of custom blob shadow sprites below the characters, which the type of game I'm developing perfectly allowed.

    Thanks again for your support and especially for this reminder: "BTW, one difference between the Huawai P20 and the iPhone 8 is the amount of pixels on the screen."
     
  10. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,452
    you're very welcome, glad I could help and happy to hear that you managed to get your game's performance back on track. :)