Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Profiling and optimisation tips for mobiles

Discussion in 'iOS and tvOS' started by Mantas-Puida, Jan 16, 2018.

  1. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    We would like to share "Mobile performance handbook: thermal stability" prepared by our Mobile team.

    This presentation is aimed at mobile game developers making games with Unity to:
    • help understanding why mobile performance is special
    • provide guidelines on how to reliably measure performance on mobiles
    • provide guidelines on how to optimize games for mobiles
    <teaser>

    </teaser>

    Note: slides include quite a lot of helpful information as commenter notes, best viewed in Powerpoint or Keynote. Google Docs also works (best in Edit mode)

    Link: https://on.unity.com/2Di8Hl7
     
    Last edited: Jun 24, 2021
  2. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thank You for the information. Quite interesting. I was wondering if you could comment on CPU throttling not caused by temperature. What I found profiling for iOS is that in stable condition there can be wild CPU variations. Also CPU always seems to be the bottle neck and not so much the GPU.

    I could have a game just sitting there without any user input and nothing happening in the scene. Watching CPU I would see a temporary spike for a frame or two from 7ms to 13ms. I see this kind of behaviour happening all the time running on iPad Pro 9" (so pretty recent device). There is plenty of CPU power available but seems the work distribution is not evened out and these spikes occur every few seconds. This is most apparent when camera moves since a missed frame is most visible in this scenario.

    I've tried getting to the bottom of this and was able to confirm in Instruments using Metal monitor instrument that frames did indeed get dropped, but I was nowhere near CPU limit of the iPad (nor on the GPU). I've spend many, many hours in trying to debug this, at the end I came up with two possibilities. Either the CPU is getting throttled down for a duration of few frames and then it revs up, or there is a thread contention in Unity at that moment. I've implemented an additional thread executing NOPS that would keep the CPU artificially busy in order to prevent it from being throttled down but that did not work, I saw even worse performance in this case. Because this happens intermittently it's difficult to debug. Typically when these types of spikes occur from what I can gather is that Unity is blocked waiting on a thread but there is plenty of CPU power available. I would be interested if this behaviour has ever been seen by anyone else. From my tests I think it's a thread contention in Unity but I can't prove or debug this without source, perhaps someone smarter than me has some ideas or suggestions. By the way I'm using Unity 2017.4.10f1.
     
  3. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,311
    if your idle scene is generating garbage, GC would kick in occasionally
    you can verify this by profiling using unity profiler
     
  4. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    I wish that was the case but no GC is going on. Thanks.
     
  5. mrwellmann

    mrwellmann

    Joined:
    Nov 27, 2015
    Posts:
    39
    On my iPhone SE (2nd gen) the default (Application.targetFrameRate = -1) FPS is 60 and not 30.
    Did you Apple change this or is there some setting I'm not aware of?

    Also setting Application.targetFrameRate to 30 does not change anything device stays 60 FPS. Can you con frim that this should not be the case and I'm doing something wrong?
     
  6. mrwellmann

    mrwellmann

    Joined:
    Nov 27, 2015
    Posts:
    39