Search Unity

Bug The "Localization" package increases the weight of the apk by 10 mb

Discussion in 'Localization Tools' started by Francesco-FL, Sep 22, 2021.

  1. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi,

    I know the explanation may be a bit vague, but I really don't know where to put my hands.

    I downloaded the localization package, and what I did was just create two localizations (one Italian, one English) and create a single localized string (the name of the app).

    Initially in the builds it did not seem to increase the weight, but today when during the final build (after I made several changes, not to the localization) I find myself with an apk of 10 mb higher (before I had an apk of 23 mb, now 33 mb) .

    I'm pretty sure it's this because if I remove the package and remove the folder with the localizations (mine weighs 13 kb) and the "AddressableAssetsData" folder (which I don't know what it is but it weighs 31 kb), it returns me a normal apk from 22 mb. With the localization instead 33 mb.

    Is an increase of this magnitude normal although the only thing I did was create a single localized string and assign it to the name android app? If it is not normal what could be the causes? Where should I look for what increases the space?
     
    mfakkaya likes this.
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    That does sound like a significant increase. I would not expect it to be that large, I'd have to take a look at the project and see what's getting included. One thing you can quickly try is to check the addressables group is using compression on the bundles. Select the group's and check the setting in the inspector.
     
  3. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I checked and I think the compression is there, how do I share the project with you? Do I create a bug report and give you the number?

    By the way I have deleted all the files in my project, I have encountered the problem even with only an empty scene.

    In the meantime, I'll write you some settings: IL2CPP, .NET Standard 2.0, Master, ARMv7 and ARM64, Use incremental GC.


    EDIT:
    I forgot to write the version, I'm using version 1.0.1, but I also found the error with 1.0.0
     
    Last edited: Sep 23, 2021
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    1.0.0 and 1.0.1 are basically the same, there are just documentation changes.
    Look in the project library folder and there should be an addressables folder, see how large the built asset bundles are.

    You can file a bug report with the project for us to look into it
     
  5. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    The entire AddressableAssetsData folder weighs 30 kb. Submitting the bug report
     
    karl_jones likes this.
  6. mfakkaya

    mfakkaya

    Joined:
    Mar 19, 2016
    Posts:
    21
    i am having the same problem. localization package increases apk size. I'm trying to reduce the file size of my game below 10mb. but after installing localization package, apk size increased by 60%!

    what i did is just add 2 languages (english and turkish). I translated 15 words for testing purposes. It's not something that will increase the file size. Apparently a lot of unnecessary stuff is included in the build package. What is the suggested workaround to keep the file size to a minimum? even 1 mb would be too much depending on the intended use. Unused features need to be stripped. Before I had an apk of 11 mb, now 17 mb.

    (I'm sorry I do not know english. this text has been translated with google translate)
     
    Francesco-FL likes this.
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    We
    Try enabling stripping in the project settings, it could be from the additional dependencies.
     
  8. mfakkaya

    mfakkaya

    Joined:
    Mar 19, 2016
    Posts:
    21
    stripping level is set to high. I actually use the localization package asset as it came out of the package. sorry, I checked the editor log and the self compressed "textures" and atlases have increased in size. I didn't make any changes for it. Added localization and addressable only. Maybe it's a bug, I should check. I can't say for sure how much localization contributes to apk size right now. It's a good idea to check this out.
     
  9. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Sent, Case 1367978
     
    karl_jones and Peter77 like this.
  10. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    They still haven't answered me (I know it sometimes takes time) (I don't wish the report wasn't "strong" enough, I sent them the project and linked the thread to them saying the information was here).

    Message mostly addressed to other users: Has anyone else got similar behavior? (I mean about 10mb added for negligible use of the package)
     
    karl_jones likes this.
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Oh yes I just checked. It only has a rating of 3 so probably would not have been looked at.
    I have asked QA to look at it so hopefully it will get some traction although they may request further details.
    Next time provide more details or at least write more so it thinks you provided more details ;)
     
    Francesco-FL likes this.
  12. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi, still nothing. I hope to speed things up by showing you the steps I take to get the error, they are super simple, I use an empty project, import the package and define a string.

    In this video I show how I start from an empty project to get the error (12Mb to 24Mb) (there is no audio) (I speeded up all loadings to x64, I ran the steps slowly so that you could possibly edit the speed of the video with the YouTube player)


    In practice: I create a new project, modify the player settings and run a normal build without localization. The apk is 12 Mb. Then I add the locale, create the locals and add the string. I run the second build. The apk is 24 Mb


    I also write the points of the video:
    - I set the player settings (0:30)
    - First build finished (without localization) (1:40)
    - I create the locals and the localized string (2:34)
    - Second build finished (with localization) (6:04)

     
  13. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Hi would it be possible to submit this as a bug report so QA can look Into it?
     
  14. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Case 1371474
     
    karl_jones likes this.
  15. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    The new bug report I submitted appears empty in the fogbugz, is it a bug? Does it even appear to you that it is empty?
     
    Last edited: Oct 12, 2021
  16. 1; you have two bug report with the same title the 1367978 has a reference in it to this forum
    2; you shouldn't share your fogbugz links and screenshots on public forums, as you can see in the screenshot I attached, anyone can go and see your bug report both past and future and you never know when you need to share something you don't want to publish to everyone. I have covered up the sensitive part which can be used in the URL.

    screenshot.png
     
  17. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi, thanks for the information. I knew I don't have to share fogbugz links and in fact I had cropped the image, but I didn't link that the case number was the fogbugz link. I have removed my image, but the problem remains.

    Yes I have two bug reports with the same name, is this a problem for the system? In the older one I had only linked the forum as it appears in your image. In the most recent one I had written much more by also connecting the YouTube video and explaining all the steps but in the fogbugz it appears empty to me.
     
  18. No problem! The fogbugz link is the case number AND the hash together. You can share the case number, but do not share the hash if you don't want people to sniff around.

    As of your bug reports, the older one only contains a link to this forum, the newer one is empty. You can ask to close the newer one and simply reply in the mail to the older one with more information. You don't need to open new bug reports if you just want to add new information.
     
  19. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    The problem is that the bug report where I linked the forum has a low strength (so maybe it won't be looked at), and I don't think the strength increases by sending an email with other information (I don't know, only the guys from Unity I think they can tell)

    The empty bug report I think is a Unity bug, I had written a lot and the strength of the report was at its maximum. So I was asking @karl_jones if he too on his side (which maybe is different) detects an empty report or not. Otherwise I'll have to send a third report, and the times will get even longer ...
     
  20. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    I don't think they update when you add more info. What are the bug numbers? I can update them.
     
  21. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    My question was whether this case appears empty to you <1371474>, or whether a long description I had given appears to you instead.

    I had written it so either it is an upload error and therefore did not upload it correctly, or the fact that I had a report of the same name is a problem, or it is a fogbugz error that does not show it to me.

    If the case appears empty on your side, I'll send another one, that's what I said.
     
  22. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Yes that's fine. I can see the description. QA were looking at it last week, I asked them to do a breakdown of the increases using the build report. From what I can recall the script increase was only a few meg so there's a lot unaccounted for. It does seem strange. I asked them to send it to the addressables team first as I'm fairly certain it's something on their end.
     
    Francesco-FL likes this.
  23. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi, the bug has been recognized:
    https://issuetracker.unity3d.com/is...-building-project-with-localization-package-1


    Then I got two strange e-mails from no-reply@automation.atlassian.com whose name is "Unity Bug Reporting Portal".
    Is it from Unity?
    They sent me an email similar to fogbugz where they said they had created a report and then a minute later an email confirming the issue, at the same time asking me to send more information if I had it (but if it has been confirmed what do they need?)
     
    denis_bogdanov likes this.
  24. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Yes that's from us. I can see the email confirming the issue and then the bug was transferred into our JIRA bug system which must be theno-reply@automation.atlassian.com email address. I can't see any emails from this though so I'm not sure what info they are requesting. The bug is now with us though so it will get looked at. Its LOC-432
    https://issuetracker.unity3d.com/is...en-building-project-with-localization-package
     
    Francesco-FL likes this.
  25. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi,

    Thinking about it, I'm considering whether to actually use the plugin or not, maybe you can give me an advice. My only focus at the moment is the localization of the app name (I have already created an internal translation system and at the moment I would not want to change it).

    That is, the localization package I would use it only to locate the name of the app, but given all the features it has, I wonder if it's a waste and if maybe I'm not considering another simpler choice.

    Do you know if there is a way to locate the app name without the package? Or whether it is better to use the package anyway.


    At the moment I create for Android and iOS

    ps. I had already searched for alternative methods on the internet some time ago and found some results. But from my memory, they were all threads from many years ago, and I remember only finding them on Android. This is why I ask you.
     
  26. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Yes it can be done. You could just pull out the scripts we have to do it that are in com.unity.localization\Editor\Platform\iOS and modify them to fit your needs.
     
  27. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi,

    in these days I have looked at it but I have understood very little. I am not used to modifying the plist or the manifest and when I extract it and delete the package, I also lose all references and it sends me a bit confused.

    As for iOS, until now I had only edited the plist to add the IDFA pop up key (which I'd like to locate, but one step at a time.)
    As for android, on the other hand, I have never handled anything that concerns the manifest or similar.

    From the extracted folder I only deduced that maybe the classes I have to handle are those called "player" and I have deleted everything related to the icons and keys for permissions, but I don't really understand where to put the localizations and the name of the app, or possibly where to add the localized string to the plist for example.


    PS. If you don't have time to write me about this, no problem, I can possibly use the full package or find other ways.
     
  28. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    I think the simplest solution would be to use the Localization package to handle this. Copy the package so its in your project Packages directory, then you can make changes to it. Delete or disable the file LocalizationBuildPlayer.cs
    You should now be able to setup the app name localization but not use localization in the player. You wont need to build the addressables etc and the String Tables you create will just be used in the Editor when generating the app name localization data.
     
  29. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    But isn't there an easier way yet? I mean, I was thinking more of a single script like postbuild type scripts to do like this:

    Code (CSharp):
    1. [PostProcessBuild(100)]
    2. public static void OnPostprocessBuild()
    3. {
    4.     // English
    5.     Create_localization("en", "English_app_name")
    6.  
    7.     // Italian
    8.     Create_localization("it", "Italian_app_name")
    9.  
    10.     // etc...
    11. }
    12.  
    13.  
    14. void Create_localization(string language, string app_name)
    15. {
    16.     // Create localized android or ios
    17. }
    Which from what I understand would only mean correctly arrange what is already in the "player" files of the com.unity.localization\Editor\Platform folders, or am I wrong?

    My problem is that I don't know how to arrange them, that's all, that is, I don't know what to put in that "Create_localization" function to work with two simple strings instead of tables, app info and all stuff that at first glance (but which maybe isn't, I don't know) it seems useless considering what I actually need.
     
  30. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    That is the easiest way.
    The alternative is to pick apart the code.
    Look at the code in the iOS folder and you will see what you need to add. You need to update the xcode files and generate files for each language, it's more complicated that you would expect. Those xcode file structures are not the most user friendly :(
    It should be possible to do it by just copying those 3 files.
     
  31. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I copied and modified those files both Android and iOS to create localizations based on the languages I insert in a script, so I think I have reached the solution to my problem.

    As for Android, I have tested it and it seems to work without errors. When it is in a known language, it sets its own localized name, otherwise it uses the Product Name.

    For iOS, on the other hand, I was only able to test it through Unity's "Simulator SDK" and then ported to Xcode and run on a virtual iPhone 8 with ios 14.5. It recognizes the localizations, but when I switch to a language that I have not set, instead of using the Product Name of the project, the name does not change, and remains so (to the previous localization).


    1. Do you know if it can be a simple error due to the simulator?

    2. I would like to share the code both for any advice/warnings and to help whoever is in the same case as me, since you are the producers of the package, I ask. Obviously I was thinking of opening a new thread and attaching the scripts, nothing complicated.
     
  32. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Im not sure about the product name issue. Im not that familiar with iOS, Ill take a look at what happens with ours and see if it's the same next week.
    I'm happy to look at your code.
     
  33. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I have to check one last thing and then publish the code.

    Meanwhile, I tried to bring an app created with the localization package (and with the relatives translations of the app name) into the simulator and it presents the same problem.

    How to reproduce:
    - Create a project, download the localization package, create locales in ("en", "fr", "es", "it"), create a translation table and assign the translations of the Product Name in the respective fields of the name of the app
    - Put "Simulator SDK" to use the simulator in Xcode
    - Bring the project to Xcode and start the simulator (I used iOS 14.5 and iPhone 8)
    - Change the device language to French, look at the app name (it displays correctly localized), then change the device language to Turkish (or any non-localized language).

    Expectation: Show Product Name as the app name
    Result: the name of the app does not change and remains that of the French localization.

    Submit a bug report?



    Then I noticed another thing but I don't know if it's your problem, as you can see in the image below the localization codes are replaced with the name of the language, but not for Spanish.

    Immagine 2021-10-30 151021.png
     
  34. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Yes could you please file a bug report for both these issues?
     
  35. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Sure, just one for both or two bug reports?
     
  36. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    2 please :)
     
    Francesco-FL likes this.
  37. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Case 1377124, Case 1377126
     
    karl_jones likes this.
  38. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    The problem of the localization of the iOS name that I had previously told, also occurs on a real device (I released the app on the store). If I switch from a supported language to an unsupported one, the name remains with the previous localization. (I will also add this message to the bug report, I wrote it here for completeness)

    The app I released does not use the package but the code I modified (which I will publish in another thread shortly). But the fundamentals are copied from your scripts so maybe the error occurs to you too.
     
    karl_jones likes this.
  39. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
  40. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    In the bug page (the one with the wrong app name in case of unsupported language) it says that it has been fixed in 1.1.0
    I looked at the changes made to the single file dealing with localization and noticed that what should fix the bug is this:

    Code (CSharp):
    1. project.SetDevelopmentRegion("en");
    2. plistDocument.root.SetString("CFBundleDevelopmentRegion", "$(DEVELOPMENT_LANGUAGE)");
    3.  
    4. // Inclusion of this key improves performance associated with displaying localized application names.
    5. plistDocument.root.SetBoolean("LSHasLocalizedDisplayName", true);

    In my files the bug doesn't fix it.
    That is, if I have "Ita-Eng" as localizations with "Eng" as default, and I download the app with the Italian language of the device, I will see the name of the app in Italian. But, if I then change the language to German, the app name remains in Italian (when it should be in English instead).
     
  41. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Did you only take those changes? We also had to update the SystemLocaleSelector to get the preferred language from iOS.
     
  42. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Ah, no, I thought the files contained in Editor => Platform => iOS were enough, which were enough for me to create the localization of the app name.
    I thought the default language definition only needed a small change like the one I wrote above. (also because I don't use your "Locale", my goal was only to define "en" as the default language for the app name)

    This is an example of what I have in the project (I haven't updated it with the lines of code written above):
    https://forum.unity.com/threads/loc...ons-without-the-localization-package.1191445/
     
  43. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    Ah sorry, you are correct, I was thinking of a different bug.

    This is what I wrote in my pr at the time

    Unfortunately, the iOS documentation does not seem to be correct or is lacking information. I spent a long time trying to understand why it would fall back to English, even when the system was not English, the simulator was not English and xcode had a different language. There seems to be something making it happen but it's not documented and is on the iOS side. I also spoke to our iOS team who pointed me to the same info.
    I think your issue is likely to do with the devices list of supported languages, it uses this info to determine what to fall back to.
     
    Francesco-FL likes this.
  44. Alvarden

    Alvarden

    Joined:
    Feb 22, 2019
    Posts:
    61
    Hello. I know this is an (relatively) old thread, but i wanted to share my experience with the Localization Package regarding the apk's build size (spoilers: that same issue still happens, even with an updated version).

    I was using the package to localize an app with just two languages. So far, everything was ok. But when i built it, i noticed that the apk's size increased around 5-6MB, which was a lot, given that i only localized text and that was it. When installed, it was even worse: it was around 20MB bigger than the previous version before installing the package.

    After trying to find out how to fix that, in the end, i opted to use a more lightweight alternative that did the job.

    Details:
    • Unity 2021.3.16f1
    • Localization version: 1.3.2 (with Addressables 1.19.19)
    • Using IL2CPP, incremental GC, targeted ARM64 and Stripping Level was medium.
     
  45. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
    The majority of the increase is coming from the package dependencies, the biggest being newtonsoft Json. More info here https://issuetracker.unity3d.com/is...en-building-project-with-localization-package
    We will try and look at this in the future to see if we can reduce the size of the newtonsoft dependency.
     
    Last edited: Mar 15, 2023
    mandisaw and Alvarden like this.