As my latest Unity 3D WebGL game has been released and I’m currently working on another one, I’ve been experimenting with ways to shrink the build size.
Probably the biggest contribution to the build size, from the game assets, is music, so naturally, tracker modules (mod/xm/it/ut) are a good candidate to replace Mp3/AAC/Vorbis compressed music. Of course, if you manage to find such music.
Unity does offer support for tracker modules, as seen in the documentation. It does’t explicity say that, in fact, that for WebGL projects, it can only import tracker modules then convert them to WAV, instead of using the original file.
So this was my little experiment, first, import a mod file:
Notice how a ~100kb gets converted to a 2.5Mb monster. I thought it was just a glitch, but then I built the WebGL release version and using the build report tool, noticed this:
I would assume that the reason for this is that FMod, the library that powers tracker modules in Unity, is multi-threading and since WebAssembly is not, then it just uses regular compressed audio.
I would assume that it’s a technical challenge to make a native multi-threading library work in a non-threading environment, and this is a pity, because aside from WebGL target, for a smaller build size, there’s really no other reason to use tracker music.
Probably the next step is to look for a 3rd party library or port myself one, but, as it stands, time is quite short right now.