Search Unity

Can't release : using IL2CPP crashes

Discussion in 'iOS and tvOS' started by Mons1999, Mar 29, 2015.

  1. Mons1999

    Mons1999

    Joined:
    Sep 24, 2012
    Posts:
    33
    Hi everybody !
    I nearly finished my game (two years working on it), and I was so happy knowing that I will release it soon until I discovered that Apple changed their requirements : Beginning on February 1, 2015 new iOS apps submitted to the App Store must include 64-bit support.

    So I upgraded from Unity 4.5.5 to Unity 4.6.3 (it didn't upgraded my project and just opened directly is it normal ?).

    When I built for my iPhone, I realized that when I used 'Mono 2.x' scripting backend, it still worked, but when I switched to IL2CPP and whatever the architecture was (ARMv7, ARMv64 or Universal), it crashed.

    The error shown is really weird (see the picture below) : even if my game uses the same reasonable memory amount (250-300mb) and even if I close all the other applications, the amount of memory used by "Other Processes" is 2,8GB ! How is it only possible on a 1GB RAM device ? Even if the free memory is negative, it only crashes at the second scene loaded (after 30sec), and the message shown by xcode is "Terminated due to memory error".

    Has anyone faced the same problem ? Is it only possible to be solved ? Please help me I can't publish my game without using IL2CPP and I'm quite stuck...

    PS : I tried with Unity 4.6.2, 4.6.3 and 4.6.4, same result. I can't use Unity 5 because their are many other problems that appear.

    Wierd RAM STATS.png
     
  2. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    The executable size with IL2CPP is currently MUCH bigger than with the mono backend, which could be the source of your memory issues. They're working on reducing the size with a patch in the near future. Scan through this thread for all the details. It started a long time ago, but the IL2CPP devs are very active and there's several posts from them in the last week or so with the latest status updates.

    http://forum.unity3d.com/threads/4-6-ios-64-bit-beta.290551/
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    As I mentioned on the other thread, the best option here is to submit a bug so that we can look at this project, if possible. We have not seen something like this before, so we would like to track down the cause. Thanks.
     
  4. Mons1999

    Mons1999

    Joined:
    Sep 24, 2012
    Posts:
    33
    Ok thank you for your answer so for now we can't do anything else than waiting ?

    I had another question on the real size of the executable. I noticed that using Mono 2.x, the size is 445MB and using IL2CPP it doubles and becomes 995MB.
    Is it only the size of the XCode project (because 32bit and 64bit builds) or will it be the same on the released app on the App Store ? This question seams obvious (I hope) but does Apple split the binaries depending on the device to reduce the app size ?

    Thank you for your quick answer Josh. My project is too big (16GB) but I will try to reproduce the same case in a smaller project. Just to be sure : what you have never seen before are the weird Xcode statistics or the crash ?
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    Unfortunately, there is not much you can do about app size now. We will be releasing some changes too to bring IL2CPP app size much closer to Mono (usually within 10%). Even after we get this change released, we will continue to decrease the application size.

    I'm not completely clear about how Apple measures, reports, and enforces restrictions on app size. I do believe that an IL2CPP build with both ARMv7 and ARM64 support will be about twice as big as a Mono build with only ARMv7, since their are two executables instead of one. We're hoping to make this situation better in the future by sharing data between the binaries where we can.

    The part of this that we have not seen is the increased memory usage for IL2CPP. Thanks.
     
    moonjump likes this.
  6. moonjump

    moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,323
    Is that double the entire app size?

    In the ARMv6/ARMv7 days, building for both increased the app size a lot, but not double. Only the Unity part of the app was repeated, not the developer code/assets/etc.

    p.s. This is just curiosity. It does seem unclear at the moment with IL2CPP how much effect optimisation will have, and how big build sizes will be in the future. I just found Josh's post interesting and useful.
     
    Last edited: Mar 31, 2015
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    @moonjump

    Yes, I believe only the binary parts of the app are doubled. That is, only the parts of the app which actually differ between ARMv7 and ARM64. Sorry that I was unclear.
     
    moonjump likes this.
  8. Mons1999

    Mons1999

    Joined:
    Sep 24, 2012
    Posts:
    33
    Thank you so much for answering so quickly !
    It retried reproducing the case in a smaller project based on your Sample Assets and this is the case link : Case 685749.
    It noticed something : with Mono2.x builds, the RAM stats shown by the XCode profiler are real (the arrow and the memory usage). With IL2CPP builds, all the stats are fake excepted the ones of the blue indicator behind the arrow, which becomes independent from it. I hope this can help you knowing what is the real amount of memory used by IL2CPP builds.

    Indicators stats.png
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    @Mons1999

    Thanks, I think that this will be helpful!
     
  10. Mons1999

    Mons1999

    Joined:
    Sep 24, 2012
    Posts:
    33
    Did you face the same problem or the case is useless on your computer ?
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    @Mons1999

    We have not yet investigated this bug, so I can't say. But I believe the information will help.
     
  12. Mons1999

    Mons1999

    Joined:
    Sep 24, 2012
    Posts:
    33
    Ok thank you please tell me when you do and if you need another case.
    Good luck !
     
  13. Mons1999

    Mons1999

    Joined:
    Sep 24, 2012
    Posts:
    33
    Did you have time to investigate it sir ?
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    Sorry, we have not investigated this yet.
     
  15. frozenpepper

    frozenpepper

    Joined:
    Sep 17, 2007
    Posts:
    210
    Any update on this issue ?
    We are experiencing "Application terminated due to memory error" too, both with Mono and IL2CPP while memory used should be well below the limits.
    Also to note that "Memory error" is different from "Memory Pressure" crashes (which we receive when we try to use more memory than that available).

    Project is huge so it will be hard to submit bug report.
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    @frozenpepper

    If you have not done so yet, it might be useful to build with IL2CPP and debug the generated code in Xcode when the problem happens. As you mentioned, the problem might not be too much memory usage at all, but something else.
     
  17. frozenpepper

    frozenpepper

    Joined:
    Sep 17, 2007
    Posts:
    210
    Thanks for the fast reply. Hard part is that xCode doesnt generate a stack trace of kinds and problem seems to appear semi randomly. What we are doing is allocating and releasing loads of memory, but in principle well below the limits. Will investigate more through IL2CPP builds.
    Also to mention that for the affected project we are using unity 4.6.8p3
     
  18. Saddamjit_Singh

    Saddamjit_Singh

    Joined:
    Dec 4, 2015
    Posts:
    22
    Getting this error in xcode
     

    Attached Files:

  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    @Saddamjit_Singh

    That error usually means that the application is using too much memory. Tracking down why that happens is not always easy. You may want to start with the Unity memory profiler. There is also an experimental memory profiler we're working on that might help as well: http://forum.unity3d.com/threads/weve-started-work-on-a-new-memory-profiler.358963/

    These tools are probably the best place to start debugging this issue.
     
    Saddamjit_Singh likes this.
  20. Saddamjit_Singh

    Saddamjit_Singh

    Joined:
    Dec 4, 2015
    Posts:
    22
    Many thanks for your reply sir.

    Sir unity memory profiler is not helping me.
    My game works well for first 3-4 minutes on iPhone and after that it starts becoming heavy slowly and slowly with every scene load. Xcode starts showing memory warnings and finally it crashes.

    My game is 2D and there are many animations and textures and 52 scenes in my project.

    I have used System.GC.Collect,Optimisation of code,marking GameObjects static,Resources.UnloadUnusedAssests,decreasing size of textures etc but still memory issue is coming.

    I have also introduced an empty scene between scene loading and used Resources.Load to load heavy textures in all scenes but still no success.

    I really need to fix this error as soon as possible sir.

    Any help sir?
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,219
    @Saddamjit_Singh

    If the Unity memory profiler does not provide any useful information, then the next step is to try the Instruments memory profiler on iOS. It may give you insight into something that the Unity profiler is missing. Outside of that, I can't offer any suggestions without more detailed information.
     
unityunity