Tips On Application Slimming - Make Game Smaller?(SOLVED)

Hi,

So we’ve got this new Defold game below live on HTML5/Android:

Someone already complained about the Android version being too big…
Android version is 20 Megabytes.

Is there something we can easily do within Defold that would shrink the Android version?
Game’s music takes up about 13.6MB on disk and it’s already at lower 22050Hz mono.
We’ve done nothing to the game’s graphic PNG’s (all are 32bit).
( graphics don’t take much of the space(1.1MB), so that would not help any )

Any ideas or tips?
Thanks!

Jesse

This is a good example for other too so I will just mention everything that I think isn’t that well optimized sorry if I comment on stuff you don’t care about.

Textures

Atlases

Why are all your individual images on a separate atlas? The point of an atlas is to reduce the amount of times the game need to swap texture. Having them on a separate atlas like this adds a lot of “dead space”. Take a look at the Title-BG and TitleFaded-BG atlases, that image is 360x640, meaning that it will be on an atlas of 1024x512. This is a lot when all your images together should fit on a 1024x1024 atlas.

This game is so small all images should be on the same atlas, this will also reduce the draw calls (and build time). Put images that will be loaded together on the same atlas to reduce memory footprint and draw calls. However the game is only around 15 draw calls so that wouldn’t be the main reason to do this.

Size

Even though Title-BG and TitleFaded-BG are fullscreen passes I don’t think you need to have them that big.

Street_Divider, ScreenFade, SectorLine are all single color images. You can make them into a single pixel, put that image under a game object and scale the game object to the size you want the image.

Street should be separated into 3 images. “End” sign, “Start” sign and the roadbackground. The background should be 1x360 px and then scaled up in y to 360.

If your FAS-Statue images was 512x512 in size instead of 555x555 the actual texture would be 1/4 of the size. Try to keep your textures close to a power off two, this will mean they will most likely pack better on atlases

Overall, remember that you can scale sprites up too. This game uses linear as a Texture filter so remember to scale them up by a power of 2.

Compression

You are using the Default texture profile. Unfortunately it doesn’t do much so I recommend using WebP for compressing checkout my example one in this post Texture Management in Defold. I don’t think it will save many MB in this case however.
Don’t use the default texture compression, use WebP

Sounds

As you say yourself - This is the big one. It is 75% of your complete game. This is the only place you can really save a lot of space, but it will unfortunately require cutting.

It’s good that you use OGG, as a none audiophile I can’t hear much difference between ogg and wave and ogg is a lotsmaller. They all look compressed (except maybe RedLightRacer.ogg, some of them also have some useless metadata - but that’s only bytes). The main issue with the sounds are how incredibly long they are.

Play a game like Candy Crush and try to notice how long their sounds tracks are - then remember that they where played by London Symphony Orchestra in Abbey Road Studios. My point is - A lot of games have a lot shorter sound tracks than you think. I would keep it to 1 min for the main track and 30 sec max for everything else.

I do not think the user would notice much if you shortened them significantly. Many of them sounds quite the same the whole way through so shortening them down and looping them could be a good idea. 12 out of the 17 sounds are over 1 min.

11 Likes

Very useful tips, thanks!

This also helped ALOT with the OGG audio size:
https://www.skyshape.com/oggresizer-vorbis-compressor.html

With the above app I made the Android version go from 20MB to about 15MB

Jesse

1 Like

What it did was reduce the bit rate from 50000 to 32000.

When I convert sounds I use the python lib pydub I tend to set the channels to 1 and framerate to 22050. I have found that that sounds acceptable, but sometimes it doesn’t so make sure to check the sounds too.

Here is an example script how to do this with python and pydub.

import os
from pydub import AudioSegment

def convert_sounds(audio_folder):
    for sound_path in [os.path.join(root, f) for root, folders, files in os.walk(audio_folder) for f in files if f.endswith(".ogg")]:
        if sound_path.endswith(".ogg"):
            sound = AudioSegment.from_ogg(sound_path)
            output_file = sound
        elif sound_path.endswith(".wav"):
            sound = AudioSegment.from_wav(sound_path)
            output_file = sound_path.replace(".wav", ".ogg")

        else:
            continue

        if not sound.channels == 1:
            sound = sound.set_channels(1)
        if not sound.frame_rate == 22050:
            sound = sound.set_frame_rate(22050)

        # Save out ogg
        if os.path.exists(output_file):
            os.remove(output_file)

        sound.export(output_file, format="ogg")
1 Like