10

How can I diagnose this error?

Application Specific Information:
    MyApp failed to launch in time

    Elapsed total CPU time (seconds): 4913.443 (user 3868.270, system 1045.173), 56% CPU 
    Elapsed application CPU time (seconds): 0.010, 0% CPU

    Backtrace not available

    Unknown thread crashed with unknown flavor: 5, state_count: 1

    Binary Images:
    0x2fe00000 - 0x2fe26fff  dyld armv7  <a11905c8ef7906bf4b8910fc551f9dbb> /usr/lib/dyld

Here is my didFinishLaunching method:

#pragma mark -
#pragma mark Application lifecycle

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

        if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")) 
        {
            NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
        }

        // Override point for customization after application launch.
        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];

        //Check for connectivity
        internetReach = [[Reachability reachabilityForInternetConnection] retain];
        [internetReach startNotifer];
        [self updateInterfaceWithReachability: internetReach];

        [window addSubview:navigationController.view];
        [window makeKeyAndVisible];

        return YES;
    }
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

3 Answers3

27

You're probably doing a lot of setup work in your AppDelegate's application:didFinishLaunching method.

You should make sure this function exits as soon as possible. Any setup-work that takes time (network access for example) should be done asynchronously in your application. While this is going on, you can show a spinner to indicate to the user that the application is loading.

Philippe Leybaert
  • 168,566
  • 31
  • 210
  • 223
5

In order to add so information to Philippe Leybaert response.
If the application take to much time to start the main thread will be kill so the application will crash.

  • When you're using the simulator, it will not crash.
  • When you are using your iphone connected to xcode it will not crash.
  • When you send it for App Store it might be accepted if the Apple tester is using a fast iPhone
  • When your users on slow like iPhone 3S will crash

A way to test this issu before submitting is to deploy to testflight or with adhoc and install it on the slower device you want to support.

Martin Magakian
  • 3,746
  • 5
  • 37
  • 53
  • I wish ours had crashed on the Apple tester's device! We're actually getting this in an app in the app store and it only crashes on certain user's devices. I've installed it fresh from the App Store on my own devices and it works perfectly - we've also installed it many times from TestFlight on test devices also without problem. It is therefore not as clear-cut as you say. – siburb Jul 10 '13 at 01:39
  • @whiskIT thank's for the information. It make sense if the tester use a fast iPhon. He will not see the bug and validate your app. – Martin Magakian Jul 10 '13 at 05:25
  • While using iPhone connected to Xcode won't crash, you can just hit **stop** in Xcode and then open the app on your iPhone manually again. It will be able to crash. This saves the hassle of going through Ad Hoc or TestFlight distribution. – Hlung Jun 25 '15 at 04:45
1

Just try to divide your application:didFinishLaunchingWithOptions: method code to different function calls and make those calls in background using the threads other then main and make sure that application:didFinishLaunchingWithOptions: method returns as soon as possible

you can use

dispatch_async(dispatch_get_main_queue(), ^{
//put your code
}

I have resolved the issue using this code !

Ram Vinay Yadav
  • 105
  • 2
  • 8
Ankit Vyas
  • 7,507
  • 13
  • 56
  • 89