Search Unity

Sudden dramatic loss in frame rate

Discussion in 'UGUI & TextMesh Pro' started by jmansa, Feb 12, 2019.

  1. jmansa

    jmansa

    Joined:
    Apr 13, 2012
    Posts:
    75
    Hi, I have build an (utility) app only using Unity UI. I have set my init.cs file like this:
    Code (CSharp):
    1. int target = 60;
    2.  
    3. void Start()
    4. {
    5.     #if UNITY_IOS || UNITY_ANDROID
    6.     Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes");
    7.     #endif
    8.  
    9.     QualitySettings.vSyncCount = 0;
    10. }
    11.  
    12. void Update()
    13. {
    14.     if (Application.targetFrameRate < target)
    15.     {
    16.         Application.targetFrameRate = target;
    17.     }
    18. }
    For some reason, and with no real pattern, other than it often happens when something else is happening on the phone, like a push notification from another app, Using the camera, or coming back from pause, the frame rate drops around 25 - 35 fps and it stays there.

    How do I avoid this, and maybe better. How do I force it back into the right frame rate?

    Here is my profiler dump in which you can see the dramatic jump in frame rate (without the spikes) just after using the camera in the app.



    Really hoping for help on this, since it makes the app useless if i cant fix this :)

    Thanks in advance :)