4
\$\begingroup\$

I have a simple unity scene with some primitive objects like cubes and spheres. Most of the objects are static and I made backed GI for lighting, The light is a point light. I also used unity post-processing asset for the depth of field.
FPS in normal game window size is about 500 but when I maximize the Game tab, FPS goes around 30. Why does this happen?

FPS 500

FPS 30

\$\endgroup\$
  • 1
    \$\begingroup\$ Curiously, it looks like most of your time is spent CPU-side. What profiling have you done so far to see what the CPU's taking its time on? \$\endgroup\$ – DMGregory Oct 31 '17 at 13:24
  • \$\begingroup\$ Yes, You're right, It's basically related to CPU, I did some profiling and find out when I maximize the Game Tab, There's spike happened in unity profiling related to Rendering in CPU Usage. It seems that a function called GFX.WaitForPresent causes this issue! \$\endgroup\$ – Emad Nov 1 '17 at 12:39
  • 1
    \$\begingroup\$ I suspected that might be the case, seeing as it landed almost exactly at 33ms. WaitForPresent is not actually a function taking a long time to process, it's the CPU waiting for the vertical sync of the monitor. Some uses of render targets can cause it to kick in even when you have VSync off, but I don't know all of the details myself. \$\endgroup\$ – DMGregory Nov 1 '17 at 12:42
2
\$\begingroup\$

Most likely reason is that you have VSync turned on for your game. VSync (vertical synchronization) will only ever work for a game if it's in exclusive full screen (which is what you're doing by maximizing). You can change this setting by using the QualitySettings option for VSync. Taken directly from the link I've provided. This Example() function should only ever be used when VSync option is wanted as turned off.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        QualitySettings.vSyncCount = 0;
    }
}

You can also turn it on or off in the default Quality Settings here (using menu: Edit > Project Settings > Quality).

enter image description here enter image description here

Both pictures taken from Unity's linked pages, since Unity sometimes likes to change the current manual and deprecate links or images.

There's also one more setting that could affect target framerate. Try setting it to a high value.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Awake() {
        Application.targetFrameRate = 300;
    }
}
\$\endgroup\$
  • \$\begingroup\$ I did try that, Doesn't work, still FPS drops! \$\endgroup\$ – Emad Nov 2 '17 at 12:17
  • \$\begingroup\$ Then i think it is a performance issue with Unity. If you have the latest version of the engine, please report this "bug" using the Unity Bug Reporter program that you find toghether with the Unity.exe file. If you don't have the latest version of the engine, try to install the latest one, and if the bug persists, please consider reporting this bug. \$\endgroup\$ – user100681 Nov 2 '17 at 12:29
  • 1
    \$\begingroup\$ @Emad Some monitors will force VSync on, sometimes your GPU might also force VSync on. I suggest checking those as well. \$\endgroup\$ – John Hamilton Nov 2 '17 at 12:58
  • \$\begingroup\$ @John tried that, doesn`t work neither! \$\endgroup\$ – Emad Nov 2 '17 at 14:14
  • \$\begingroup\$ @Emad Added one more setting that could affect framerate. Also, if you're using any packages from the Unity store, they might also be messing with the settings. Check if the same thing happens in a clean project (after setting the relevant settings as suggested in the post). \$\endgroup\$ – John Hamilton Nov 3 '17 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.