Search Unity

Attaching the Profiler to a WebGL build

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

  1. RicardoCoelhoTTW

    RicardoCoelhoTTW

    Joined:
    Jun 15, 2021
    Posts:
    13
    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.                     PlayerSettings.SplashScreen.show = false;
    6.  
    7.                     buildOptions.locationPathName = path;
    8.                     buildOptions.target = BuildTarget.WebGL;
    9.                     buildOptions.options = BuildOptions.None;
    10.  
    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;
    with
    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