Search Unity

iOS 12 large memory usage

Discussion in 'iOS and tvOS' started by johnfrog, Sep 20, 2018.

Thread Status:
Not open for further replies.
  1. johnfrog

    johnfrog

    Joined:
    May 7, 2015
    Posts:
    13
    Hi guys,

    Apple released ios 12 last week and all of a sudden, Unity's memory usage is nearly double. I remember seeing an issue opened for this a while back but can't find it any more.

    Anybody know what's going on?

    Cheers.
     
  2. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
  3. johnfrog

    johnfrog

    Joined:
    May 7, 2015
    Posts:
    13
    Thanks Paulius! That links broken for me though

    Cheers
     
  4. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    sorry about that, it should work now.
     
  5. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    @_Paulius Is there any temp fix, we are trying to soft launch but any device on iOS 12 crashes. We are on 2017.4.2f2
     
  6. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    Is there any update on this?
     
  7. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    @_Paulius one more time, is there any update on this, or a temporary workaround?
     
  8. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    I'm also seeing this with Unity 5.6.5p4 and Unity 2018.2.11f1, it seems.

    With an empty project:
    • iPhone 6+ on iOS11: 24MB
    • iPhone 6+ on iOS12: 75MB
    It's a little unclear from the discussion above and the issue tracker description: is this simply a problem where the number in Xcode is reported incorrectly, or is the app actually allocated more memory? The former case is only annoying, while the latter can increase memory pressure and lead to crashes.
     
  9. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Today, I built my game for stand alone and it used half as much memory as iOS. And that with the textures almost four times the size as iOS.
     
  10. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    I just got a response from the QA team about the memory issue
    "The bug has been verified, but we have prioritized critical bugs that are preventing shipping of titles for our next patch."
    So it seems that this issue isn't important enough yet which is sad because the unity engine has now been set back by at least 8-10 years due to the HUGE memory limitations.
     
    johnfrog likes this.
  11. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    The app is actually allocated more memory. My game on iPhone 4s was using around 200-300mb memory. However it is now crashing on iPhone X (iOS12) because it is going well over 2gb in memory.
     
  12. _Paulius

    _Paulius

    Mobile Developer Unity Technologies

    Joined:
    Jul 8, 2014
    Posts:
    173
    @Jaynesh Whom did you get this is response from? This is definitely not true, as I've mentioned in the other thread we have prioritised this issue and are working directly with Apple to find a solution.

    But I do understand that it's really unacceptable that we're taking this long and that it's something we should had addressed while iOS 12 was still in beta. We'll look into our QA and high priority issue escalation processes to figure out why and how did this happen. And hopefully a situation like this will not repeat itself in the future.
     
  13. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    727
    I’ll be looking forward to an update
     
  14. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    I don't want to call out who said that as I don't want her to get into any trouble. I appreciate that you are looking into this. Unity have known about this issue since the beta so surely they have heard something from Apple regarding this? or have some idea of what is going on. I refuse to believe that there has been zero information regarding this since the problem was discovered and today.
     
  15. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    727
    Last edited: Oct 15, 2018
    johnfrog likes this.
  16. johnfrog

    johnfrog

    Joined:
    May 7, 2015
    Posts:
    13
    I don't think it's exclusive to Unity apps. We tried this with an old non-unity app and the memory usage was much higher for iOS 12. More than double.
     
  17. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    727
  18. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    Hi All,


    We have been discussing this issue with Apple. On iOS 12 and Xcode 10 Apple's memory reporting tools has been updated to more accurately track memory footprint now then prior versions. In other words it’s not that your application is consuming more memory, but rather that it previously was under reported.


    This is especially true for games using Metal, as most of the allocations have been happening in kernel space which hasn’t been previously accounted for app’s memory footprint.


    That being said if people are experiencing actual crashes due to out of memory (this can be confirmed in the device system log) that is now happening on iOS 12 and not on iOS 11 please report a bug with a repro attached and post the case ID back here or private message me. We will forward these cases onto Apple to help investigate.
     
    Last edited: Oct 18, 2018
    skullthug, User340, johnfrog and 2 others like this.
  19. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    @ScottF, thanks for the info!

    One question that comes to mind: what is the minimum memory overhead that can be achieved with a completely empty Unity project? My test on iOS 12 showed 75MB - are there certain project settings or other considerations I should take into account that could drive that number lower? I'm working on a fairly memory-intensive game, so one of my goals is to reduce the "baseline" overhead of the Unity engine itself as much as possible. I see a manual page about reducing the built player size, but not one specifically about reducing memory overhead of the engine.

    It's also unclear whether this change affects how the OS decides to kill apps. Before iOS 12, if the OS used an under-reported number to decide whether to kill an app, it would effectively mean that your app could use more memory before being killed. If iOS 12 now uses a more accurate number for this, it may ultimately be a good thing, but it would still mean that an app can't use as much memory as it used to and avoid being killed.
     
  20. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    I will have more info to follow but my advise as of right now is to please upgrade your device to iOS 12 Beta 4 or later and re-test your application. As previously communicated the tools will now report more memory then previous iOS versions (expected) but the memory cieling issues should be improved. I will update the post as I have more info.

    @kromenak are you looking for general advice on how to minimize memory footprint, or specifically due to the iOS 12 behavior you may have experienced?
     
  21. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    727
    Did you mean 12.1 beta?
     
  22. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    Yes
     
  23. BetterGamesStudio

    BetterGamesStudio

    Joined:
    Jun 21, 2017
    Posts:
    5
    @johnfrog @ScottF @_Paulius
    Hi Guys, Is this also a memory issue??? I am posting threads below. Since IOS 12 released this thread is causing my games to crash on iOS 12 devices. Games are working fine on iOS 11. I searched a lot but didn't find any temp fix for this issue

    Thread 11 IOS: 12.0.1 (16A404) Devices: iPhone 5s (Model A1453, A1533, iPhone 6)
    #0 (null) in 0 ()
    #1 0x00000001010e1670 in JobQueue::Exec(JobInfo*, long long, int) ()
    #2 0x00000001010e15dc in JobQueue::Steal(JobGroup*, JobInfo*, long long, int, bool) ()
    #3 0x00000001010e19a0 in JobQueue::ExecuteJobFromQueue() ()
    #4 0x00000001010e1a44 in JobQueue::processJobs(void*) ()
    #5 0x00000001010e10e0 in JobQueue::WorkLoop(void*) ()
    #6 0x000000010114c47c in Thread::RunThreadWrapper(void*) ()
    #7 (null) in _pthread_body ()
    #9 (null) in thread_start ()

    Thread 13 IOS: 12.1 (16B5077c) Devices: iPhone 5s (Model A1457, A1518, A1528, A1530)
    #0 (null) in 0 ()
    #1 0x0000000100de9670 in JobQueue::Exec(JobInfo*, long long, int) ()
    #2 0x0000000100de95dc in JobQueue::Steal(JobGroup*, JobInfo*, long long, int, bool) ()
    #3 0x0000000100de99a0 in JobQueue::ExecuteJobFromQueue() ()
    #4 0x0000000100de9a44 in JobQueue::processJobs(void*) ()
    #5 0x0000000100de90e0 in JobQueue::WorkLoop(void*) ()
    #6 0x0000000100e5447c in Thread::RunThreadWrapper(void*) ()
    #7 (null) in _pthread_body ()
    #9 (null) in thread_start ()
     
  24. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    We're also experiencing crashes with Unity 2018.2.5f1 on iOS 12, due to memory...
    It didn't happen with Unity 2017.1.4
     
  25. Duobix

    Duobix

    Joined:
    Dec 6, 2014
    Posts:
    52
    Are you sure that the issue can be isolated to Unity update?
    Are you building your game using Xcode 9 or Xcode 10?
    Builds made with Xcode 9 seem to have less of a memory impact somehow
    (at least in the case I've had to cover pretty recently).
     
  26. BetterGamesStudio

    BetterGamesStudio

    Joined:
    Jun 21, 2017
    Posts:
    5
    @tomerpeledNG the threads i posted above are they also related to memory??? Because i am unable to understand it
     
  27. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    @Duobix Well you might be right. We just update both Unity (to Unity 2018.2.5f.1) and Xcode( to XCode 10 from XCode 9).
    So do you think that going back to XCode 9 might solve our issue? Currently is crashes our game on Devices such IPhone 6 with iOS 12.

    @BetterGamesStudio The stacktrace you've added are regular Thread stacktrace I believe...
     
  28. twinsen3d

    twinsen3d

    Joined:
    Jan 31, 2013
    Posts:
    1
  29. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    Hi,

    As @Duobix mentioned, we downgrade our XCode from 10 to 9.2 and now everything is back to normal - no crashes on our game!!!!

    So, where is the problem? Unity or iOS?
     
  30. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    @ScottF, regarding your earlier question, general advice on lowering the "baseline" Unity memory usage would be useful, regardless of the iOS 12 issue. I'm not sure if such a resource/documentation/tutorial exists somewhere and I haven't seen it. Or maybe the engine just uses a certain amount of memory (even after enabling engine code stripping, for example) and there's not much to be done about it.
     
  31. aramt

    aramt

    Joined:
    Dec 7, 2012
    Posts:
    1
    iOS12 will crash when using memory beyond 650MB.
    650MBiOS12.png
    This problem occurs on devices with less than 1GB of RAM in the iOS12.
     
    Last edited: Oct 23, 2018
  32. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    Update:

    We have confirmed on our side that applications now behave consistently (when testing with iOS 12 Beta 4 & Beta 5) vs iOS 11 and older in respect to how much memory is consumed. Please note that the OOM issues was only happening on a sub-set of iOS devices such as the IPhone X but not the IPhone XS.

    As mentioned earlier you WILL see higher memory usage on iOS 12 vs 11 but this is expected and should be welcome news as the memory profiler tools are now more accurate.

    There is nothing we at Unity can do to make this situation better for iOS 12.0, iOS 12.1 will have to roll out before any issues impacting shipped titles will be improved.

    There is no regression in Unity. The memory footprint Unity and your game uses between different versions is always going to have small fluctuations. It is entirely possible your game is right near a memory limit and these small fluctations put you over. Please try on iOS 12.1 Beta as this has significantly increases the memory cieling on certain devices.
     
    Deleted User and Cromfeli like this.
  33. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,755
    Maybe this has nothing to do with this thread, but I noticed that setting memoryless MSAA for RenderTextures does not work any more.

    I'm not sure if it's a Unity regression or an iOS 12 bug (I only noticed it now and last time I checked for it was a couple of months ago), but it made my main RenderTexture claim an additional 45mb of memory when AA is on.
     
  34. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    iOS12.1 is out. I suggest all who have memory issues to upgrade and retry. Please report back with the results...
     
  35. okluskyond

    okluskyond

    Joined:
    Dec 6, 2017
    Posts:
    38
    Hi, iOS 12.1 out. Using Unity 2018.2.5f1 and xCode 10.1 problem still present.

    In compare to iOS 12, Unity 2018.2.5.f1 and xCode 9.4 we are heavily memory limited. This is killer situation for us.

    Btw. Memory ceiling was not improved at all xCode 10 and xCode 10.1 version is still 1400MB on iOS 12 and iOS12.1 on iPad9.7
     
  36. clipo

    clipo

    Joined:
    May 2, 2018
    Posts:
    2
    Same here
     
  37. rwblodgett

    rwblodgett

    Joined:
    Apr 4, 2017
    Posts:
    67
    So, I have run our app with extremely different results between iOS 11.x and iOS 12.x.

    On an iPhone 8 with iOS 12.0.1 and 12.1, the app crashes and burns when memory allocations get to around 700MB. This is with nothing else running on the device.

    On an iPhone 7 with iOS 11.4.1, the app doesn't crash and I can allocate 1200-1300 MB worth of stuff. It does crash North or 1300 MB.

    So, in my opinion, the same app, built with Unity 2017.3.1, appears to have a very different memory life cycle in iOS 12 vs iOS 11. This cannot just be attributed to small fluctuations of memory allocations. This is significantly different. I don't know if this is Apple or Unity's fault.
     
    Last edited: Nov 2, 2018
    joshuacwilde likes this.
  38. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    This memory issue seriously needs to be looked into by Unity. The mobile gaming industry has been set back by a few years because of this.
     
    Xander-Davis and yanivng like this.
  39. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    Would you be able to share your project with us so we can review the memory usage with Unity and Apple engineers? Please PM me so we can investigate further.

    Thanks,
    Scott
     
  40. Sannyasi

    Sannyasi

    Joined:
    Nov 20, 2012
    Posts:
    36
    I'm also running into the same issue.
    This will put a stop to the planned deployment of my app until fixed. So have we had any word?

    I want to say the upgrade to 12.1, and subsequent upgrade to xcode 10.1 may have made matters even worse.
    I notice about twice the memory consumption reported in xcode on iOS 12 vs 11, even with the same version of xcode and xcode project. Crashes are regular (even in different segments of code) with 1400mb limit warning.

    And yet works flawlessly on iOS 11 (all other factors being identical).

    Unity: 2018.2.13f1
    iOS : 11, 12.01, 12.1
    Xcode: 10, 10.1
     
  41. rwblodgett

    rwblodgett

    Joined:
    Apr 4, 2017
    Posts:
    67
    Hi Scott, I did send you a reproducible project. See case # 1100123.
     
    Peter77 likes this.
  42. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    I am also having memory issues. My game VAST which shipped on tvOS December 2017 and could run on Apple TV 4 and Apple TV 4K now crashes on both when trying to load the first level (the only level shipped so far and which remains untouched since a minor update in early 2018 that worked). Customers are now e-mailing our support about this as no one on the tvOS platform can play this now.

    We've actually been confronting this issue for months while working on an art rebuild of the first level (until now, we thought it was just the new level but now not even the old shipped version runs directly from the App Store) and there doesn't seem to be any work around other than deleting lightmaps and stripping out half of the assets from the level systematically until it loads again. I did have some success putting the assets back in, group by group... but didn't get a chance to try rebaking lightmaps then. So in other words, this doesn't make a lot of sense. Also, we can load in our Sandbox testing levels fine-- but full levels are (only now) too much apparently?

    It throws this error:
    UnityGfxDeviceWorker (33): EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=2048 MB, unused=0x0)

    Even more puzzling, Xcode says there's memory to spare:


    Below is another thread I've found with the same bug. One solution I saw was to turn off Metal, which we can't do. We designed the game to use Metal to push the Apple TV to its limit. Clearly we might be! It's either that or they say using an older version of Xcode might work, but that sounds like it could lead to more problems, especially by now.

    https://forum.unity.com/threads/ios..._type_memory-limit-2048-mb-unused-0x0.541145/

    Not sure if this is directly the same bug or what, so I thought I'd post in this thread. I saw a lot of mentions of iOS so this might be the first mention of tvOS.

    Anyone have any ideas?

    ~

    Before you ask, I cannot send the project for legal reasons. Sorry-- wish I could if it would help.

    I also posted about it on our site to let our customers know we're aware and trying to figure it out (hopefully with Unity) as soon as possible: https://www.astrogun.com/2018/11/26/vast-bug-level-loading-unity-memory-issue/

    I've also filed an official bug report with Unity about this happening on tvOS. Got the confirmation. Case 1104251.

    In the meantime, here and for others, any help is MUCH appreciated! This has ground our game production and deployment on tvOS to a halt.
     
    Last edited: Nov 29, 2018
    GlennSnyder and joshuacwilde like this.
  43. GlennSnyder

    GlennSnyder

    Joined:
    Jan 24, 2018
    Posts:
    5
    This is happening for our iOS->ARKit app as well.

    iPhone X w 11.4.1 gets to 1.36 gb of memory usage and operates well within that limit
    iPhone X w 12.0 hits the 1400mb limit and the app crashes.

    Throughout the assetbundle load process the iOS 12 equipped device is always using 180%+ of the memory usage of the iOS 11 device until the iOS 12 device crashes.

    This is holding up our new feature release for a major auto manufacturer that was hoping to debut this week at the LA AutoShow.
     
    Xander-Davis likes this.
  44. GlennSnyder

    GlennSnyder

    Joined:
    Jan 24, 2018
    Posts:
    5
    Is there anyway we can bump this priority or open a new ticket. It seems that this should be of the highest priority as the apps simply cannot run currently. This isn't something like a special race condition or a small portion of apps. Anything using 300+mb of ram for UI + assets cannot run on ARKit with iOS 12 currently as you hit the memory limit on the iPhoneX and the like immediately. Our app has been running fine for a year on iOS 11 and is now useless on any device other than the iPad Pro if they have upgraded to iOS12.
     
  45. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Not sure what we're supposed to do in the meantime?
     
  46. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Managed to get my game running a little further by disabling Metal.
     
    Xander-Davis likes this.
  47. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    727
    This is true. You will also get better memory performance if you can combine any meshes together. From my profiling, the meshes are the major cause of memory problems. I ended up writing my own renderer in Metal for my mobile game that is much more memory efficient. Obviously that is not a general solution though...
     
  48. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Update: I just tried it without Metal enabled and it made no difference for us.

    Also, with Metal on for tvOS with our project, Unity fails to build if the build target is set to 12.0. It had worked if it's set to 11.0. With Metal off, the project would successfully build to either 11.0 or 12.0 but experiences the same crash on level load. When set to 12.0 with Metal, the build fails throwing alerts to the Console that compressed textures cannot be used with tvOS... which is insane. This is after using Unity Hub to open the project and change the opening build target from Windows to tvOS (I had switched to work on this on Windows until this iOS / tvOS Unity memory bug is resolved). I am suspicious this 'Advanced Open' process failed to do the one thing it said it would do, so with the project open, I have now switched to Windows and am now switching it back to tvOS, triggering a total reimport of all assets. I should be able to either verify or clear this paragraph when this is done, maybe in 12 hours...

    Not great.
     
    Last edited: Dec 6, 2018
  49. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    I feel your pain with the waiting game. I have a Cache Server PC setup and although the initial switch is around 6-7 hours, switches after that are 20 mins.
     
    Xander-Davis likes this.
  50. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Update: This morning I tried it on tvOS 12.0 with Metal and it didn't work either, same memory bug. So I get the same memory crash whether Metal is enabled or disabled on tvOS 11.0 or 12.0. (To test, I'm using a fully-built level I had successfully shipped on tvOS in December 2017)

    And of course, it all works in the Editor. No console errors. It also works on a Windows build.
     
    Last edited: Dec 6, 2018
Thread Status:
Not open for further replies.