-
-
Notifications
You must be signed in to change notification settings - Fork 22.4k
Add compress_for_servers
build option for Web (and add opts.get_arguments()
)
#105371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Brotli is ungodly slow, as it is single-threaded. I'm wondering if it would be preferrable to cook up some magic in order to run instead rust-brotli. The problem here is that there's no binary to download, as it doesn't exist (yet). |
I just tried to compile and run |
Doesn't it have a -j argument? |
Dang it. Didn't know. I'll try it out. |
So, the results of my benchmarks. 40MiB wasm file
695MiB wasm file
ResultThe results are inconclusive, so I will not support dropbox/rust-brotli. |
If you can find a way to efficiently decompress Zstandard on the web platform, supporting it could be worthwhile. All modern browsers except Safari support it: https://caniuse.com/zstd In fact, it might not be worth supporting Brotli anymore given its slow compression speeds, as gzip will remain available for Safari until it adopts Zstandard. Edit: |
a60dab0
to
91fe3f3
Compare
Note
This PR is the first of (maybe) two that intends to apply some optimizations underlined by @popcar2 in his great blog post on How to Minify Godot's Build Size (93MB -> 6.4MB exe).
compress_for_servers
build optionThis PR primarily adds the new
compress_for_servers
build option. See Compression in HTTP (MDN) for more information (tl;dr, it permits the server to send a compressed file instead of the raw file, for the receiver to decompress it seamlessly, saving bandwidth). It is configured as aListVariable
, which seem to be the first time it's used in the project. It accepts those values:gzip
(aliasgz
): gzips web built filesbrotli
(aliasbr
): brotli compress built filesnone
(default): no compression of built filesall
: will apply all compression formats to built filesListVariable
is interesting because it permits the use of multiple values as entry.compress_for_servers=all
is the dynamic equivalent (handled byListVariable
) ofcompress_for_servers=gzip,brotli
.Note
A new PR (or this one) needs to follow-up in order to add those server compressed files into the official build templates.
opts.get_arguments()
Incidentally, in order to fix some issues with
SCons.Variables.ListVariable
against our currentopts.Update()
use in SConstruct, this PR also introducesopts.get_arguments()
as a newVariables
class method. It returnsopts
values as if they were entered by hand in the command line. Otherwise, the newListVariable
gets updated twice and the result isn't idempotent, and theListVariable
validator don't recognize it's own values. This change was made to prevent this.This PR also cleans up (a lot)
create_template_zip()
inplatform/web/emscripten_helpers.py
. It simplifies adding files toin_files
andout_files
, no need anymore to track manually each file that are added to add theirzipfile
counterpart.