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

Bug Extreme FPS Drops In Build

Discussion in 'Editor & General Support' started by TragicallyCanadian, Jul 28, 2023.

  1. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    Hello everybody. I've recently been pushing builds of our project, and I am experiencing some strange stuff, specifically regarding performance after a build is created.

    So, in the editor the FPS is very consistent. I can have 10-20 enemies on screen and it generally stays over 100. Here's a gif to showcase an example.
    (There's 10 enemies here but some are inside of the others models because I just quickly spawned them)

    https://gyazo.com/9a72b5ceb820d26da687800e13dcbe15

    I do a build, and spawn 10 again, and the FPS tanks massively.

    https://gyazo.com/2741791711e7c0c85e68a49f0bafffe6

    I am running the project in the editor and in the build at the same resolution. Is there something I am potentially unaware of? This is my first time profiling a build of the project that isn't just inside the editor. What is confusing to me is why it acts this way as a build, but not in the editor.

    attached is a screen shot of the profiler during the initial spike. Any advice would be much appreciated. Thanks for reading.
     

    Attached Files:

  2. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    Update: If I press "Record" on the profiler, to begin profiling and then turn it back off the FPS is stable and plays like it would in the editor. The problem is it only becomes "stable" if I do this. Otherwise it never corrects. What could be causing this? Does anybody have any idea?
     
  3. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    Do you change any render textures or camera settings or change any settings when getting close to the NPCs?
    Tried deep profiling?
    Updated Unity already?
     
  4. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    Negative!
    I have, getting somewhere. (Kinda?)
    Yep, 2022.3.5f1 LTS.

    For anybody who maybe experiencing problems like this in the future who finds this thread..

    So after some digging, I remembered the NetworkManager (I am using Netcode for Gameobjects) prints messages to the debug log every tick. I set the "Log Level" to "Nothing." And this helped a bit. Debug logs are expensive.

    For anybody using TMPRO; if you have a lot of text in your scene that is set to auto update, this can also cause pretty big spikes, avoid that if possible and tick the box "is Scale Static" under "Extra Settings".

    Still not sure why this only effects the build, and not the version in the editor. Maybe somebody who knows could chime in and explain.

    Problem still not fully solved though, I am now getting this in the Profiler. I assume it's coming from the NetworkManager of "Netcode For Gameobjects".
     

    Attached Files:

  5. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    Here's a gif, basically when I go into the build the starting FPS is about 140. In the editor it's above 220.

    When I toggle the "Profiler" On and Off the FPS goes to around the same level as it is in the editor, but only if I toggle the profiler at least once.

    Gif below
    https://gyazo.com/8e1eb41fc06912bd3306dbecdd086ec9
     
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    Good progress. Logging is fairly expensive yeah, you can also completely disable it in C# for release builds.
    And canvases can also be performance heavy if they are refreshed yes
     
  7. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    Unfortunately at this point I am at a loss. I've exhausted every angle I could think of. I even disabled every NPC and character on the map. The frame rate still stayed the same. With just a camera viewing the walls, it still was lower upon launching the build.

    EDIT: The player character was also disabled.
     
  8. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    Another shot. No idea why this is happening or what is causing this. It's just a camera in a very simple scene with almost nothing present, except for a few cubes resized to look like walls.
     

    Attached Files:

  9. TragicallyCanadian

    TragicallyCanadian

    Joined:
    Mar 26, 2020
    Posts:
    31
    I've found the strangest discovery.

    The Stand Alone Build runs at normal speed BUT ONLY IF the Unity Editor is Present in the background. What on earth could be the reason for this lol? Do I submit a bug report?

    I am going to take this to a new thread.

    Stand alone build WITH editor running in background 277 FPS average Unity Example A.png


    Stand alone build WITHOUT editor running in background 144 FPS average
    Unity Example B.png
     
  10. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,456
    Maybe vsync or since kind of frame limit on the gpu driver side?
     
  11. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,996
    This has been solved here (duplicate thread).
     
    DevDunk likes this.