Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

IL2CPP build size improvements

Discussion in 'iOS and tvOS' started by David-Berger, Apr 28, 2015.

  1. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Hey JoshPeterson, @jesusluvsyooh,

    Note: Even though iTunes 'Build Details' indicate the 4.6.8p1 binary as 77.1mb, it is now also giving me a the warning that it exceeds the 100 MB app file limit. So this seems very inconsistent.

    So the frustrating thing is, looking at the IPA's for each build (exported as .ipa from xCode's organiser) I see that the content at this point is almost identical (in terms of size):

    Built with 4.6.8p1
    48mb - executable.
    113mb - remainder of .ipa content uncompressed
    53mb - remainder of .ipa content compressed

    Expected max size 48+53+100kb approx: 101mb
    Build size reported from iTunes: 77.1mb

    Built with 4.6.8p3
    48mb - executable.
    113mb - remainder of .ipa content uncompressed
    53mb - remainder of .ipa content compressed

    Expected max size 48+53+100kb approx: 101mb
    Build size reported from iTunes: 106mb

    Edit: So that's a 28.9mb increase that seems to come from nowhere (but the warning about the 100mb limit makes me doubt all numbers Apple is giving us here).

    So it seems it's not some spurious increase in executable size causing this. Perhaps it's the processing that occurs after/during the submission upload and processing.

    I've checked our project for use of the [Preserve] attribute and found 0 hits in code (the preserve word was found a lot in the XML files for our translated text - 'Smart Localization' asset - but I doubt this refers to the attribute.

    Unfortunately I'm not able to provide this project for inspection (that frustrates me as much as you :) ).
     
    Last edited: Oct 8, 2015
    MrEsquire likes this.
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @larku

    Thanks for the detailed breakdown. I believe you are correct about the change we made for the preserve attribute not causing any issues here, as that would increase the size of the executable, if anything.

    The way these sizes are calculated by Apple has always been somewhat of a mystery to me. I'm not sure there is much else you or I can do, sadly, which is frustrating.

    @jesusluvsyooh

    Are you seeing similar results? At least that might give us another data point.
     
  3. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    When uploading the build to the store from the Organizer there is an option to include/exclude the symbols. (dSYM file) is it enabled when you test?
     
  4. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    All my tests were without dSYM (ie, I uncheck that checkbox every time :) )
     
    MrEsquire likes this.
  5. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Thanks JoshPeterson,

    I'll just keep squeezing what I can out of my textures until it's small enough I think. I can't use 4.6.8p1 due to iOS 9 issues. I can't use 4.6.8p2 as has a bug that causes my game to crash, so it looks like it's 4.6.8p3 with the strange size issue and squeeze all my textures down to 16x16 pixels :)
     
  6. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    @MrEsquire - I've always unticked the dsym crash symbols option too.
    @larku Nice signature :D feel free to throw £50 my way when you eventually get that donation!

    I've had the email a few times, even when the final builds (according to app store details) has been below 100mb, on both iPhone 4 (ios7) and 6 (ios9) stores.

    The recent update which i released which was over 100mb on iPhone 6, and under 100mb on iPhone 4, i did not get en email about the 100mb size warning. I presumed they had both just scraped under 100mb again like the previous updates, so it was quite a shock to see the iPhone 6 final size over 20mb higher.

    @JoshPeterson - I do not have XCode 6 or Unity 4.6.8p1 anymore to test, my old macbook pro's struggling for space and performance so i tend to remove everything older once a solid stable version is released. (holding out for the new macbook pros and skylake processors out early 2016)

    Looks like its iOS 9 related to me, the iPhone 4 (iOS7) sizes have always been around the same for past few months, where as the ip6 once it had iOS9 jumped up over 120mb (was on iOS8 before that and under 100mb).
     
    larku likes this.
  7. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Added to my list!

    I'm not receiving any warning email, I'm using the size reported by iTunes connect (MyApp->Avtivity->All Builds->choose build), at the All Builds page where the binaries are listed, I get the warning icon shown there which when clicked on tells me it's over 100mb.

    How do you see this? I can only see size and it's not listed by device...

    I'm still using Xcode 6.3.2 - so I doubt it's an issue with the Xcode version for you.
     
  8. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Example email:

    That particular update i believe it was still under 100mb according to app store details despite what the Apple email said it could be page.

    @larku
    I have an iPhone 4 and 6, i checked the app stores on both separately, when the update was out. :)

    Well i guess we can rule out XCode for the size increase.
    What device are you using, and ios version?
     
    Last edited: Oct 8, 2015
  9. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I'm using an old iPad 2 with iOS 8.?? - not really relevant in my case though as I'm only looking at the size in iTunes connect (ie, no device involved).
     
  10. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    Ah, whats your game called, i'l check the size it says on app page on my iphone 4 and 6 :)
    Edit: as your on iPad with iOS 8, that means we have 3 devices between us, each on ios 7 8 and 9 :D
     
    Last edited: Oct 8, 2015
  11. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Ah, thanks for the offer but it's not approved or available yet, I'm only uploading release candidates to see how big they'll be.

    I cut/squeezed down about 5mb of textures out of my project and then uploaded again and it now indicates 74.8mb (compared to 106mb) - so there's no way that 5mb of textures made that difference directly.. BUT I'm still getting the 100mb warning. I don't trust any numbers that iTunes connect is giving me now.

    I'm going to put a support request into Apple.
     
  12. Khaled-Khair

    Khaled-Khair

    Joined:
    Jun 24, 2013
    Posts:
    9
    Coming from another thread about size : http://forum.unity3d.com/threads/ios-game-size-on-the-store.360468/
    We are facing an issue with our new game download size on the store, we are using :
    - Unity 5.0.2
    - Xcode 7.0.1

    After building the game with unity and archiving it in xCode, if we export the archive to ipa ( Save for iOS App Store Deployment , without app symbols), the ipa size is 39.4MB, but when we submit the game to App Store (through xCode organizer directly, or using the Application Loader with the ipa), Testflight shows the game size to be 172.9 MB!!!! which is a huge problem, many players will not download the game because of that.

    [Update] I checked the compressed file size in iTunes connect -> My Apps -> [Game]-> Activity-> Build details and it is showing 85.8 MB, so what does this mean?
     
  13. HuuPC

    HuuPC

    Joined:
    Sep 9, 2015
    Posts:
    7
    I got the same problem. Does anyone have solution ?
     
  14. polovaikin

    polovaikin

    Joined:
    Nov 24, 2014
    Posts:
    2
    I solved this problem! Just move back to xcode 6.4 version! :)
     
  15. HuuPC

    HuuPC

    Joined:
    Sep 9, 2015
    Posts:
    7
    It's legal for iOS 9?
     
  16. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Please provide some more information, what are you saying? if you Archive game in Xcode 6.4 you will get a final store size smaller?
     
  17. ultraschall

    ultraschall

    Joined:
    Feb 14, 2013
    Posts:
    30
    What i found after our latest app update:

    Xcode Archive (7.0.1) 263 MB ( Unity 4.6.8p1)
    > compressed filesize in itunes connect 165 MB after upload
    > Final Version in Store 230 MB after app store review


    When profiling the download it turns out that it actually only downloads 165 MB. So it seems that apple displays the file size on device instead of actual file size of the download.
     
  18. HuuPC

    HuuPC

    Joined:
    Sep 9, 2015
    Posts:
    7
    How do you profiling the download size of app?
     
  19. luxel

    luxel

    Joined:
    Mar 17, 2014
    Posts:
    3
    I'm also having the same issue. After I found a hint in google, I downloaded the ipa from itunes, and compare it with our local ipa, here are the results:

    ➜ ~ unzip -lv ~/Music/a_store.app | grep a.app/ttbz
    ;unzip59568448 Defl:N 55686987 7% 09-26-15 04:58 648764a7 Payload/a.app/a
    ➜ ~ unzip -lv ~/release/a_local.ipa | grep a.app/a
    ;unzip59568528 Defl:N 24523344 59% 09-25-15 18:59 b01702e6 Payload/a.app/a

    Yes, when using il2cpp, the whole source code is compiled into the binary file of the archive. After uploading to itunes, apple did some encryption to the binary, it really helps protected the C# source code...but is really really bad for the compression. That's why ipa is always significantly increased in size after uploaded to itunes.

    Unfortunately, I still don't have a solution for this. Our game appeared on apple store is still bigger than 100MB.:(

    P.S. I'm using Unity 4.6.8p + xcode 6.4
     
  20. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I'm not sure I'd class this as the same issue - I think it's well known that the executable is larger with IL2CPP and the issues caused to compression due to signing (there is no C# code to protect, it's already been compiled to binary code - the C# is totally gone at this point).

    The issue I (and some others) were describing is a disparity between different IL2CPP builds (ie, not comparing to mono builds) and the vastly different sizes being reported by iTunes Connect.
     
  21. ultraschall

    ultraschall

    Joined:
    Feb 14, 2013
    Posts:
    30
    I am using a mobile bandwidth profiler to check the actual download size
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @luxel

    In order to analyze the binary sizes, you may want to have a look at the first post in this thread if you have not already. It has a nice description about about to use otool and size to have a look at the parts of the binary that are code and the parts that a data.

    With IL2CPP, you should find that the code segment of the binary (which does not compress) is significantly smaller than the code segment with the Mono scripting backend, for armv7. This is mainly because we use thumb instructions with IL2CPP, which were not supported with Mono. If this is not the case, please let me know - we have a bug to correct then.

    Of course the universal binary produced from Xcode with IL2CPP also has a large arm64 slice, so the total code size for IL2CPP will be necessarily larger than for Mono.

    Note though that Mono also converted the C# code to a native binary for armv7, so there is no difference between IL2CPP and Mono in this respect. The C# assemblies ship with a Mono build because they are used for metadata at runtime, not for executable code. That same metadata exists in the global-metadata.dat file for IL2CPP. Both the assemblies (for Mono) and the metadata file (for IL2CPP) should compressible.
     
  23. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Is there going to be any further work on improving size?

    Maybe the issue is not IL2CPP specific, my game on Apple store 500mb, Android Store 155mb
    No difference in code except for a few plugins.

    I really think its something to do with texture compression.
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @MrEsquire

    Yes, we have some more build size improvements coming, although I don't think we have anything to bridge a gap that large. In general, we're looking at about 5% improvements in executable size at most for the current changes we are considering.

    It might be worth looking outside the executable to find that much size difference.
     
    MrEsquire likes this.
  25. doterax

    doterax

    Joined:
    Jun 10, 2015
    Posts:
    4
    @JoshPeterson in Unity 5.2.2p4 still duplicate global-metadata.dat also build has unused file UnityEngine.xml

    Duplicate of global-metadata.dat occurs in Copy Bundle Resources Build phase in Xcode
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @doterax

    Can you submit a bug report for this so that we don't loose track of it? I don't believe that we ever saw a bug report before on this issue.
     
  27. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I reported a bug about UnityEngine.xml added to builds. I received an email a few days ago that it should be fixed with 5.2.2p3.... i haven't validated it myself yet.
     
  28. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    When did you report this bug out of curiosty, collecting some mental stats?
     
  29. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Case 720207 reported on August 16th
     
  30. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Excellent QA and Unity speeds.. 3 months wait(not surprised, and they so quick to get customers make bug reports)
    Sorry for the of-topic, waiting for the 5.2.3 final release that I heard maybe out this week.
    Hopefully it will have the fix in it.
     
  31. eduardocoelho

    eduardocoelho

    Joined:
    Dec 18, 2013
    Posts:
    10
  32. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    Have anyone found the reason or fix for the bloated app store size? My app shows more than twice the amount of the actual size of the app on the app store and even downloading it does not take up as much as what is shown but more closer to the actual size. Ive emailed unity regarding the problem and this is what they got back to me.

    Thank you for contacting App Store Developer Support about the file size of your app.

    When you deliver an app to Apple, it is encrypted for DRM purposes and recompressed. When the encryption is added, the size of the compressed file will increase.

    The exact size of the increase will vary from app to app. The size increase can be large when the binary contains contiguous zeros. We are unable to guarantee the size of your file after the encryption has been added.


    Could anyone or someone from unity shed some insight on what exactly the problem is?
     
  33. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @chorusgames

    I don't think that this email is from Unity. Is it instead from Apple? After some discussion, we're not entirely sure what this email means. Can you follow the analysis steps listed at the start of this thread and provide some numbers for your app here? That might help us sort out what is occurring.
     
  34. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422

    This is certainly one of Apple's awesome emails. What this email is saying (poorly) is that.

    1. Apple encrypt the binary executable portion of your app.

    2. The encryption makes compression useless (can even increase size) since encrypted content is essentially random.

    3. An IPA built with XCode is not encrypted and does not exhibit this uncompressed binary symptom.

    4. When you submit your IPA to Apple, they rip the binary out, encrypt it and put it back (that's a simplification, they do other things also.)

    5. If your binary happened to be padded with a lot of zeros (dunno why thy single out this scenario) then there'll be a larger discrepancy between the IPA size you saw come out of XCode and the IPA size after Apple process it for the store since your zeros compressed very well before encryption.

    6. Point 5 is somewhat moot as you'll already see a significant increase in size without a zero padded binary.
    This is old but give a decent overview: http://www.indiepinion.com/steffenj/how-to-calculate-the-size-of-an-iphone-app-after-approval/

    I believe things have changed somewhat with bitcode builds and other bits, but the concept stays the same.

    IL2CPP builds contain a MUCH larger executable than mono builds and hence you'll get more of the size increase effect.

    Note also that IL2CPP also contains 32 and 64bit code, so you can expect some significant increases there too.
     
    Last edited: Jan 26, 2016
  35. anirudha_vfx

    anirudha_vfx

    Joined:
    Oct 12, 2013
    Posts:
    11
    Today I made my iOS app live on appstore.
    The ipa size is 45mb. The itunes connect also showed the builds compressed size as 45mb. But after the review and go live, the appstore on iphone is showing the download size at 408 MB!
    This is really hard to comprehend.
    But while downloading on the device, the actual downloaded data size is still ~45MB.
    My apps android build is just 30MB!
     
  36. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    @anirudha_vfx

    Did you find a solution?
    I'm still working on my app which is pretty much ui only. At the moment I have an android build of 30mb too.
    Then I generated for ios, archived, export for ios app store. There I get a 400mb file which contains two architecture files with 199mb each.

    when I select the archive in the xcode organizer and click Export , Save for iOS App Store Deployment and THEN
    UNcheck BOTH "Include Appsymbols" and "include Bitcode"
    Now I have a 35mb Unity-iPhone.ipa Universal Build, which would be great, right?

    Can you try to submit that to the Appstore via the webform and have a look again?

    I tried to drag and drop the Unity-Iphone.ipa in the xcode->devices manager onto my iphone but I got an error "App installation failed - A Valid provisioning profile for this executable was not found". Don't know what to do from here but maybe you find out.

    Please write here if it worked out for you.
     
  37. CPXTom

    CPXTom

    Joined:
    Apr 24, 2010
    Posts:
    113
    Hmm including dSYM and bitcode should not increase the size for the app store. Both dSYM and bit code are not served to users, they kept on apple's servers, separate from the app. In iTunes connect it will list the total size with dSYM and bitcode, but the size listed in the app store should only be the size of the app itself.
    The last build we shipped including dSYM (have not submitted with bitcode yet though) and this is how it worked.
     
  38. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    Last edited: Feb 5, 2016
  39. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Note, I uploaded to Apple yesterday and I found that they now give explicit download sizes for your binaries for each device - I'd check what the actual download size is there (if you haven't)

    iTunesConnect->App->Activity->All Build then open the build and click the App Store File Sizes to see the real figures.

    I'm only mentioning this as this is a new feature for me (was not available last update) so you may not be aware also.
     
    CPXTom and Moonjump like this.
  40. amanset

    amanset

    Joined:
    Oct 19, 2013
    Posts:
    11
    Indeed. I just noticed this and I just don't understand what is going on.

    I just updated from Unity 5.3.0 to 5.3.2.

    Build 39 of my game, built with 5.3.0 has this in iTunes Connect:
    Compressed File Size: 59MB
    App Store Universal Size: 40.4 Download, 51.5 Install Size
    Testflight reported size: 32.4 MB

    Build 40 of my game, built with 5.3.2 has this in iTunes Connect:
    Compressed File Size: 210MB
    App Store Universal Size: 39.8 Download, 48.5 Install Size
    Testflight reported size: 147.6 MB

    This game isn't live yet and I am worried about what size it is going to be on the store. Do I trust the App Store estimated size shown? Is the huge Testflight size because Testflight adds debugging data? What actually is this "Compressed Size"?

    Something has clearly changed with Unity (I have not updated Xcode) but I have no idea what and/or if there is anything I can do.
     
  41. amanset

    amanset

    Joined:
    Oct 19, 2013
    Posts:
    11
  42. heinzkuang

    heinzkuang

    Joined:
    Apr 5, 2013
    Posts:
    18
    @David Berger

    I built a empty project to xcode with IL2CPP (strip engine code is checked). A file named libiPhone-lib.a which size is 1.1G! And the binary is 560M! Why???
    5.3.2 p4
     
    Last edited: Mar 11, 2016
  43. heinzkuang

    heinzkuang

    Joined:
    Apr 5, 2013
    Posts:
    18
    I call the itunes connect Customer Service,and they told me that the size show on iphone appStore app is the truly size for iphone user download.
     
  44. heinzkuang

    heinzkuang

    Joined:
    Apr 5, 2013
    Posts:
    18
    The size in itunes connect shows may not the final download size for users.
     
  45. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    You may not be aware but Apple have significantly improved their iTunes connect file size reporting (it now gives you the actual download size for each device type - ie a list of 20+ sizes).

    I think it's pretty accurate (if not exactly accurate) now.

    This is a recent change, if you have not uploaded a new binary recently then you may not have seen the significant improvements.
     
  46. heinzkuang

    heinzkuang

    Joined:
    Apr 5, 2013
    Posts:
    18
    I just uploaded my new binary 3days before and its already for sale. On iphone's appstore,the size information shows the download size is 300+M, and download speed very slow(I'v tested on two different devices with two different net environments). It seems the 300+M is the real size for download,not the size shows on itunesconnect(65M for iphones and 80M for universal) .
     
  47. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Ouch, can anyone else verify this? That's not what I'm seeing.

    My iTunes listing shows 89.3 MB, and the sizes shown in iTunes connect are 97 MB (universal), 74.6 MB (iPhone 5s, 6, etc).

    So the figure shown in iTunes is somewhere between the two values shown in iTunes connect.

    I have not verified the actual download size though.
     
  48. SOMPOM

    SOMPOM

    Joined:
    Jul 17, 2015
    Posts:
    3
    Hi everyone.

    here is what we got. I joined the screenshots from the build information we have on iTunes Connect and from the AppStore display.

    So it says that the estimated download size should be 37.5Meg
    But the size displayed on the AppStore is 95.6 (iPhone 6) which match the install size column

    It was fast to download on a low connection, so the size to download was really around 40megs.
    Is it normal and expected? I always thought that the AppStore size display was the download size and not the install size.
     

    Attached Files:

  49. heinzkuang

    heinzkuang

    Joined:
    Apr 5, 2013
    Posts:
    18
    How do you make sure that the download size on your ip6 is around 40M? 95.6M for download also can be very fast,at least I downloaded an app with 88M also very fast(link fast too).
     
  50. SOMPOM

    SOMPOM

    Joined:
    Jul 17, 2015
    Posts:
    3
    The network we have here. If the file was 100Megs it would have taken longer to get on my device. But it's not bullet proof.