Oran C
Oran C

Reputation: 119

RangeError: too many arguments provided for a function call createUnityInstance

Not sure what I've done wrong with a WebGl build in Unity or if I need to add more.

Have a path setup in the wwwroot of the our webapp to put the WebGL build in. When I run it locally it the page will load and the Unity logo appears and progress bar gets to 90% and that's it.

When running in Firefox the page loads and it produces a RangeError popup How do I vew the arguments passed through?

Initially I had a parse error appear but managed to resolve that issue.

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.

Adding the following code has resolved the parsing error.

    public static IApplicationBuilder UseStaticFilesExtendedTypes(this IApplicationBuilder app)
    {
        var provider = new FileExtensionContentTypeProvider();
        provider.Mappings[".glb"] = "model/gltf-binary";
        provider.Mappings[".env"] = "application/octet-stream";

        // app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });

        app.UseStaticFiles(new StaticFileOptions
        {
            ContentTypeProvider = provider,
            OnPrepareResponse = content =>
            {
                if (content.File.Name.EndsWith(".js.gz"))
                {
                    content.Context.Response.Headers["Content-Type"] = "text/javascript";
                    content.Context.Response.Headers["Content-Encoding"] = "gzip";
                }
                if (content.File.Name.EndsWith(".wasm.gz"))
                {
                    content.Context.Response.Headers["Content-Type"] = "application/wasm";
                    content.Context.Response.Headers["Content-Encoding"] = "gzip";
                }
            }
        });

        return app;
    }

This is what appears on the web page on localhost.

enter image description here

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

Build settings:

enter image description here

Upvotes: 4

Views: 1183

Answers (1)

Oran C
Oran C

Reputation: 119

I have managed to resolve this issue.

How I asked the question wasn't clear but at the time I was desperate.

It was a caching issue.

In Firefox, hit F12 to open the console and select Storage tab. Expand Indexed DB, inside localhost delete the UnityCache and refresh the page.

enter image description here

I had made multiple builds and replaced the new build and tried to run again which seems to cause caused the error. Builds.loader.js which Unity generates when building for WebGl seems to have issues with caching/old caches.

Hopefully this will helps!

Upvotes: 6

Related Questions