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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Attaching the Profiler to a WebGL build

Discussion in 'Scripting' started by RicardoCoelhoTTW, Jun 15, 2021.

  1. RicardoCoelhoTTW


    Jun 15, 2021
    Hello guys.
    I'm building a game for multiple platforms. One of them, as you may have guessed, is WebGL.
    Depending on the target build I have to move some files around because of build sizes restrictions, so, instead of building my applications in the File/Build Settings/Build (& Run) menu, instead I have a custom GUI window where I chose my target build and in my script I already have the necessary configurations.
    But, there is a problem. I am unable to attach the Profiler to a WebGL build this way, and I can't figure out how and thats where I need your help.

    This is my code to create a release build in WebGL
    Code (CSharp):
    1. case DeployType.WebGL:
    2.                     PlayerSettings.SetAdditionalIl2CppArgs("--emit-null-checks --enable-array-bounds-check");
    3.                     PlayerSettings.WebGL.emscriptenArgs = "-s ASSERTIONS=1 -s DISABLE_EXCEPTION_CATCHING=0 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1";
    4.                     PlayerSettings.stripEngineCode = false;
    5.            = false;
    7.                     buildOptions.locationPathName = path;
    8.            = BuildTarget.WebGL;
    9.                     buildOptions.options = BuildOptions.None;
    11.                     BuildPipeline.BuildPlayer(buildOptions);
    12.                     break;
    And now to run a local test build with the Profiler attached I replace
    Code (CSharp):
    1.                     buildOptions.options = BuildOptions.None;
    Code (CSharp):
    1. BuildOptions finalbuildOptions = BuildOptions.Development
    2.                         | BuildOptions.ConnectWithProfiler
    3.                         //| BuildOptions.AllowDebugging
    4.                         //| BuildOptions.ConnectToHost
    5.                         //| BuildOptions.EnableDeepProfilingSupport
    6.                         //| BuildOptions.IncludeTestAssemblies
    7.                         ;
    8.                     buildOptions.options = finalbuildOptions;
    (The commented options were just random configs of desperation trying to get the Profiler to work)
    My build configuration script works and my builds are successfull and work flawlessly as I want. The issue here is that I can't attach the Profiler to the WebGL build.
    What else do I need to do to be able to Profile my application?

    I'm running the WebGL build on a local XAMP server. I've also atempted to connect the Profiler to the WebGL build in the local server through IP but with no luck