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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Slow android build from unity 2022 compared to 2020

Discussion in 'General Discussion' started by mavv, Jan 9, 2023.

  1. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    Hi!
    Some time passed, and I wanted to return my adventure with Unity :D
    I stopped at Unity version 2020.1.13f. In meanwhile I changed PC, and built new system from zero. Now I downloaded Unity 2022.1.23f1 and happily build android APK package. There are a few errors (in my code) to repair, but overall - new version didn't crash or broke all of packages which I use, including cinemachine etc.

    I have also older version of apk installed on my phone. Newly builded game is much slower on this same phone. I suppose that there are new settings or features, and maybe they slowed down my game. On what features / problems should I look?
     
  2. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    General advice, don't use 2022 until there's an LTS version.

    .1 minor versions are basically open beta. .2 versions will add a ton of bug fixes, sweeping changes, and still have a lot of issues. .3 versions will be usable, .4 will be mature.

    It has been this way for at least 10+ years. I'm still on 2021.3 LTS
     
  3. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    Thank for sharing this.
    So you suggest that it's better to use 2021.3 LTS, and I don't need any new features from newer versions / optimalisations / functions? There is no crucial advantage of using newer versions?

    I have full backup from version 2020, so theoretically i can try it. I even tried install 2020.1.13f but I had troubles with lack of some SDK/NDK/java things for android build.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,020
    Not sure if that was the joke, but we don’t have .4 releases any more :)
     
    PizzaPie and lmbarns like this.
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,020
    The idea is that whatever advantages there might be, are generally outweighed by the disadvantages.
     
    Last edited: Jan 9, 2023
  6. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    433
    It depends.
    I guess you are using the build-in renderpipeline?
    In Unity 2022+ you are probably better off using URP I think.

    Anyway, regarding your case, I would start with checking shadow-settings like shadow-distance, light-sources in general and maybe VSync..
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,020
    For faster build times? I don’t think that’s true.
     
  8. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    433
    Did I miss something in the questions? I thought it was about the game running slower on the phone - I am sorry if I misunderstood the question ^^.
     
    angrypenguin likes this.
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,020
    Hmm maybe I misunderstood the question. I was under the impression OP was talking about build times, but maybe he isn’t.
     
  10. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    Game just slowed down, frame rate is bad. It's independent from shadows or texture size. I already implemented switching these, but even on lowest settigns is still slower, than best setting from 2020.

    I don't mean build time at all. I think this isn't changed much. I didn't even measured this :)
     
    AcidArrow likes this.
  11. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,763
    There's no reason for there to be a sudden severe slowdown in BiRP anyway.
     
  12. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    You mentioned that there are errors in your code. Is there anything in those which would cause more work? E.g. objects constantly trying to do expensive initialisation which fails? Or even just spamming log messages?
     
  13. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    @angrypenguin It's moslty timing problems. Nothing with graphics.
     
  14. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,516
    It doesn't need to be graphics to slow everything down.
     
  15. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,775
    Profile and see what's up. Could be anything at this point.
     
    angrypenguin likes this.
  16. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    Code on both builds is the same, but of course, there can be something new approach to achieve "things" and this is what i'm asking, what possibly could be done in new way between 2020-2022? Maybe there are new crucial settings, which default setup would slow down everything?
     
  17. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    I discovered main problem with proper timings. In editor i have about 800fps, but if I turn on vsync like there:
    Turn on vsync in the editor Scene window.
    everything is played at correct speed on forced 60fps. But I think this can't be real issue with it and without doubt it must be solved later.

    I installed 2021 LTS, and also there is fps drop. Installed then 2020 LTS, and again from backup, this same project, don't suffer anymore.

    Funny thing is, in Editor I have about 400fps in 2020, but almost 800 in 2021 (in stats) :)

    Still, app launched in phone suffers by much fps drop. So this is caused by some change made between 2020 and 2021.
     
  18. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    118
    Are you building with Vulkan api? I believe it is enabled by default and will slow frame rate for certain android devices.
     
  19. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    I don't have Vulkan on available list. There is only:
    • OpenGLES3
    • OpenGLES2 (Deprecated)
    in this order.
    Oh I see, i need to add Vulcan. Did it, but result is the same.
     
    Last edited: Jan 11, 2023
  20. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    I extracted "intro" scene, deleted almost everything to testing, and it's still bad. Please, maybe you can find what is wrong?

    [edit] never mind
     
    Last edited: Jan 12, 2023
  21. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,005
    Do not rely on the in editor framerate, it is notoriously unreliable in general as the editor itself will have an affect and certainly not between versions of Unity as they keep trying to improve it, possibly by trying to discount editor impact, but doing so means it can have little relation from one verion to another.

    Whilst not unheard of a new version causing issues due to new settings, i'd take the advice of PanthenEye above, you need to profile and monitor the log output to see what's up.

    If there was a specific setting that could cause this i'd assume someone would have mentioned it by now, that leads to assuming its something specific with your project. You mentioned you had to fix errors, so there could very well still be some errors in the build that aren't present in the editor and the slowdown is simply from logging those errors. Alternatively there might have been a regression is some api or graphics, which profiling will most likely highlight.

    No one here can guess what those are, you need to profile and check the logs. However we can probably help if you get some useful data on where things are slowing down in the build.
     
  22. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    Noisecrime - as I said before, problems will be fixed. I reduced scene to minimum, with just few models and particles, and still problem exists. Withoun any error in my code (as I hope of course :) ) You can download scene from post above and took a look. I think, like you said, this should be a "stupid problem" with one crucial setting, but I can't find anything suspicious.
     
  23. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    Hm. I created now almost blank new project. With one cube and 4 spheres, with shadows. This simplest scene ever ALSO HAS BIG PROBLEM WITH FPS ON PHONE!
     
  24. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,020
    Are you setting the framerate to something over 30? It's 30 by default.

    If you used to do it with VBlanks, that method no longer works in 2021 and after, make sure you call Application.targetFrameRate = 60; somewhere.
     
    Noisecrime and mavv like this.
  25. mavv

    mavv

    Joined:
    Feb 4, 2014
    Posts:
    29
    I remember that I wrote this Application.targetFrameRate = 60; and then removed it because some reason. Sadly I can't remember why. It was mistake :D
    This solved everything.. what a shame on me! But anyway, thank you!! Case closed :D
     
    Jmonroe and AcidArrow like this.