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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Lag on android build but not on PC?

Discussion in 'Android' started by peq42, Apr 22, 2022.

  1. peq42

    peq42

    Joined:
    Mar 4, 2022
    Posts:
    73
    So, I'm trying to export my very simple first game to my phone(made using the latest stable version of unity).

    On my PC, the game runs at an average of 200FPS(each frame taking an average of 5ms to be done, with occasional 16ms spikes, and big spikes that happen on scene change, but that I don't really care about)

    Profiler pic:


    The issue is, while the game runs perfectly on PC, on my phone(Moto G9 Play, with a Snapdragon 662 and 4GB of ram. Which is a intermediate phone) the game feels like its running at 30fps or maybe lower.

    I tried everything I've learned so far to optimize it: I'm using IL2PP, Burst AOT set to performance, half resolution textures on android, preloading heavier objects, URP, targeting export to android 9 and above(and ARM v7 and 64), fast compression method on textures, using Vulkan instead of OpenGLES 3(which I do believe is faster ?), etc but so far it seems to still be laggy.
     
    Last edited: Apr 22, 2022
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Have you set it to run at more than 30fps? Unity limits mobile games to 30fps by default for arbitrary reasons that no longer make any sense.

    If you’re using 2021, just set Application targetFramerate to 60.

    Vulkan is not faster than gles 3.0 on average, but it depends on the device.
     
    LogicFlow and peq42 like this.
  3. peq42

    peq42

    Joined:
    Mar 4, 2022
    Posts:
    73
    Already tried that, but performance is the same
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Connect the profiler to the device and see what’s eating performance.
     
    peq42 likes this.
  5. peq42

    peq42

    Joined:
    Mar 4, 2022
    Posts:
    73
    I have yet to do this, but wanted to make an update: Apparently although my PC was fine with anti-aliasing and Post Processing, running at about 200 frames/s, removing it gave my phone an extra 20FPS(its running at around 45-50fps).

    I'll try the remote profiler, but in the meanwhile I appreciate any extra tips!
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Ah, yeah, all Unity supplied post processing isn't fast enough to run well on mobile.
     
    peq42 likes this.
  7. Saeid_Namdarii

    Saeid_Namdarii

    Joined:
    Jul 25, 2021
    Posts:
    4
    do you fix it ?? i have this problem too !!!
     
  8. Saeid_Namdarii

    Saeid_Namdarii

    Joined:
    Jul 25, 2021
    Posts:
    4
    hey thanks for your help ♥
    Application.targetFrameRate = 300;
    its worked
     
  9. Saeid_Namdarii

    Saeid_Namdarii

    Joined:
    Jul 25, 2021
    Posts:
    4
    use this

    Application.targetFrameRate = 60;