Search Unity

iOS App Size: App Slicing and Comparison to Android

Discussion in 'iOS and tvOS' started by DevMan5000, Sep 2, 2016.

  1. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    Hi,

    I'm made a couple Unity Answer posts, but I'm not getting much traction there.
    http://answers.unity3d.com/questions/1238460/does-apple-use-app-slicing-thinning-for-unity-apps.html

    http://answers.unity3d.com/questions/1237740/ios-app-is-much-larger-than-android-app-1.html#comment-1238238

    iTunesConnect estimates download size as 77.2mb, installed size will be 158mb.

    My iPad settings menu shows the app (through normal Build and Run) as 165mb, so really close to the estimated install size.

    My Android tablet's Internal Storage menu shows my app as 79.98mb.

    So, my iOS app is DOUBLE the size of my Android app. Anyone know why?

    I use compressed texture atlases for all of my textures so there shouldn't be a huge disparity there between platforms. Textures show that they are RGB Compressed PVRTC 4 bit.

    I feel like my textures are set appropriately so that led me to think about whether my build size is being impacted by compiling both ARMv7 and ARM64.

    If I Build and Run from XCode with IL2CPP and only ARMv7, then my installed size is 126mb. However, if I make a IL2CPP Universal build and install it, the app size is 165mb. So a 40mb jump!


    APP SLICING

    This unity page mentions app slicing: unity article.

    From that Unity article: " iOS devices using iOS 9.0 and above will download only the slice (32 or 64) depending on their needs. Apple splits the binary and creates a separate package, so those platforms e.g. iPhone 6s should have a smaller Download Size without you doing anything to your game. This is completely unrelated to ODR or Bitcode. Devices running below iOS 9.0 will still need to download the Universal build however. "

    This article from Apple says this:

    "Xcode simulates slicing during development so you can create and test variants locally. Xcode slices your app when you build and run your app on a device. When you create an archive, Xcode includes the full version of your app but allows you to export variants from the archive."

    Its saying that it does app slicing when doing a normal build and run, but that is bogus because I am building Universal (ARMv7 and ARM64) and there is a 40mb difference in install size. If it was performing app slicing, then I would expect to see no difference in install size between an ARMv7 only build and a Universal build because the Universal build would have had the ARM64 slice removed during slicing.

    What am I missing?

    Looking at iTunesConnect TestFlight builds I've uploaded, the install size is 158mb. That is really close to the install size after an XCode Build/Run (165mb). So what gives?

    Estimated App Store File Sizes

    Universal: download: 97.6 MB install: 223 MB

    iPhone 5C: download: 77.2 MB install: 158 MB

    iPhone 5: download: 77.2 MB install: 158 MB

    iPad 4 Wifi + Cell: download: 77.2 MB install: 158 MB

    iPad 2 Wifi download: 77.2 MB install: 158 MB

    Someone please help!!! :)
     
  2. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    I did a check and my iPad is running 9.1 so it should be getting the benefit of app slicing, but it is NOT.
     
    Last edited: Sep 5, 2016
  3. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
  4. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    Dang, I've gotten 0 answers on this post and in Unity Answers as well. App size is pretty important, but no one seems to have a handle on what's up with it.
     
  5. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    It's quite expected that Android app installs take less storage space than iOS:
    a) because part of the assets are kept inside original apk archive in compressed form, contrary iOS always extracts application fully. While it costs more disk space, loading is typically faster.
    b) Android allows JIT-compiling applications on the fly, thus it's enough to ship code in .NET bytecode format and compile to ARM when needed. .NET bytecode is typically more compact than ARM code, so if your code depends on lots of .NET libraries there might be very noticeable space savings. Contrary on iOS all the code must be precompiled ahead of time and we do it via our IL2CPP technology. Which offers better runtime performance, at bigger code size. (IL2CPP builds are now available on Unity Android too).

    It's hard to tell what exactly makes a difference in your app without looking into builds. I would suggest to make Android and iOS builds. (For Android make APK and then unzip it, for iOS export IPA via Xcode Archive function and then extract it). After that:
    1) Investigate Data folder differences inside extracted folder, they should be quite similar.
    2a) Investigate how much space takes application libraries + .NET dll files on Android.
    2b) Investigate ARM64 + ARMv7 slices of your iOS executable, check how much bitcode, code and data segments take via otool utility as explained in https://support.unity3d.com/hc/en-us/articles/208412186.

    Once all these numbers are known, it will be easier to comment on installation size differences.
     
    DevMan5000 likes this.
  6. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    Thanks for your reply Mantas-Puida.

    "because part of the assets are kept inside original apk archive in compressed form, contrary iOS always extracts application fully. While it costs more disk space, loading is typically faster."
    This is very vital information that I did not see in my search on forums/answer hub. I appreciate you calling it out here.

    I will do the investigative steps that you mention and report back.
     
  7. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    Hey all,

    In doing these tests, I stumbled upon a way to put a thinned out app onto my device. Here are the instructions:

    1. Select your build target as Generic iOS Device
    2. Project -> Archive
    3. Open Window -> Organizer
    4. Select the Archive that was just made
    5. On the right panel select Export
    6. For "method for export:" select "Save for Development Deployment". (Note: "Save for iOS App Store" option prevented me from manually dragging the .ipa onto my device in later step, but Development setting worked fine).
    7. On the next window select "Export for specific devices:" and select your device (mine was iPad Mini 2)
    8. Continue through steps and save .ipa in a recognizable place. (I disabled all the checkmark stuff). You will see a specific "thinning app" phase called out as it exports the .ipa.
    9. Now we will install the ipa on device. XCode: Window -> Devices
    10. Select your iOS Device from left panel
    11. In a Finder window navigate to your ipa file.
    12. Back on the Devices window, you should see a section "Installed Apps"
    13. Drag the .ipa from the Finder window into the Installed Apps section of the Devices window. This will install the app on your device.
    14. Go to Settings menu on iOS device and check out the installed size.

    Hope this helps!
     
  8. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    Mantas-Puida,

    Here are my results from exporting archives.

    iOS
    Normal Build/Run (Play Button in XCode): .ipa Size: N/A Installed: 152 MB
    Exported archive (Universal): ipa Size: 67 MB Installed: 114 MB
    Exported archive targeted for specific device (iPad Mini 2): ipa Size: 60 MB Installed: 104 MB

    Note: The archives were exported using the Development option, not the iOS App Store option. The app store option prevented me from dragging the .ipa onto my device. Not sure if Development option makes the installed size smaller.

    1. Why is the install app size from an .ipa so much smaller than the app size from a Build/Run through XCode? Is it because I exported the archive with the development option?

    2. Obviously the thinned out .ipa (generated by exporting the archive for a specific device) installed to the lowest size, 104 MB. Can I expect this to be the ultimate final size from the App Store?
     
    Last edited: Sep 10, 2016
  9. DevMan5000

    DevMan5000

    Joined:
    Jun 13, 2014
    Posts:
    14
    Here are more results.

    otool Results
    These results were taken from generating an .ipa with Save for iOS Store option (Didn't offer target device option when exporting archive to .ipa).

    I also ran otool on an .ipa generated specifically for my iPad2. Those results showed only the arm64 architecture and the arm64 filesize values matched the ones below.

    architecture armv7:
    code segment size = 15187968 = ~15MB
    data segment size (mostly metadata) = 589824 = ~.6 MB
    segment + data segment = ~15.6 MB

    architecture armv64:
    code segment size = 16924672 = ~17 MB
    data segment size (mostly metadata) = 933888 = 0.9 MB
    segment + data segment = ~17.9 MB

    In IPA_Folder/Payload/MyApp/Data folder is 81 MB.

    Android

    Android .apk file = 60 MB Installed = 78 MB

    Unzipped .apk:
    assets/bin/data = 102 MB
    assets/bin/Managed = 7 MB (these are the .Net libs, right?)
    lib = 40 MB

    I can't make heads or tails of these numbers. Do these mean anything to you?
     
  10. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    745
    @DevMan5000

    1. Why is the install app size from an .ipa so much smaller than the app size from a Build/Run through XCode? Is it because I exported the archive with the development option?

    This is partly correct, when you build and run to the device from XCode it will include the __LINKEDIT (dynamic library linkage) information to your binary, which it does not when you build for the store. That can account for quite some numbers, it's described here - https://support.unity3d.com/hc/en-us/articles/209933103-Bitcode-Support-in-iOS-tvOS

    2. Obviously the thinned out .ipa (generated by exporting the archive for a specific device) installed to the lowest size, 104 MB. Can I expect this to be the ultimate final size from the App Store?

    Yes, very likely, however, as described here - https://support.unity3d.com/hc/en-us/articles/208412186 - the best mode and most assuring method is to upload a publish build to iTunes connect and see the size table apple provides, this helps to understand the different slices.

    The numbers you provide seem reasonable. The iPad2 requires the 32 and 64 bit slice so for the binary you will have the doubled amount of size of one vertical and thus bigger than on Android.
     
  11. tonyb_

    tonyb_

    Joined:
    Jun 30, 2013
    Posts:
    8
    This is a big problem for Unity developers.

    My own experience is this:

    1. Android APK on Play Store approx 40mb
    2. iOS build on Apple Store approx 190mb

    This is for THE SAME game - no difference.

    Therefore I am seeing upwards of 1000 downloads from Google and only 20 (so far) for Apple. And this I believe is because of the massive download / install size.
     
  12. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Difference is bit on unusual side.
    Could you share links to your game on Google and Apple stores?
     
  13. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
    Almost the same here:
    1) Android is about 80MB
    2) iOS is about 270MB

    Same game, same texture options.
     
  14. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Do you have App Store links to share?
    Thanks!
     
  15. Xaron

    Xaron

    Joined:
    Nov 15, 2012
    Posts:
    379
  16. hareeshreddy

    hareeshreddy

    Joined:
    Dec 5, 2017
    Posts:
    1
    Have you been able to figure out the problem @Xaron? There has been several thread regarding this very same Android & iOS app size comparison but apart from theories there has not been any proper solution yet.

    BTW I like your simulation app mind sharing the apk of it? I would love to test it out real quick ;)
     
  17. s_aturn

    s_aturn

    Joined:
    Jun 8, 2015
    Posts:
    13
    Yes even tho all of the above explanations make sense, I dont understand how it can justify such a massive difference in final instal sizes.

    I have a similar case where Android is about 70 mb while iOS is 230 mb. Like the others, same game same texture compression etc.. I've followed guides online to lighten the appsize in general, but here I need to shave a 100 mb minimum on the iOS version to be close to its Android counterpart :(