- Home /
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 sometimes hangs 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 <device name> SpringBoard[48] <Warning>: Forcing crash report of <FBApplicationProcess: 0x18ab0050; <app name>; pid: 355> (reason: 1, description: <app bundle id> 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, specifically inside main:
int main(int argc, char* argv[])
{
@autoreleasepool
{
UnityInitTrampoline();
UnityParseCommandLine(argc, argv);
RegisterMonoModules();
NSLog(@"-> registered mono modules %p\n", &constsection);
uh oh: i added more NSLog()
s to the code snip above, and the problem distinctly no longer reproduces.
not really. the NSLog() thing i mentioned did seem stable as a fix, even if it's hideously hackish. what i actually ended up doing was inserting both an NSLog() statement and a hard sleep of 15ms or so in between each of those three statements there in main().
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);
Register$$anonymous$$ono$$anonymous$$odules();
NSLog("foobar4");
hardSleep(15);
}
oh thanks, I try your hack and the problem seems be solved.
Your answer
