Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

Discussion in 'iOS and tvOS' started by HuuPC, Nov 5, 2015.

  1. HuuPC

    HuuPC

    Joined:
    Sep 9, 2015
    Posts:
    7
    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 <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.

    I found a work around by using thread sleep. In pseudo-code, something like this:
    Code (Objective C):
    1. void hardSleep(long ms) {
    2.    long finishTime = time_now_ms() + ms;
    3.    while (time_now_ms() < finishTime) {
    4.      // do nothing
    5.    }
    6. }
    7. main() {
    8.    NSLog("foobar1");
    9.    hardSleep(15);
    10.    UnityInitTrampoline();
    11.    NSLog("foobar2");
    12.    hardSleep(15);
    13.    UnityParseCommandLine();
    14.    NSLog("foobar3");
    15.    hardSleep(15);
    16.    RegisterMonoModules();
    17.    NSLog("foobar4");
    18.    hardSleep(15);
    19. }
    20.  
    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
     
  2. HuuPC

    HuuPC

    Joined:
    Sep 9, 2015
    Posts:
    7
    Does anyone have idea about that problem?