iOS 9, unity sometimes hangs in main(). iOS kills process after 20s

Hi All -

we’re looking at an issue which is fairly troubling. on iOS 9.0.1 and 9.0.2, our app sometimeshangs in the very initial launch screen, and iOS terminates the process after 20 seconds. in the iOS log (captured using the excellent deviceconsole utility), the signature of a hung launch is:

  • the absence of the line → registered mono modules.

  • the eventual presence of a line like this: Oct 8 00:03:06 SpringBoard[48] : Forcing crash report of <FBApplicationProcess: 0x18ab0050; ; pid: 355> (reason: 1, description: failed to launch after 20.00s (launchIntent: foreground-interactive))

Details:

  • On some iOS 9 devices it happens in about 30% of launches, others more like 15%.

  • It never happens on iOS 8.

  • It does not happen when run directly from xcode (this makes sense because an xcode launch is not a springboard launch)

  • We’ve tried Unity 5.1.2 (our default) with XCode 6, and Unity 5.2.1 p2 with XCode 7, with the same results.

  • In a successful run, the log line → registered mono modules appears pretty much instantly.

  • It happens across a suite of 3 of our apps, all of which are build on Unity 5.1.2, but if we go back to versions build on Unity 4.6, the problem does not happen.

I’m worried the the absence of → registered mono modules indicates that the problem is extremely early in the app-launch process.

I found a work around by using thread sleep. In pseudo-code, something like this:

void hardSleep(long ms) {
   long finishTime = time_now_ms() + ms;
   while (time_now_ms() < finishTime) {
     // do nothing
   }
}
main() {
   NSLog("foobar1");
   hardSleep(15);
   UnityInitTrampoline();
   NSLog("foobar2");
   hardSleep(15);
   UnityParseCommandLine();
   NSLog("foobar3");
   hardSleep(15);
   RegisterMonoModules();
   NSLog("foobar4");
   hardSleep(15);
}

Did any one can explain how this bug happen? And how to fix this instead of above work around.

P/S: I’m currently using Unity 5.1.2 and Xcode 6.4

Does anyone have idea about that problem?