WebGL engine and assetbundle load times benchmarked

Hey WebGL devs, I just finished running some load time benchmarks and thought I’d share my results. Small sample size here, so if anyone has more data, feel free to share!

These were run from a build using 2019.1.14.

As expected, engine built with streaming wasm and Brotli compression seems to give the best results in the vast majority of cases.
Bundles seem to give the best results with LZ4 compression only when on a fast network, LZ4 and Brotli compression when on a slow network.

The bundle results were a surprise to me, since I have been reading that it’s recommended to go with uncompressed bundles for WebGL. My test results show otherwise.

The “Fast 3G” network throttling was done with Chrome’s dev tools to keep the testing consistent between mac and chromebook (which also means there was lots of CPU overhead just to have it open).

There’s a few points here:

  • It depends on the device (and what type of assets are in your asset bundles and how well they compress). The reason [LZ4] bundles are (usually) slower than [uncompressed + GZip/Brotli] bundles is Unity has to do the LZ4 decompressing (and obviously js/wasm is limited to a single thread) whereas the browser can handle GZIP/Brotli decompression natively (and use whatever resources it wants). This is why in your tests “mac + unthrottled” [LZ4 + GZip/Brotli] is actually slower (you’re double compressing which doesn’t really reduce file size that much and now you have the overhead of double decompressing). So if your device is slow enough (think phones), the decompression overhead of LZ4 in Unity tends to be greater than the actual download of a [uncompressed + GZip/Brotli] bundle. On some phones making this change was a huge win.

  • It depends on the size of your bundles and network speed. If your bundles are small enough and your download speed is fast enough, then actually just simply leaving bundles fully uncompressed will be the fastest (as seen by your mac + uncompressed result). It also seems like your bundles are quite small considering they can be downloaded in 1.9 seconds uncompressed. This means with a relatively fast internet speed any compression becomes “useless” (you were already downloading the file instantly, making it smaller doesn’t help). You kind of have two extremes here: “unthrottled” (compression doesn’t seem to help at all) and “3G speed” (where download speed is so slow that reducing file size easily dwarfs any decompression overhead). I’m not sure this is a really accurate “real world example”.

  • You neglected loading bundles from cache. A big problem of LZ4 bundles is they get saved into indexDB as LZ4. So every time you load them from the browser’s indexDB Unity needs to decompress them again. Using the [uncompressed + GZip/Brotli] route, those bundles will be saved into indexDB as uncompressed. Thus they will never have to be decompressed again.

1 Like