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. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    Thank you for the update, good to know we aren't all crazy ;)

    Keep us posted!
     
    Regone likes this.
  2. unclebob301

    unclebob301

    Joined:
    Jan 29, 2014
    Posts:
    20
    No probs deverolic

    just finished testing and for us the initial crashes were code related. In the Xcode 10.1 memory report we could watch as each asset loaded and destroyed but the memory footprint kept growing until the inevitable crash around the 800meg mark.

    A couple of Resources.UnloadUsusedAssets(); later and memory requirements stayed within 130 to 180meg and obviously no memory related crashes (iphone 5s).

    Typically we are throwing around 4k and 8k image files so managing memory for IOS has always been more of a challenge than say with Android, windows etc.

    So now we know our code works fine and is well within IOS's needs we will be trying on IOS devices with the latest IOS builds later this afternoon when one becomes available.

    Will keep the thread posted.

    Cheers
     
    Xander-Davis likes this.
  3. unclebob301

    unclebob301

    Joined:
    Jan 29, 2014
    Posts:
    20
    Ok just pushed a build to a ios 12 device.

    Same app, same code base. Xcode 10.1 Unity 2018.2.20f1 64bit

    No crashes guys. However.

    Memory use is now reported to be between 205 and 265meg for the same code and assets. This is up from the reported value of 130 to 180meg on Xcode 9.4.1

    I don't know about your apps but IOS is closing/crashing our apps based on them hitting a memory threshold of 800meg - which seems the start of the red zone in Xcode memory reporter. Perhaps in Xcode 9 and earlier apps have been reported to be well below that limit but now given the extra accuracy of IOS12 those apps appear to be a third bigger and thus trigger the crash even though they would run with no problem. So by keeping your apps memory footprint below 800meg (say 750) then this could be a short term and quick solution.

    The strategy we use is simple. We instantiate the game object(s) with the largest memory footprints and Destroy them with a Resources.UnloadUsusedAssets(); at the earliest non upset the user experience point.

    If we encounter any other issues we'll post here.

    Hope that helps someone and thank you again for the heads up.

    Needs to be sorted before the forced IOS12 requirement though but not sure its a Unity issue but they would be the ones to draw it to Apples attention as they have clout whilst small devs simply do not.

    Cheers
    UB
     
    protopop and Regone like this.
  4. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    I'm having the same issue.... 2x more memory usage on an iPhone7 with iOS 12 vs an iPhone 6s running iOS 11....
    Causing crashes on iPhone 5s and 6.
     
  5. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    Hello guys, I am from 20 years into the future and I can confirm that this issue hasn't been fixed still. @derkoi when will you update your game? It's been 20 years without an update.
     
  6. Regone

    Regone

    Joined:
    Aug 1, 2014
    Posts:
    35
    Classic Jaynesh.
    ¯\_(ツ)_/¯
     
    Xander-Davis likes this.
  7. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    If you're really 20 years from the future you'll know I switched to another game engine and lived happily ever after. lol
     
    Regone and Jaynesh like this.
  8. victor_sq

    victor_sq

    Joined:
    Feb 19, 2016
    Posts:
    36
    same issue, my game hit memory limit ceiling on iPhone 5s. Memory consumption doubled compare to previous versions of xcode (also inapp stop working). I can't update game for few months already, I have to admit such kind of issue is real disaster
     
  9. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Unity 2019: New Feature: We've sorta made garbage collection not neccessarily faster

    Also Unity 2019: New Feature: For one of our core supported platforms with a hardware install base worldwide somewhere around 600 million units dwarfing all consoles combined, now you have to use 128x128 wall textures like you're making a game for N64 in 1996 or your game crashes

     
  10. johnfrog

    johnfrog

    Joined:
    May 7, 2015
    Posts:
    13
    Yeh, this is becoming a joke now.

    Let's be real - I assume Unity has a designated team set for their iOS integration so they won't push back on other features for their roadmap - I get that - it's a big company and love seeing new features.

    But are the Unity iOS engineers even looking at this at all? I sincerely hope this is a top priority item for that team.
    If it's not - it bloody well needs to be.

    And I don't want a response, "oh send us a project to reproduce" - the evidence is plastered over this thread.

    Paying for 4 pro licenses and can't even release the damn app. Jesus Christ.
     
  11. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Well said.
     
  12. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    From experience at triple-A studios, this should have been a Unity HQ all-hands-on-deck four-alarm fire "you're sleeping under your desk until this is fixed" thing to resolve it in a week instead of... over half a year and still breaking games worldwide.

    But, nah.
     
    johnfrog likes this.
  13. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    But what I don't understand is that surely there is some studio with actual clout that is affected by this bug. I imagine a lot of higher-budget Unity games maximize their textures to use every bit of memory. Are there no big players complaining about this bug? iOS is such a crucial target.
     
    Xander-Davis likes this.
  14. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Yeah I was wondering this too.
     
  15. Jaynesh

    Jaynesh

    Joined:
    Feb 28, 2015
    Posts:
    36
    Big studios are probably reporting this through different channels. We peasants have to just wait here on the side while they stall this issue by asking for more repros.
     
    derkoi and Regone like this.
  16. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    Well there is only 3 weeks left before every iOS developer has to use High Sierra and Xcode 10.1 if they want to release of update an iOS game. Additionally, the newer Xcode 10.2 only works on MacOS Mojave so system requirements are moving fast (does unity 5.6 work on Mojave for example). I have a feeling once people start uploading apps to the App Store after March 1st and get an error message requiring the switch that we’ll see more movement on this problem.
     
    fakegood, Xander-Davis and derkoi like this.
  17. unity_HQu8vgLmevyXig

    unity_HQu8vgLmevyXig

    Joined:
    Oct 3, 2017
    Posts:
    1
    I tried about everything I can do. I guess literally all I can do is just wait....
     
  18. jtokash

    jtokash

    Joined:
    Sep 1, 2013
    Posts:
    23
    Has anyone checked to see if the XCode 10.2 beta resolves the memory issues? Not sure if 10.2 will be final before March, but it might be a good data point. I have not tried 10.2, yet, personally.
     
    Xander-Davis likes this.
  19. victor_sq

    victor_sq

    Joined:
    Feb 19, 2016
    Posts:
    36
    I removed admob and firebase that give me this piece of memory to stop crashes on 1gb devices, I guess all we can do so far is squeeze our projects in memory consumption and wait... very unfortunate
     
  20. Duobix

    Duobix

    Joined:
    Dec 6, 2014
    Posts:
    52
    The problem is, that they'd need to change something in the iOS API to resolve this issue - which is only doable from Apples side(if the fix could come out of apple first here-but I'd highly doubt that).I actually was able to use API 12.1 files inside xcode 9.x, but the memory problem was still there. So the question persists-has there been a newer iOS Api than 12.1 in Xcode 10.2?
     
  21. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    @martonekler, It has almost been a month since your last message. Any update on this issue?
     
  22. joe_moulton

    joe_moulton

    Joined:
    Jun 22, 2018
    Posts:
    1
    I am late to the party, having just updated to iOS 12 on on of my dev devices today in order to use Metal Indirect Command Buffers and, of course, have just encountered what everyone here has been tearing their hair out over for the last few months.

    I develop with Metal and OpenGL ES directly more than through Unity and have confirmed that memory behaves appropriately up until the first draw call is made (e.g. at minimum clearing and presenting the drawable/renderbuffer) at which point memory usage roughly triples as many here have indicated. Unfortunately, I also updated to XCode 10.2 beta and iOS 12.2 beta and the issue persists. Apple has done nothing to prioritize this fix and while it may be on the Unity team's radar and I'm sure it has been communicated to Apple it would be nice to have someone from Apple chime in and at least say they are aware of and working on this. This is such a blunder it is a little surprising it hasn't made its way into the news.
     
  23. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    So it really must be a problem on Apple's side. because it sounds like there's no memory issue until you start using the ios12.1 sdk.

    I'm on Unity 5.6 and MacOs Sierra so there's a lot to prepare.

    Ive already started testing my project in 5.6.6 and 2017 - both of which are minimum needed to use unity in MacOs High Sierra. And i have to update my macos too, which can break some pipelines. And if there is no fix in xcode 10.1 but a fix comes later, that means we have to upgrade to Mojave for xcode 10.2+ support. It just feels a bit fast when i already have a wonderfully working project all the way back to ipadmini 2 right now.
     
    yanivng likes this.
  24. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    . @martonekler asked if I would send an iOS Xcode built project from Unity of my game VAST to help them debug, and I realized this is a little more secure than sending the actual full Unity Project itself. I have agreed to this-- Unity engineers have it now and will also share it with Apple engineers. VAST and the Xcode project sent yesterday 2/14 was from Unity 2018.3.5f1. Our development environment is macOS Mojave 10.14.3 and we were using Xcode 10.1. VAST experienced this issue on both tvOS and iOS beginning around Fall 2018. By December 2018 - January 2019, we got around this by crushing textures and lightmap settings all the way down.

    Back in Summer 2017, we originally developed the game on Apple TV 4 (2015), and it ran there with our textures at high resolutions, environment art surface textures in particular at 4K across all channels in the Standard Shader, nearly two years ago.

    Hopefully this helps us all get this issue resolved, and I thank Marton for reaching out to us with the idea of submitting an Xcode project only instead of the full Unity project. I would encourage you to reach out to Marton to do the same.

    Happy Valentine's Day from Astrogun. ❤️
     
    Last edited: Feb 15, 2019
    Regone, gecko, protopop and 1 other person like this.
  25. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    It’s really great that you did this. And sending a build instead of a project seems like a great idea all around. I could never send my 26gb project file anywhere. But a 1gb build file is more manageable.

    I checked out your blog post too about this - you have really been in top of things. Titanium Moth Bug is a great name to get behind - is anyone else using? It’s the first time I heard it but I will use it going forward, because this is one the biggest challenges facing iOS devs in a long time and we see it coming.

    Btw I think it’s a good idea to have separate iOS and tvOS versions. I can’t remember but I read an article that warned against having a universal build because how the two would be linked. So if your tvOS version ever had to be removed you’d have to remove the iOS version too. I love the iOS ecosystem, but I think that iOS development is not as straightforward as it was a few years ago.
     
    Xander-Davis likes this.
  26. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    Btw is it ok for us to refer to this issue as the titanium moth bug in Twitter etc? Or so you prefer us not to?
     
    Xander-Davis likes this.
  27. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    This is ok! Thanks for asking :)
     
  28. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441


    ^^^ Well I maybe turned this lemon into positive marketing asset lemonade like any good indie developer should. #hustle

    I think we're all close to a solution here, fam. I can feel it.

    :)
     
    Last edited: Feb 16, 2019
    johnfrog, Regone, yanivng and 6 others like this.
  29. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,561
    I have to say i am absolutely amazed you put this together so fast and so professionally. Your marketing skills are really impressive. For me, the most difficult part of os development over the years has been keeping up with the Unity + MacOS + Xcode upgrade combo, and i think this helps the community a lot.
     
    Regone and Xander-Davis like this.
  30. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Time is running out.....
     
  31. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Yes indeed... I've been informed last week that Unity's engineers were able to verify the memory crash-out with the submitted iOS Xcode project of VAST (I had intentionally set the textures to their original 4K asset setting which worked before the bug for them to repro) and have now forwarded it on to Apple's engineers.

    Has anyone else submitted their Xcode projects to help them with repro cases recently?
     
  32. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Well that's reassuring. Hopefully something will be done about it soon then. I'm surprised there's not more people posting here though, perhaps it's something specific to us that's happening?
     
  33. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,799
    In our case, we have seen about 50-60mb more ram than what we'd expect (kinda consistent with @unclebob301 's findings), which while less than ideal, does not really affect our game that much.
     
  34. jtokash

    jtokash

    Joined:
    Sep 1, 2013
    Posts:
    23
    I've been following this thread since the early days. XCode 9.4.1 was great as a stopgap, but now that March is upon us, I'm trying to get our game to run with XCode 10.1/iOS 12/iPhone 6 Plus. What is the best way to pinpoint (in Instruments in Unity, or elsewhere) the memory cost of each individual texture and see the impact of the XCode 10.1 / iOS 12 changes at the texture by texture level? Are RenderTextures affected or just textures we load?

    Thanks!
     
    Last edited: Mar 1, 2019
  35. ScottF

    ScottF

    Vice President, Platforms

    Joined:
    Jul 31, 2013
    Posts:
    96
    Hello Community,


    I wanted to share that Apple has released an article where you can read more about the changes in iOS 12 which many of you have observed here: https://developer.apple.com/documentation/metal/reducing_the_memory_footprint_of_metal_apps


    I will reiterate what I said back in October (clarification in italics).


    "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 behavior is only observed when the application is built targeting iOS12 and does not apply to existing applications which were built to target iOS11. You will only observe these changes after you upgrade your app with XCode 10.


    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. "


    For the vast majority of developers what will be observed will be XCode tooling reporting higher memory usage. For a subset of users you may experience your application being terminated for high memory usage which is explained in more detail in the Apple article. This issue is not Unity specific but rather a memory policy on the iOS platform.


    If you are experiencing app termination you will need to reduce your memory footprint. As this issue has been answered I am freezing this thread. We can answer additional questions you may have on techniques to reduce memory on a fresh thread. The Unity R&D team will continue to invest in optimizations and best practices to ensure your games have as much space as the platform will allow.
     
    TroyDraws and fredyang17 like this.
Thread Status:
Not open for further replies.