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

Question WebGL build. RangeError: too many arguments provided for a function call createUnityInstance

Discussion in 'WebGL' started by oranchad, Feb 7, 2022.

  1. oranchad

    oranchad

    Joined:
    May 26, 2020
    Posts:
    5
    Not sure what I've done wrong or if I need to add more.

    When I Build And Run inside Unity it creates the window and loads without issue.

    Have a path setup inside the wwwroot of the our .netcore webapp to put the WebGL build in. Initially I was getting the following.

    Unable to parse /MyApp/Build/Builds.framework.js.gz! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: gzip" present. Check browser Console and Devtools Network tab to debug.

    I then added the following code which resolved the parsing error.

    Code (CSharp):
    1.    public static IApplicationBuilder UseStaticFilesExtendedTypes(this IApplicationBuilder app)
    2.    {
    3.        var provider = new FileExtensionContentTypeProvider();
    4.        provider.Mappings[".glb"] = "model/gltf-binary";
    5.        provider.Mappings[".env"] = "application/octet-stream";
    6.  
    7.        // app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
    8.  
    9.        app.UseStaticFiles(new StaticFileOptions
    10.        {
    11.            ContentTypeProvider = provider,
    12.            OnPrepareResponse = content =>
    13.            {
    14.                if (content.File.Name.EndsWith(".js.gz"))
    15.                {
    16.                    content.Context.Response.Headers["Content-Type"] = "text/javascript";
    17.                    content.Context.Response.Headers["Content-Encoding"] = "gzip";
    18.                }
    19.                if (content.File.Name.EndsWith(".wasm.gz"))
    20.                {
    21.                    content.Context.Response.Headers["Content-Type"] = "application/wasm";
    22.                    content.Context.Response.Headers["Content-Encoding"] = "gzip";
    23.                }
    24.            }
    25.        });
    26.  
    27.        return app;
    28.    }
    Now when I run the web application. The Unity WebGL page loads and progress bar gets to about 90% and produces the following.



    RangeError: too many arguments provided for a function call
    createUnityInstance/l/</<@https://localhost:5001/MyApp/Build/Builds.loader.js:1:5770
    promise callback*createUnityInstance/l/<@https://localhost:5001/MyApp/Build/Builds.loader.js:1:5417
    callRuntimeCallbacks@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:19279
    preRun@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:14671
    run@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:359513
    runCaller@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:358850
    removeRunDependency@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:15974
    receiveInstance@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:17723
    receiveInstantiationResult@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:17840
    promise callback*unityFramework/createWasm/instantiateAsync/<@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:18451
    promise callback*instantiateAsync@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:18354
    createWasm@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:18914
    unityFramework@https://localhost:5001/MyApp/Build/Builds.framework.js.gz:3:293288
    createUnityInstance/l/<@https://localhost:5001/MyApp/Build/Builds.loader.js:1:5335
    promise callback*l@https://localhost:5001/MyApp/Build/Builds.loader.js:1:5317
    createUnityInstance/<@https://localhost:5001/MyApp/Build/Builds.loader.js:1:18860
    createUnityInstance@https://localhost:5001/MyApp/Build/Builds.loader.js:1:18452
    script.onload@https://localhost:5001/lib/unity-loader.js:64:24
    EventHandlerNonNull*@https://localhost:5001/lib/unity-loader.js:63:1


    Is there a way to see what is getting passed through the createUnityInstance? Or do I need to configure it more?

    Build settings:

     
  2. nelson_unity888

    nelson_unity888

    Joined:
    Jun 19, 2021
    Posts:
    2
    I am hitting the same error as I try to host the game in an AWS bucket.
    I am using application/wasm as the type for the wasm.gz
    I am using encoding gzip for the gz files in the bucket.

    I managed to fix it by adding changing the content-type of the wasm file to application/wasm and removing the content-type of the other .gz files under Build
     
    Last edited: Mar 1, 2022