Having a real beast of an issue with my game. It works 99% of the time (like, seriously, I can play for hours and hours with no issues). Yet on a handful of occasions I've had a weird error pop up, it's happened on both my platforms (Android and iOS), so it does not appear to be platform specific.
The Game StructureOur game has 6 scenes that are loaded and unloaded in a semi-random order. When transitioning between a transition screen covers the game (this is a persistent GameObject with a DontDestroyOnLoad). This transition destroys all the elements of the previous scene, then calls the following inside a Coroutine:
AsyncOperation asyncunload = Resources.UnloadUnusedAssets()
yield return asyncunload;
async = Application.LoadLevelAsync(nextId);
Once that async is done, the transition hides itself and the next scene is played.
The ProblemVery rarely (as mentioned, has happened maybe 8 or 9 times out of hundreds and hundreds of scene transitions), the transition animation will slow to a crawl. The transition normally takes 2-3 seconds, but once the bug hits it will take 10-20 seconds. Once the transition is done the game seems to play perfectly fine (crazy, right?), but when the next transition comes up the slowness will return.
Memory ChecksI added a TON of debug code to try and isolate the issue. This has revealed the following:
-We haven't been able to pin down the problem as associated with any particular one of our scenes, although it may be.
-There appears to be a weird memory leak. When the game is working normally, right after the UnloadUnusedAssets() we get a
System Memory in Use: 3.0mb -- again it will show right around 3mb every time after every game for hundreds of plays.
When the game starts messing up, this System Memory in Use goes up! e.g.
System Memory in Use: 17.0mb or higher. In other words, it sure looks like memory is not being cleared. Sometimes it will fall back down to 3.0 after the bad transition, other times it will stay at this high level through more transitions.
The really bad part is when it sticks like that, because the game appears to be totally broken (20 second transitions every time), and the only way to fix it is to force quit the app (something many Android and iOS users have no idea how to do).
That's about all the information I have so far, any advice on what this might be or ideas on how to isolate the issue would be immensely helpful. We were hoping to launch this week