Unity webgl: Unable to parse Build/vectorunknown builds.framework.js.gz! enable "Content-Encoding: gzip" in response headers in github pages
Asked Answered
B

3

6

I have a unity webgl project and I pushed the webgl build to my git branch as shown below.

enter image description here

I deployed this branch to my github page as shown below.

enter image description here

The build is working on my local with the help of servez. However, on github pages (and my local without servez) it gives the following error:

Unable to parse Build/vectorunknown 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.

How do I deploy to github page with "Content-Encoding: gzip" response header included? How do I make it work? Do I need to make webgl with different options in Unity instead? Kindly help!

Bureaucrat answered 3/11, 2022 at 22:4 Comment(3)
Unity requires very specific encoding on the web server. Or you build without compressionAbly
yeah. i changed player settings to disable compression and I am trying that out now.Bureaucrat
Probably it means that Github is not configured to correctly serve those file types ... I know that at last e.g. fr testing your WebgL things on IIS you need to explicitly overwrite the mime type mappingMarianelamariani
B
3

I went to Edit > Project Settings > Player > Publishing settings and disabled the compression. it worked after that. However, the colors look weird after that. i wish there was another better way. enter image description here

Bureaucrat answered 3/11, 2022 at 23:9 Comment(4)
There is. Use a web server configured to work with unity's requirements.Ably
Follow unitys setup instructions i cant add any more because when you do its always workedAbly
@Ably Can you provide a link to Unity's setup instructions for configuring a web server? Do you mean docs.unity3d.com/2020.1/Documentation/Manual/… ?Boyla
why did you mark this as the solution? this is not the solutionFoti
B
5

I had the same error message. When I inspected network traffic using browser developer tools, I could see no "Content-Encoding: gzip" response header. I added the mime types required by Unity to the server configuration, but still couldn't get the needed Content-Encoding response header to appear.

However, I found that enabling Player Settings > Publishing Settings > Decompression fallback solved the problem for me. According to these docs, "The decompression fallback option enables Unity to automatically embed a JavaScript decompressor into your build. This decompressor corresponds to your selected compression method, and decompresses your content if the browser fails to do so."

Presumably there's a somewhat slower startup because of having to download the JavaScript decompressor.

Boyla answered 20/2, 2023 at 3:59 Comment(2)
wow how did you figure this - of all possible things - out!Peristome
@Peristome I don't remember exactly, but since it was having trouble handling the decompression (parsing gzip), I probably thought a fallback method for decompression might work.Boyla
B
3

I went to Edit > Project Settings > Player > Publishing settings and disabled the compression. it worked after that. However, the colors look weird after that. i wish there was another better way. enter image description here

Bureaucrat answered 3/11, 2022 at 23:9 Comment(4)
There is. Use a web server configured to work with unity's requirements.Ably
Follow unitys setup instructions i cant add any more because when you do its always workedAbly
@Ably Can you provide a link to Unity's setup instructions for configuring a web server? Do you mean docs.unity3d.com/2020.1/Documentation/Manual/… ?Boyla
why did you mark this as the solution? this is not the solutionFoti
F
1

Here's why the marked solution is a tradeoff, not a solution. Making something work isn't necessarily solving the problem.

If you disable compression in WebGL, your build will have a significantly larger size, causing prolonged load time and a larger download size. So, by 'hacking' it, you introduce two new problems to make some error messages you don't understand disappear.

enter image description here enter image description here enter image description here

saved 40 MB using compression

On the following page, you can find the necessary configuration to allow content decoding from your server (depending on what you use):
https://docs.unity3d.com/Manual/webgl-server-configuration-code-samples.html

For example, I use Apache, and by simply adding a .htaccess to my build's root with the following content, I was able to use, in my case, gzip compression, and it loaded very quickly compared to uncompressed format (wasm).

<IfModule mod_mime.c>
RemoveType .gz
AddEncoding gzip .gz
AddType application/gzip .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz
AddType application/wasm .wasm # need this line to serve decompressed wasm file
</IfModule>

That finishes the decompression server configuration and allows your server to load the gzip content.

Try gitattributes for Github pages

Note that this might also be a workaround, since Unity doesn't account for gh-pages server.

Namely, the thing you could try with GitHub pages would be to use the .gitattributes file at the root of your repository, with the following configuration

*.data.gz   binary
*.wasm.gz   binary
*.js.gz     binary
*.symbols.json.gz binary
*.wasm      binary

disclaimer: not sure if it will work

Foti answered 19/7, 2024 at 10:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.