Search Unity

Tips for reducing finished iOS app size?

Discussion in 'iOS and tvOS' started by lostminds, Oct 4, 2019.

  1. lostminds

    lostminds

    Joined:
    Jan 17, 2019
    Posts:
    51
    Hello,

    I've just finished my first iOS Unity app and released it to the appstore. It's not a big project, and it's not a big problem, but I'd like to see if I can reduce the app size to a minimum. Following advice I've found online I've looked at the build report to see a breakdown in build sizes and what my largest files were, and this is what I got:

    Build Report
    Uncompressed usage by category (Percentages based on user generated assets only):
    Textures 20.3 mb 63.2%
    Meshes 242.5 kb 0.7%
    Animations 0.0 kb 0.0%
    Sounds 9.6 kb 0.0%
    Shaders 2.1 mb 6.7%
    Other Assets 703.6 kb 2.1%
    Levels 149.8 kb 0.5%
    Scripts 194.7 kb 0.6%
    Included DLLs 6.4 mb 20.0%
    File headers 2.0 mb 6.1%
    Total User Assets 32.1 mb 100.0%
    Complete build size 699.4 mb
    Used Assets and files from the Resources folder, sorted by uncompressed size:
    3.0 mb 0.4% Built-in Texture2D:
    2.1 mb 0.3% Assets/UI Graphics/Launch title graphic@2x.png
    1.6 mb 0.2% Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader


    As expected most of the space was Textures, 20.3MB, but what I didn't expect was the three largest files: an unnamed Texture2D and my launch screen logo, followed by a post processing shader that I think should have been stripped since I don't use any postprocessing. After looking online it seems that the graphics used in the launch screen (including the background that's the unnamed Texture2D) are for some reason re-saved uncompressed in the build process, which is why they're so big (the file "Launch title graphic@2x.png" is 47k in the Assets folder, and 2.1MB in the list above). Does anyone know if this is true, and if there's any way to avoid this?

    The other question this raised was if any of this matters, since the complete build size listed (699MB!) doesn't really seem to reflect anything meaningful for the resulting app size. When packaging the app for the AppStore in XCode these things seem to be compressed(?) and stripped anyway and the build above resulted in a 54MB app package. So maybe the uncompressed launch screen graphics from the list above get compressed in this step anyway?

    Still, 54MB is quite a lot for a simple app, and 22MB extra on top of the uncompressed assets and code listed above. This article (https://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html) in the manual seems to indicate an empty Unity project should fit in a 12MB app on the AppStore.

    So, does anyone have any tips for reducing the size of the finished iOS app package?
     
  2. kaarloew

    kaarloew

    Joined:
    Nov 1, 2018
    Posts:
    360
    Where is the Launch title graphic@2x.png file located in your project hierarchy? And are you sure that there isn't a script / gameobject that has a reference to it? (e.g. dragged wrong file to material)
     
  3. lostminds

    lostminds

    Joined:
    Jan 17, 2019
    Posts:
    51
    (Sure I replied to this earlier, but my reply seems to have disappeared?)

    "Launch title graphic@2x.png" is located in the same Assets/UI Graphics/ folder as all my other UI icons and such, and they all get the correct size. I'm pretty sure it's not referenced by any other script, but why would that matter? The problem isn't that it's included, it should. The problem is it's 2.1MB in size instead of 47k as the file is.

    And also, does anyone know of a way to not include the Shaders/PostProcessing/UberPost.shader in your build? It seems pointless since I don't use any post processing, or is it actually used for something else as well?
     
  4. kaarloew

    kaarloew

    Joined:
    Nov 1, 2018
    Posts:
    360
    If it is a launch image for iOS / Android side, then it shouldn't be in Build report. The size increase (47k -> 2.1MB) is because it is non compressed asset. Unity will LZMA compress it afterwards so it will be smaller in package, but most likely it will still be somewhat bigger than the PNG image.
     
  5. lostminds

    lostminds

    Joined:
    Jan 17, 2019
    Posts:
    51
    Well, it's not a launch image, it's graphics files for the unity splash screen (where you can also add your own logos etc). But then I guess it doesn't matter they're so big if they're re-compressed in later steps.
    Still seems strange/buggy that those two graphics are the only ones that are uncompressed in the build report, and confusing that the background one doesn't even show the proper filename and is just called Built-in Texture2D:
     
  6. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    Have a look in Edit > Project Settings > Graphics. Is it in the list of "Built-in shader settings", "Always Included Shaders" or "Shader preloading"? Remove if it is. You might find a few others that can go.
     
  7. lostminds

    lostminds

    Joined:
    Jan 17, 2019
    Posts:
    51
    No, UberPost.shader is not in either of the Graphics settings lists and it's not in the Player prefs optimization preload assets list either.