Tracker Modules Don’t Work In Unity WebGL

Insider 17 Sep , 2020 0

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’ve been using tracker music for my browser games, both in Flash and in Javascript. Laser Lab, Knight And Witch and Loose Cannon all have tracker music soundtracks and they don’t need multi-threading to render them – in fact, the impact on CPU is rather minimal. Coming to think that tracker music worked on computers made in the 80s and early 90s and demos such as Second Reality (Future Crew) worked perfectly on a Intel 386 CPU, rendering amazing graphics and music…

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.

Written by
Stefan Dicu
Owner of Piron Games and game developer.

LEAVE A REPLY

Your email address will not be published.