- Home /
Application Crashes On Launch - How To Fix?
Hey guys,
I've been encountering a really nasty bug for the past couple of weeks that I can't seem to get rid of. I'm building an iOS game using the unity engine and the issue only arises on a mobile device. Basically what happens is when the application enters the background for a lengthy period of time (usually 2-3 days) and the user tries to play it again, it will instantly crash on launch and will continue to do this every time the user tries to launch the game. The game will not load properly again until the user re-installs the game.
As it stands now, I have the "Behavior in Background" setting under project settings set to "suspend" and I have custom code written in my project under the OnApplicationPause() function that changes the timeScale to 0 whenever the game enters the background and back to 1 again when it re-enters the foreground.
I believe the error lies when the application fails to exit properly. In my experience, I've never encountered the bug on my personal device because I am adamant about manually closing my apps on my iPhone (ie, double tapping the home button and swiping up), however, the majority of my friends who do not manually close their applications seem to frequently encounter the issue. Furthermore, the crash log that is generated produces a "failed to exit" bug. At the moment, I do not have any custom code written that handles the exiting sequence when the application is not manually closed.
I've tested this theory out on some other unity tutorials on the iPhone, and they all seem to encounter this same issue. For example, the space shooter iPhone tutorial on Unity's website (https://unity3d.com/learn/tutorials/projects/space-shooter-tutorial) produces the same error after the application is left in the background for a prolonged period of time and will instantly crash on launch until the application is reinstalled.
I'm not 100% sure that the exiting sequence is causing the issue, however. I'm relatively new to gamedev so I could be missing something obvious due to inexperience.
Has anyone else encountered this issue before? If so how did you fix it? Any help is greatly appreciated :)
crash log and OnApplicationPause: http://imgur.com/a/nAhNU