Changes to the WebGL loader and templates introduced in Unity 2020.1

Yeah with the changes they made the build output files are a bit different.

Check this one for the web.config

If you’re using hash as files name you gotta disable it because it is broken right now. The files lose part of their extension which causes issues with loading up things.

Thank you so much - I will try that and see if I get it working.

Brilliant, works now, loads up really quick now. Thanks again

The documentation has a mistape, there is no close of , I mean in the end

https://docs.unity3d.com/2020.1/Documentation/Manual/webgl-server-configuration-code-samples.html

1 Like

Is there any indication as to when this will be fixed?
We want to upgrade our project from 2019.4 to 2020.1, but this bug is blocking us.

It works now in Chrome and Firefox with the following settings:

This new approach completely breaks on iOS for iPad (which previously worked on 2019.x). So it’s great for other platforms, but unusable right now if targeting mobile. See regression here: Unity Issue Tracker - [WebGL] [iOS 13] Application on browser crashes when trying to minimize the browser 'Out of bounds Trunc operation'

1 Like

that .htaccess leads to new issues…

2809.loader.js:1 Uncaught TypeError: Cannot read property ‘1’ of null
at 2809.loader.js:1
at createUnityInstance (2809.loader.js:1)
at HTMLScriptElement.script.onload ((index):56)
(anonymous) @ 2809.loader.js:1
createUnityInstance @ 2809.loader.js:1
script.onload @ (index):56
load (async)
(anonymous) @ (index):55
cs.min.js:5 Uncaught onMessage is not defined

these appear to be the default settings anyway in 2020.1.41

Not sure what changes are also required on a server, but currently we can’t release WebGL builds with Unity 2020.1. However it works out of the box using Unity 2019.4.

Console errors in Unity 2020 range from “invalid character” to “unityframework not found” or similar. Tried all Player Settings combinations with no avail and had to revert to 2019 to make a build.

3 Likes

there is an issue with unitywebgl.loader.js and MacOS BigSur. the regex for parsing the version of MacOS errors, and the loading never finishes. I see this with Safari shipping with BigSur, didn’t test Chrome or Firefox

1 Like

Can you share for nginx?, tried the following :

location / {
            root   html;
            autoindex on;
            autoindex_localtime on;
            index  index.html index.htm;
           
            location ~* \.(loader.js)$ {
            add_header Content-Type application/javascript;
            }
           
            location ~* \.(wasm)$ {
            add_header Content-Type application/wasm;
            }
           
            location ~* \.(data.gz|symbols.json.gz)$ {
            add_header Content-Encoding gzip;
            add_header Content-Type application/octet-stream;
            }
            location ~* \.(wasm.gz)$ {
            add_header Content-Encoding gzip;
            add_header Content-Type application/wasm;
            }
            location ~* \.(framework.js.gz|js.gz)$ {
            add_header Content-Encoding gzip;
            add_header Content-Type application/octet-stream;
            }
        }

But getting the following from firefox :

The script from “http://localhost/test/Build/WebGL.framework.js.gz” was loaded even though its MIME type (“application/octet-stream”) is not a valid JavaScript MIME type.
wasm streaming compile failed: TypeError: Response has unsupported MIME type
falling back to ArrayBuffer instantiation

this worked
using brotli compression / chrome
Apache

@alexsuvorov I would really appreciate any kind of update on this.

As of right now the default settings don’t work for both local builds and most servers. You can’t just build your games and upload them to itch.io or any other website anymore. You have to mess with the compression settings, which seems like a really bad idea. Not to mention that it’s really hard to find out what’s even wrong.

The default settings for builds should just work, and as far as I see it, these settings can’t stay like this moving forward.

4 Likes

Should probably have a checkbox that indicates whether one is using Apache or IIS server to automate the .htaccess generation

2 Likes

Is there any update on this issue? It has been months and even in Unity 2020.1.6 this problem still persists.
Is there an issue tracker for this?

1 Like

Found out working nginx rules for Unity WebGL 2020.1++

location / {
            root   html;
            autoindex on;
            autoindex_localtime on;
            index  index.html index.htm;
           
            location ~* ^.*\.(js)$ {
            types {}
            default_type application/javascript;
            }
           
            location ~* ^.*\.(wasm)$ {
            types {}
            default_type application/wasm;
            }
            location ~* ^.*\.(wasm.gz)$ {
            gunzip on;
            gzip off;
            types {}
            default_type application/wasm;
            add_header Content-Encoding gzip;
            }
            location ~* ^.*\.(framework.js.gz|js.gz)$ {
            gunzip on;
            gzip off;
            types {}
            default_type application/javascript;
            add_header Content-Encoding gzip;
            }
           
            location ~* ^.*\.(data.gz|symbols.json.gz)$ {
            gunzip on;
            gzip off;
            types {}
            default_type application/octet-stream;
            add_header Content-Encoding gzip;
            }

        }

Clear the browser cache and reload the page.

3 Likes

Why is. Wasm loaded twice?

1 Like

Hi all, I want to upgrade our project from 2019.4 to 2020 to improve the webgl loading&startup time.
Are there any noticeable improvements using 2020 instead of 2019.4?

1 Like

I’d also like to vote on this

1 Like