Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question GPU and CPU big performance issues

Discussion in 'General Graphics' started by jisase, Apr 13, 2023.

  1. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Hi, sorry for my bad English.

    I am testing for a mobile project and I have encountered major performance problems when testing it on my phone, I will leave below all the data that I consider could be important:

    Data from my phone:
    - Tecno Camon 19 Neo.
    - Android 12.
    - CPU: Mediatek MT6769Z Helio G85 (12nm), Octa-core (2x2.0 GHz Cortex-A75 & 6x1.8 GHz Cortex-A55).
    - GPU: Mali-G52 MC2.
    - 6GB RAM

    Unity data:
    Unity 2021.3.7f1.
    Universal Render Pipeline version 12.1.7.
    Universal Toon Shader for URP.

    Images of the light settings and the "medium" quality asset:

    Light.PNG

    Enviroment.PNG

    URP_Settings.PNG

    Images of the Profiler and the Framde Debug (directly from my phone via cable):

    Profiler.PNG

    FrameDebug.PNG

    As you can see in the images of the profiler, both in CPU and GPU it marks the problems in "Others", however if I turn off the "Others" section the "Shadow/Depth" section is also the same so I tried disabling all the shadows in the scene and the problem only disappeared from the "Shadow/Depth" section but not in "Others".

    You can also see that there is a 48% in BatchRender.Flush > Render.Mesh and Batch.DrawStatic in GPU.

    On the other hand in the Frame Debug I can see that after several optimizations in the Unity Toon Shader settings I was able to reduce the calls from 430 to 138 which is a big difference but still it didn't help.

    I must clarify that I don't have much experience with the profiler nor with the frame debugger in case I have said something nonsense...

    On my PC the game runs at 250fps on average and on the phone it runs at 5fps and I do not understand what is happening, if someone can help me I would appreciate it very much.
     
  2. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,000
    First off you might need to temper your expectations. Looking up the specs of the phone it has a high resolution 1080x2460, but with a mid range GPU, though checking some benchmarks it’s 15% slower than the Adreno 610 in my Oppo A5 2020, that acts as my lowest performance Android test device.

    having said that looking at the profiler it’s taking 9 seconds to render a frame! That appears way off, suggesting that something is seriously wrong somewhere, either in the project or hardware.

    A few things to test
    1. Try running at a lower resolution, add some UI to scale resolution and see if that makes any difference. If performance improves at lower resolution then you are fill rate limited.
    2. Try a different or force a specific 3D api, e.g OpenGL es 3 vs Vulcan
    3. Remove the toon effect completely see if that changes anything.
    4. Search the forums for any issues with the Unity version you are using on Android. Try using a different version of Unity to build the project. Don’t forget to back up project before upgrading to a new version of unity.
    5. Check the abd Android logs, might be a clue in them.

    I doubt with the performance you are showing that 1 will be the issue. Resolution is likely to be a problem on such a device, but I strongly suspect something else is going on, hence 2, 3 and 4.

    if performance still doesn’t improve, then you’ll have to just progressively remove features and complexity from the project to track down the cause.

    in terms of hardware could you be running into low memory issues? Maybe force quit all other apps on the device.
    Is it overheating?
     
  3. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Thank you very much for your reply!

    Now that you mention it, I forgot to say that the only way to make it go at 60 fps on the phone, was forcing the resolution through script with: "Application.SetResolution(x,x,true)" and I put a resolution of 480p and an aspect ratio of 18:9.

    On the other hand the device doesn't overheat, I have left it with the game running for a long time and it doesn't heat up at all.

    I will try everything else you have recommended and see if anything improves.
     
  4. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Hello again!

    I've been working on everything you recommended (except checking the android abd) and I've found that leaving the scene empty, only with: a camera and a directional light, the GPU doesn't change at all and remains exactly the same, but the CPU does change and I could see that it seems to be something with the URP.... I investigated a little and it seems that there is an error in URP that normally happens when you have several cameras, but in my case I only have one (and two virtual cinemachine but also eliminated them for this test) and still continues to occur, I leave an image of the profiler with the empty scene:

    Profiler_2.PNG
     
  5. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,000
    Interesting and good to see you making some progress. I would double check about the camera, maybe add a debug.log to print out how many cameras are in a scene, just in case there is one hidden or hanging about.

    Alas I don’t think there is anything more specific I can offer to help you. If I were in your position I’d probably be making a lot of searches in google for general terms such as ‘urp slow on Android’ and reading every thread that pops up in the hope of getting a ‘lightbulb’ moment. It sounds like you might already be doing that, in which case just keep going, even for threads that might not seem related.

    For example one of the first results I got was this thread https://forum.unity.com/threads/urp-on-mobile-incredibly-slow.1219044/

    Anyway good luck and if you find a simple solution please post your findings in this thread to help others.
     
    jisase and DevDunk like this.
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,396
    GPU profiling can add a lot of overhead. If it's locked to 30 fps it's probably vsync
     
    jisase likes this.
  7. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Perfect, thank you very much for your help!

    I'll keep researching and anything useful I find I'll post here.
     
  8. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Hi, thanks for your comment!

    I have the vsync disabled in all qualities, is there any way to know if it could also be affecting in some other way?
     
  9. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,396
    If you're on mobile, some devices force it on a hardware level
     
    jisase likes this.
  10. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    631
    Hi, have you tried testing the build on another android device?

    Also:
    What's the triangles and vertices count in the Editor's game view stats panel?
    Does the URP toon shader have a geometry shader stage?​
     
    jisase likes this.
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,002
    Use Application.targetFramerate.

    There is, to my knowledge, no mobile device that forces 30fps, everything is 60hz or more.
     
    jisase likes this.
  12. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,396
    Without changing any settings unity vsyncs to 30 fps on my old s8+ if I recall correctly
     
    jisase likes this.
  13. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,002
    Unity defaults to 30 on all mobile devices, there is no hardware that enforces it, it’s a design decision by Unity.

    And by “design decision” I mean Unity just had 30 as a default for decades and they probably can’t be bothered to change it.

    (or actually, with URP being terribly slow by default, it’s probably easier if we keep pretending mobiles can’t handle more than 30fps).
     
    jisase and DevDunk like this.
  14. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,130
    That phone may have been released in 2022 but the technology in it is from 2018. I don't know if that's normal for your area of the world but my phone is a budget tier model from Google that has similarly specced hardware and was discontinued shortly after I bought it. I still wouldn't have thought URP would have any trouble with it.
     
    Last edited: Apr 16, 2023
    jisase likes this.
  15. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    551
    It's worth noting that all your GPU time is spent in EndQueries. So it might just be the GPU profiler that is causing a high overhead. Try closing the GPU Module and see if the EndQueries goes away.
     
    jisase and DevDunk like this.
  16. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Well it seems to be so or something I'm doing wrong, because I decided to leave aside URP to test with the default pipeline and in an empty scene is still running at 15fps and the profiler shows me that it is the Vsync although I have it disabled ....

    Is there any way to disable it from the mobile device?

    Captura.PNG
     
  17. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    I haven't had a chance to try it on another device yet, but I will soon!

    On the other hand as I understand the Toon URP does not have a geometry shader but I have a separate custom geometry shader for the grass, could it somehow be causing the problems? although I must say that even with the scene completely empty it does not go above 15 fps.
     
  18. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Yes, unfortunately it is something common in these parts of the world :c
     
  19. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Yes, always try both ways, with and without the GPU profiler but it doesn't change anything :c
     
  20. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    I've only managed to reach 60fps in 2 ways.
    1. Forcing the resolution via code with Screen.SetResolution(x,x,true) and setting it to 480p.
    2. With an empty scene using URP and Unity version 2019.4.31f1
     
  21. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    631
    I think you can use Application.targetFrameRate to set the target frame rate on mobile platforms.

    Examples:
    Code (CSharp):
    1. void SetToRefreshRate()
    2. {
    3.     Application.targetFrameRate = Screen.currentResolution.refreshRate;
    4. }
    5.  
    6. void SetToDefault()
    7. {
    8.     Application.targetFrameRate = -1;
    9. }
    However, the device's OS may also limit the frame rate of your application. You may check the OS settings or enable performance mode if exists.
     
    jisase likes this.
  22. FunSTW

    FunSTW

    Joined:
    Jun 3, 2018
    Posts:
    7
    Try disabling PostProcessing, HDR, and SSAO in the RenderFeature, and then run it again?
    These features often result in poor performance on mobile platforms.
     
    jisase and DevDunk like this.
  23. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Thanks for your reply!

    So far I had it like this (getting max 30fps with width = 1640 and height = 720):
    Code (CSharp):
    1. void SetConfig()
    2.     {
    3.         Screen.SetResolution(width, height, true);
    4.         QualitySettings.vSyncCount = 0;
    5.         Application.targetFrameRate = -1;
    6.     }
    I will try with the code you have provided me to see how it goes!
     
    Last edited: Apr 26, 2023
    wwWwwwW1 likes this.
  24. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Thanks for your reply!

    I have HDR and SSAO disabled and as for Postprocessing I only have a slight color adjustment, even so I tried to disable it and nothing changed :(
     
  25. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,000
    Have you tried looking at the Android logcat yet? I believe its quite easy in Unity these days with an official Unity package to do that. It would be good to double check that it isn't spewing out errors that might give some indication as to the problem.

    Although from your recent posts while cpu is definitely struggling, its the GPU that's having the real problem.

    Its unclear if you have systematically gone through and disabled various systems to see if any are the cause - e.g. terrain, grass, toon etc. If not, I'd say that is worth a try too.

    As I've said before I wouldn't expect great performance out of such a device, especially at native resolution, but something still feels off with the results you are getting.