App size doubles after using Play Asset delivery in Unity

Viewed 1174

i just exported my game to use Play Asset delivery following this guide: https://docs.unity3d.com/2021.1/Documentation/Manual/play-asset-delivery.html

in short

  • build app bundle enabled
  • split application binary also checked.

The exported aab size is 311mb and when uploading to google play it says:

base               ----install_time  ---30.1mb
UnityDataAssetPack ----install  time ---264mb

enter image description here

But then when i download the app in any device, the file size is 846mb, more than double the expected size. Also it tries to download all at once, i thought that the dataassetpack was downloaded after the base one.

i'm using Unity 2021.1.16f1

Do you know any cause for this to happen, and how to fix it? thank you very much!

2 Answers

You are comparing a "download size" to a "size on disk":

  • The size you see in the Play Console corresponds to the download size, which is compressed.
  • On the device, you see the size on disk where the data is stored uncompressed so it can be directly rendered without having to keep two copies of the same data (one compressed and one uncompressed), so that explains the discrepancy.

It seems that you have configured the modules to be install-time so they will be installed as part of the initial install. If you want them to be installed while the user is starting the game, you should configure them to be fast-follow. If you want to manually download them using the Play Core API, you should configure them to be on-demand. This is all explained in the page you linked in the Managing asset packs at runtime section.

That page also links to the Google documentation on the topic, which has a dedicated section for Unity -- which would be too long to copy here, so have a read and come back if you have more specific questions.

If you're only using Unity marking the AAB output type in the build settings, and not using Google's API to do your stuff via script, then it's correct. Unity has a bug when assembling bundles and will simply (at least) double the size of your app. Things will be doubled in your AAB, you'll see the stuff you had in streaming assets in split apks and also inside the base.apk. Unity's way is not reliable, it's quite wrong and Google's plain way for Unity also is not perfect, it will not work for every single project. I was able to get the hang of it, but in the end I wrote our own tool to create the asset packs, created our runtime implementation to use the API and also our build procedures to be called by our custom build class. My suggestion is, squeeze the docs here https://developer.android.com/guide/playcore/asset-delivery/integrate-unity?language=api and build your custom solution.

Related