The size of your game can be a critical success factor for platforms such as web and mobile, while it is of less importance on desktop and consoles where disk space is cheap and often plentiful.
Apple and Google has defined application size limits when downloading over mobile networks (as opposed to downloading over Wifi). For Android this limit is 200 MB for apps published with app bundles. For iOS users will get a warning if the application is larger than 200 MB, but can still proceed to download it.
According to a 2017 study it was shown that “For every 6 MB increase to an APK’s size, we see a decrease in the install conversion rate of 1%.” (source)
Poki and many other web game platforms recommend that the initial download should be no larger than 5 MB.
Facebook has a recommendation that a Facebook Instant Game should start in less than 5 seconds and preferably less than 3 seconds. What this means for actual application size is not clearly defined but we are talking size in the range of up to 20 MB.
Playable ads are usually limited to between 2 and 5 MB depending on the ad network.
You can optimize the application size in two ways; by reducing the size of the engine and/or by reducing the size of the game assets.
To get a better understanding of what makes up the size of your application you can generate a build report when bundling. It is quite common that sounds and graphics is what takes up the bulk of the size of any game.
Defold will create a dependency tree when building and bundling your application. The build system will start from the bootstrap collection specified in the game.project file and inspect every referenced collection, game object and component to build a list of the assets that are in use. It is only these assets that will get included in the final application bundle. Anything not directly referenced will get excluded. While it is good to know that unused assets will not be included you as a developer still needs to consider what goes into the final application and the size of the individual assets and the total size of the application bundle.
A quick way to reduce the engine size is to remove functionality in the engine that you do not use. This is done application manifest file where it is possible to remove engine components that you do not need. Examples:
image.load()
The biggest wins in terms of asset size optimizations are usually gained by reducing the size of sounds and textures.
Defold supports .ogg and .wav files where .ogg is typically used for music and .wav for sound effects. Sounds must be 16-bit with a sampling rate of 44100 so any optimizations must be done on the sounds before encoding them. You can edit the sounds in an external sound editor software to reduce the quality or convert from .wav to .ogg. Also consider converting sounds from stereo to mono.
You have several options when it comes to optimizing the textures used by your game, but the first thing to do is to check the size of the images that gets added to an atlas or used as a tilesource. You should never use a larger size on the images than is actually needed in your game. Importing large images and scaling them down to the appropriate size is a waste of texture memory and should be avoided. Start by adjusting the size of the images using external image editing software to the actual size needed in your game. For things such as background images it might also be ok to use a small image and scale it up to the desired size. Once you have the images down to the correct size and added to atlases or used in tilesources you also need to consider the size of the atlases themselves. The maximum atlas size that can be used varies between platforms and graphics hardware.
This forum posts suggests several tips on how to resize multiple images using scripts or third party software.
If an atlas is too large you need to either split it into several smaller atlases, use multi-page atlases or scale the entire atlas using a texture profile. The texture profile system in Defold allows you to not only scale entire atlases but also to apply compression algorithms to reduce the size of the atlas on disk. You can read more about texture profiles in the manual. If you don’t know what to use, try to start with these settings as a starting point for further customizations:
You can read more about how to optimize and manage textures in this forum post.
The size of your fonts will be smaller if you specify what symbols you are going to use and set this in Characters instead of using the All Chars checkbox.
Another way of reducing initial application size is to exclude parts of the game content from the application bundle and download it on demand. Defold provides a system called Live Update for excluding content for download on demand.
Excluded content can be anything from entire levels to unlockable characters, skins, weapons or vehicles. If your game has a lot of content, organize the loading process so that the bootstrap collection and the first level collection include the bare minimum resources required for that level. You achieve this by using collection proxies or factories with the “Exclude” checkbox enabled. Split resources according to the player’s progress. This approach ensures efficient resource loading and keeps initial memory usage low. Learn more in the Live Update manual.
Android builds must support both 32-bit and 64-bit CPU architectures. When you bundle for Android you can specify which CPU architectures to include:
Google Play has support for multiple APKs per release of a game, which means that you can reduce the application size by generating two APKs, one per CPU architecture, and uploading both to Google Play.
You can also make use of a combination of APK Expansion Files and Live Update content thanks to the APKX extension in the Asset Portal.
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB