Bug with WebGL compressed builds

So here is the summary of my 2 weeks investigation with cloud engineers and others with serving compressed WebGL unity builds:

  1. In version 2019 the compressed builds(gzip&brotli) can be served without any problem (in computers).
  2. In version 2020 the compressed builds can not be served with error ( Uncaught ReferenceError:unityFramework is not defined at HTMLScriptElement.r.onload ).
  3. In version 2021 the compressed builds can not be served with error (Header with Content-Encoding: (gzip or br) is missing)

Even after trying to tackle the errors with changes in the configuration files and adding .htaccess files, i haven’t managed to solve them. Please feel free to say solutions/thoughts! Thank you.

I noticed this in 2020 versions and stopped compressing webGL builds, as I figured the host (itch.io) would run a compression on the file.

This error message reads like it’s on the hosts end - but if you tried the same compression with 2019 and it worked than that’s weird.

Hello eIZach ! Exactly! So i use aws servers to host the builds. I’ve tried both apache/nginx without any luck. I am sure unity engineers are aware of this issue. It’s indeed weird.

I am experiencing the same problems as this guy serving compressed build on both azure and aws, and locally.

Solved for 2020 and 2021 by allowing .htaccess files.

1 Like

Can you offer more info about this solution? Do you allow .htaccess files on the server or in Unity settings?

1 Like

@Steven_Damian Yes, can you please elaborate on what “allowing .htaccess files.” means, thank you!

Hey there. I discovered the error as well, with Unity 2020.3.2f1 (LTS).

Of course, a workaround may be disabling compression, but unfortunately that inflates the build badly.

For now, I found a solution here, which works for me with Brotli-Compression enabled.
https://answers.unity.com/questions/1804378/webgl-builds-in-version-202021f1-are-not-working.html

UPDATE:
According to Unity’s documentation “WebGL: Compressed builds and server configuration” it’s a recommended solution to enable decompression fallback “…if you have less experience with server configuration, or if server configuration is unavailable to you…Note: Using this option results in a larger loader size and a less efficient loading scheme for the build files.”

7014700--830002--image.png