Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Game is incredibly unstable and prone to crashing on iOS after upgrading to Unity 4.2

Discussion in 'Editor & General Support' started by MightyRabbit, Jul 30, 2013.

  1. MightyRabbit

    MightyRabbit

    Joined:
    Aug 8, 2012
    Posts:
    27
    Hi guys,

    I don't see any similar topics on this and I'm really at a loss for why this is happening. We updated to Unity 4.2 last week and after we upgraded, our game began getting tons of applicationDidRecieveMemoryWarning() errors in xCode that eventually lead to a crash. We downgraded the project back to 4.1 and all the memory warnings do not occur, the game does not crash.

    What this means is that Unity 4.2 is the root of the memory warnings we are receiving - does anyone know why we might have this problem? We'd really like to upgrade to 4.2 so we can build to Blackberry and Windows Phone, but we can't do that if it is going to cause our iOS version to be unstable.

    Thanks in advance for any help!
     
  2. caseyc

    caseyc

    Joined:
    Jul 2, 2012
    Posts:
    15
    I was having the same problem with our game after upgrading the project to unity 4.2. After looking at unity's memory profiler as well as xcode's and testing things, it seems like the problem is with memory allocated to RenderTextures not getting properly freed (even when using RenderTexture.GetTemporary/RenderTexture.ReleaseTemporary).

    In unity's memory profiler, it reports what the render texture memory and render texture count should be, but when you look at xcode's memory profiler you can see the available physical memory does not seem to increase much when render textures are destroyed or released, which is contrary to how it works in 4.1.

    Loading a new scene doesn't clear the memory. I've tried Destroy( rendertexture ), RenderTexture.Release, and RenderTexture.DiscardContents, but none of them seem to get rid of it either.

    Is anyone else having this issue? If someone else has RenderTextures that are clearing properly on iOS it would go a long way to helping solve the problem.

    Thank you
     
  3. MightyRabbit

    MightyRabbit

    Joined:
    Aug 8, 2012
    Posts:
    27
    As far as I know, we don't even have render textures in our game, so the issue is something else entirely for us - it definitely sounds like a similar issue to what we're seeing, though.
     
  4. MightyRabbit

    MightyRabbit

    Joined:
    Aug 8, 2012
    Posts:
    27
    So I thought this issue might have been caused by deferred lighting being enabled, but that isn't the case. What happens is as I play the game I get more and more memory warnings as time goes on. The "real memory" never seems to go above 300MB, which is normal; however, virtual memory constantly grows as the app is active. Is that normal?

    I attached a screenshot of instruments right before it crashed.

    If anyone can help me figure out what is going on here or at least point me to a place where I can find the culprit, that would be much appreciated.

    Once again, this exact same project when built out with 4.1 gets no memory warnings and does not crash. When it is built out with 4.2 it crashes all the time, inexplicably, and gets memory warnings like crazy. The screenshot above was taken while the game was being played on an iPod Touch 5.
     

    Attached Files:

    Last edited: Aug 5, 2013
  5. MightyRabbit

    MightyRabbit

    Joined:
    Aug 8, 2012
    Posts:
    27
    Turns out we do have RenderTextures, just none that are deliberate. Has anyone figured out if these are definitively the cause of memory problems with Unity 4.2 on iOS? If so, how can we fix this?
     
  6. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    I have had similar issues back then when I upgraded my project to Unity 4.0, and today, attempting to upgrade a different project to 4.2, I am having similar issues.

    The game works perfectly in the editor, and sometimes even in the simulator, but crashes at random positions on the device.

    I have outlined my experience in this unity answer, and I am really pissed off at Unity for not attending to this problem. There is clearly something wrong with Unity 4.x on iOS.

    Again I am stuck in limbo, on one hand forced to work with an older Unity version, and as time goes by, this becomes harder and harder, as plugins drop support, and now with iOS 7 and changes to uniqueIdentifier, not upgrading Unity means I need to deal with a growing number of issues.

    Anyone from Unity care to jump in?
     
  7. DannyB

    DannyB

    Joined:
    Jun 20, 2012
    Posts:
    214
    For the benefit of anyone else still having problems, my crash was related to the use of deviceUniqueIdentifier, as discussed in this thread (including a way to manually fix it for Unity 4.2.0)

    Unity 4.2.1 now seems to fix it.