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. Dismiss Notice

Low FPS in build (slow game), fine in editor. Can't find answer! (Mac, but also PC)

Discussion in 'Editor & General Support' started by zngb, Nov 3, 2017.

  1. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Hello fellow Unityiers.

    I have this issue I can't overcome. Looked in the forums, Answers, Google... hell, even asked on the IRC channel. No solution. Skim to interesting for the interesting part.

    When I run my game in the editor, it runs smoothly. When building and running the build, it runs real slow (low FPS). This now happens on my MacBook Pro. It also happened on a PC laptop I tried. Fine in editor, bad in build.

    The PC seemed to be problematic however (Windows 10, NVIDIA-something-decent). I tried running a benchmark-test-application to see if it's only my game or an OS thing but that app ran also like a sick grandma. I figured the OS is pigeon-poop because I played around with it too much and went on. The MacBook Pro is what I want to fix right now.

    On my main machine, PC with Windows 10 and an NVIDIA GTX 1070, the game runs smoothly both on editor and build.

    interesting: Running the profiler I get that the function `gfx.WaitForPresent` is taking most of the frame time. That means v-sync stuff as I read in some dark places on the web. I tried disabling v-sync in the Quality settings of my project and build again (on the MacBook) but it still ran like a sick grandma.

    So there, I'm a bit lost. I'm not sure if it's a Quality setting or the OS deciding not to run with hardware acceleration or whatnot... Please provide your input.

    I hope I can fix this.
     
  2. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    709
    Divide and conquer! create a backup, and then try deleting elements in your scene until you (hopefully) delete the object(s) causing problems. If you find that after deleting all scene objects and the problem still exists, you could try creating an entirely new project and just building the blank scene. Depending if a blank project does the same thing might help you (and others) to narrow down the list of suspected culprits.
     
  3. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Will definitely try. I'll report back. Thanks!
     
  4. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    395
    Make sure it's using the same graphics API between editor and build.
     
  5. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Hi @daxiongmao, how would I do that?

    I still didn't get to 'dividing and conquering', will do.
     
  6. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Hi, I finally got up some alone-minutes with the Mac. I disabled all objects in my scene but the player controller (based on Unity's standard assets + some mock gun), I disabled all post processing effects I have on the camera, and I made a plane and four cylinders so I can stand upon and see if the movement is jerky.

    It is.

    It was mentioned above I "make sure the same graphics API is used between editor and build" - I'm not sure what to do with this advice, to be honest... an explanation maybe?

    Here's a screenshot of the profiler on the Mac build running jerky-ly with the first person controller running around aimlessly on the plane with the four cyilndars of doom.
    Screen Shot 2017-11-10 at 23.37.25.png
     
  7. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Hello, still no luck.
    I went to the player settings and ticked off the Auto Mac Graphics API. I tried both available settings I had (screenshot) and both had bad performances on the full scene. With the scene simplified, the perfromance was better with the OpenGL chosen. I still saw gfx.WaitForPresent spikes in the profiler, but they were "only" 18ms so the game seemed smoother (remining it is the player, plane, and 4 cylinders).

    I will try a scene from scratch, or a game from scratch, etc. For now, please give me more ideas on what to check if something pops to mind. Thanks.
     

    Attached Files:

  8. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    gfx.WaitForPresent is when the CPU has finished its job and is waiting for the GPU to catch up. Macbooks are not known for having great graphics, and Nvidia-something-decent doesn't help me understand what you're working with :)

    For me, that was actually the most interesting part. If the benchmark test ran badly, why do you expect your game to run well? Did you run the benchmark on the MacBook or Windows? It would be nice to know what hardware you have (on Windows, open the Search and type "dxdiag"). CPU and RAM (on main page) and GPU(In the Display tab) is what I'm interested in. Also, on the latest update of Windows, in the Task Manager you can see how much GPU power is being used. If during the game it shows 99% GPU usage, that's a problem.

    The last thing I can think of is to try to make another empty scene IN THAT PROJECT, drop in only your character and a few primitive objects and see how the performance is. If it's bad, try a new project with the same basic scene type and see what the performance is like.
     
  9. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Hey @DroidifyDevs
    While I can't answer some of your questions regarding the hardware used (at the moment. Computers not available.), I did make the empty scene tests. Stuff is interesting:

    (MacBook->) An empty scene on the project with some game objects yields a slowness with WaitForPresent. So as suggested I tried a new project from scratch, imported some silly model from the asset store and duplicated it to make my MacBook sweat. Same result! Slowness also appeared here. Reminding that this is build only. In editor I get good results and the profiler doesn't show WaitForPresent as a blocker, only seemingly regular methods at work.

    Another interesting thing I noticed which might help debug this, is that WaitForPresent occurs in spikes. Most often, they happen every ~3 frames. Then after some time it happens continuously for a few frames, then back to 3-4 frames. Is this a clue to anything?

    Again sorry for late responses. I'm not on this 100% fulltime. I only have a few hours here and there to play around with this.
     
  10. johann755

    johann755

    Joined:
    Oct 30, 2017
    Posts:
    1
    For me, build is very slow when V-Sync is disable
     
  11. jhonk

    jhonk

    Joined:
    Feb 23, 2015
    Posts:
    1
    hello .. I have a solution ... in the construction make sure you mark the architecture correctly. Captura.PNG
     
  12. jo_achim747

    jo_achim747

    Joined:
    Oct 8, 2018
    Posts:
    4
    Hi, I am facing the same issue on a MacBook Pro 2018.. It should run fine, since it should not be too hard for the Mac to render my scenes.

    Have you tested around with Post Processing and / or the HDRP? I did and thought possibly it could be caused by them (although I completely removed them from the project)...

    Do you have a solution by now?

    Best regards,
    jo_achim747
     
  13. zngb

    zngb

    Joined:
    Aug 5, 2015
    Posts:
    20
    Hey @jo_achim747
    Sorry but I don't have that Mac anymore and never resolved it on it. If you're interested I think I can initiate a Mac cloud build for that project so can try running it if that might help in any way :thinking:. I think I have that project lying around here somewhere...
     
  14. jo_achim747

    jo_achim747

    Joined:
    Oct 8, 2018
    Posts:
    4
    Thanks for your response. But I do not think that this would allow for further insights, especially if you have not come to a solution either...

    Nevertheless, thank you very much for your kind offer! I really appreciated it.

    Best regards and success with your other projects,
    jo_achim747
     
  15. jacobleaney_unity

    jacobleaney_unity

    Joined:
    Sep 6, 2018
    Posts:
    8
    Just in case anyone comes across this thread in future, I ran into two issues/fixes of a similar nature (slow FPS on mac build vs. Unity editor) that are something good to look at at least to start with, if you've optimized your scene well:

    1. I was running my game mode in the editor at the correct resolution for my mac (2560 x 1600), but NOT set to maximize on play, so the frame buffer in the editor was lower than in the build. My solution was to force the build to run at a lower res (1920 x 1200) instead of native res (2560 x 1600) on 13" macbook pro with retina display.

    Will always test performance in editor using maximize (or setting the window manually) from now on.

    2. I had Mac Retina support toggled on in the Player Settings. Turning this off increased my frame rate by 10-15 fps in my build (albeit at the slight expense of image crispness).
     
    SpencerGreller likes this.
  16. SpencerGreller

    SpencerGreller

    Joined:
    Oct 13, 2015
    Posts:
    3
    Thank you!
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,503
    Issues like these are most often caused by weak GPU coupled with running game view in Unity at low resolution and running the game in fullscreen at native/high resolution.
     
    Joe-Censored likes this.
  18. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    It can also be impacted by running different quality settings in Editor vs in Build.
     
  19. ParhamXTT

    ParhamXTT

    Joined:
    May 24, 2020
    Posts:
    28
    I havw this issue and I can not solve it.
    CPU : Intel Core I7 10510u
    GPU : Nvidia GeForce GTX 1650
    RAM : 16 GB
    Resolution : 1920 x1080 @ 60 Hz
    OS : Windows 11 64 bit
    Integrated GPU disabled to increase RAM accessibility for the CPU.
    CPU usage : 26 percent
    GPU usage : 11 percent
    RAM usage : 9 GB out of 16 GB
    GPU VRAM usage : 1.9 GB out of 4 GB
    Build FPS : 3 to 7 FPS
    Editor FPS : 50 to 130 FPS
    please help. thank you very much.
     
  20. ILoveNachos

    ILoveNachos

    Joined:
    Mar 19, 2022
    Posts:
    1
    I had this problem and it turned out to be caused by too many "Debug.Log"s.
    There's probably a limit to debug's in the editor but not in the build.
     
  21. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    395
    Most of the issues if related to resolution mentioned above mean your shaders are too complex and possibly texture memory is to high or using to high of settings or no mipmaps etc. And causing the GPU to swap out memory. 4GB of ram in the previous post is not much by todays standards.

    Try building in window mode and scaling the view down and see if at some point it speeds up. The will tell you if your are fill rate bound (shader / gpu) vs vertex bound more cpu vs gpu and just trying to draw too many models (draw calls).

    The GPUwait for present I believe could be say your cpu renders it all in 10m and you are vsync enabled with a refresh rate of 60hz / 16ms. So it will wait 6ms to present.

    It can also happen were you are vsynced and a few frames here and there take 17ms. causing it now to wait until the next vsync giving a big spike of 15ms. Since it had to wait for a second frame to present.

    The profile above seems like its maybe set to every other vsync at 30fps refresh rate. So getting 15fps renders.

    Quality settings is another one. Lots of versions of unity just like to change the default settings randomly.

    I don't use mac a lot but there are various emulation settings in the editor. And I think can tell editor to use say DX11 on PC, but build for vulkan. On mac I would expect they use the same. Some iteration opengl / metal backend.