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

Question WebGL Framerate Fluctuations and Profiling Issues

Discussion in 'Editor & General Support' started by wattse13, Sep 18, 2023.

  1. wattse13

    wattse13

    Joined:
    Apr 3, 2019
    Posts:
    9
    Hello, I am currently struggling to optimize the performance of a WebGL project I am working on. The project’s framerate fluctuates between 15 and 50 fps. I have been trying to use both Unity’s and Firefox’s profiling tools on builds of the game, but I have been unsuccessful in finding what is causing the framerate fluctuations.

    I originally thought that VSync or WaitForTargetFrameRate processes were the culprit, but based on this thread and this thread, I think the problem may lie elsewhere.

    I tried following the setup/steps in this thread, and I was able to get the Firefox profiling tool set up correctly, but I felt like most of the scripts being pointed towards were on the Unity side of things.

    I have both Deep Profile, and Call Stacks enabled in the Unity Profiler. The project is using a Lightweight Forward Renderer. Rendering also appears to be the main draw on resources. I've been doing my best to optimize the LWRP Asset as much as possible and I am wondering if I haven't come up against the border of what's possible.

    Is there any additional information available for understanding Unity’s or Firefox’s profiler? Am I missing something obvious? Any help would be greatly appreciated!

    unityProfiler.png

    tldr;

    The Goal:
    • We are targeting the WebGL platform.
    • It is a 3D game with what I think is a moderate amount of 3D assets.
    • Ideally this game could be played on a Chromebook, or other similar low-spec hardware, in a classroom setting.
    • We are using Unity Engine 2019.4.20f1
    The Issues:
    • Framerate fluctuates between 50 and 15 fps.
    • I have been unsuccessful in using the profiler to find the underlying cause.
    Things I Have Tried:
    • I have tried creating/profiling builds in which known-high poly 3D assets have been deleted/disabled.
    • I have tried creating/profiling builds in which no Nav-Mesh agents were active.
    • I have tried creating/profiling builds with baked lighting.
    • Removed scripts that generated garbage.
    When the above changes were made, framerate improved slightly, but the fluctuations did not stop – i.e., with fewer assets the framerate didn’t drop to 15 as often but did still drop severely and regularly.

    When following the steps laid out in this thread, I discovered that the project is creating a whole bunch of jank as seen in the Firefox profiler. I have tried to investigate what is responsible for the jank, but I am very unfamiliar with the Firefox profiler and I did not understand most of the information provided provided by the tool.

    jank.png

    Test Build:

    Stratus University itch.io Link

    Testing Computer:

    Processor Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz 2.90 GHz
    Installed RAM 16.0 GB (15.9 GB usable)
    System type 64-bit operating system, x64-based processor
    Intel(R) HD Graphics 620
     

    Attached Files:

  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    Hi,
    Have you looked at the timing and distribution along the frame's chronological structure in the Timeline view of the CPU Usage Profiler Module?
    Have you looked at this with the Profile Analyser package, ordering frames by duration and comparing the same capture against itself, once with the high end of frame times selected, once with the low end of it?

    Also, the WebGL subforum might be a more focused arena for your thread :)
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Unless it's prohibitive for some reason, I'd definitely look into upgrading the engine version. At least for a performance check.

    There's so much in that tech stack that improved over those years. Nowadays with 2022.3 and URP I can build and run a full post-processing enabled demo of an unoptimized scenery and get 60 fps all the way (in Chrome, Firefox performance is significantly worse). Years ago, especially with built-in RP, it was almost prohibitive to enable any of the fullscreen post effects.
     
    MartinTilo likes this.
  4. wattse13

    wattse13

    Joined:
    Apr 3, 2019
    Posts:
    9
    I knew there must be a subforum specifically for WebGL! I was unable to find it yesterday, but of course I found it immediately when I looked this morning. I have made a new thread over there; New Thread Link.

    Thank you for your response! I tried out both of your suggestions and posted some screenshots in the new thread. If I am correctly understanding the Profiler and the Profile Analysis, it looks like I will have to reduce the number of assets in the game or upgrade to a newer version of Unity.
     
    MartinTilo likes this.
  5. wattse13

    wattse13

    Joined:
    Apr 3, 2019
    Posts:
    9
    Hey thank you for the suggestion!

    I was able to get a build of the project running in Unity 2022.3. Unfortunately, performance decreased, but I think that was because the project was not properly optimized in the new version of the engine. We will hopefully be able to upgrade to the new version of the engine after a deadline at the end of this month as then we will have a bit more bandwidth to learn some of the nuances of the new engine version.