Skip to content

Why my iPhone App did fail to properly launch ONLY when downloaded from the iPhone app store and NOT in development mode?

by paddoum on May 3rd, 2010

iPhone apps development is always full of surprise to say the least. It’s always very frustrating to experience an iphone apps crash especially when downloaded from the iTunes app store (Following approval by Apple). It happened only with 3G device (Worked fine on the 3GS) and it didn’t “crash” when ran in debug mode on the simulator or on my iPhone

It appears that iPhone OS uses a watchdog timer when applications are launched. If an iPhone app takes too long to complete its initial startup, the operating system terminates the application (my app actually needs to parse a large xml file into a Core Data base when it launches). iPhone apps terminated for this reason will have the exception code 0x8badf00d and related information noted in the associated crash report.

I didn’t experience this issue with my iPhone app when debugging because when Xcode launches an application, the watchdog timer is disabled to compensate for additional overhead that may be incurred when Xcode attaches the debugger ( I have never read any xcode tutorial regarding this topic by the way). As a result, your iPhone app long startup may initially escape your attention if you are exclusively testing by running from Xcode.

I didn’t experience this issue with my iPhone 3GS either because it has a better processor than the iPhone 3G.

If considerable work must be done at launch, Apple recommends to consider performing that work on a secondary thread and visually indicating the activity which I did to solve this specific issue.

UPDATE: And the solution is….

First you create a method that you want to run in the background:

-(void) methodIwantToRunInTheBackground {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

///Whatever you need here

///Remove the text and the spinner from the view
	[updatingLabel removeFromSuperview];
	[spinner stopAnimating];
///stop ignoring touch to the screen
	[[UIApplication sharedApplication] endIgnoringInteractionEvents];
/// Drain the pool
	[pool drain];
}

An then you create the updating label an the spinner where you want to trigger it ( viewDidLoad for me) :

-(void)viewDidLoad{

	///Updating label
	updatingLabel = [[UILabel alloc] initWithFrame:CGRectMake(110,135, 100, 100)];
	updatingLabel.backgroundColor = [UIColor clearColor];
	updatingLabel.textAlignment =UITextAlignmentCenter;
	updatingLabel.textColor = [UIColor grayColor];
	updatingLabel.text = @"Updating....";
	[self.view addSubview:updatingLabel];
	[updatingLabel release];

	///Spinner display
	spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
	[spinner setCenter:CGPointMake(320/2.0, 460/2.0)]; // I do this because I'm in landscape mode
	// spinner is not visible until started
	[self.view addSubview:spinner];
	[spinner release];
	[spinner startAnimating];

////Star ignoring touchs
	[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

///Run your your method in the background as a different thread
	[self performSelectorInBackground:@selector(methodIwantToRunInTheBackground) withObject:nil];

}

From → Development

5 Comments
  1. Janice permalink

    > Apple recommends to consider performing that work on
    > a secondary thread and visually indicating the
    > activity which I did to solve this specific issue.

    Hey, thanks for making everyone read a very long story… and the solution… but *NOT* telling us *HOW* to solve it… or ever showing any code.

  2. paddoum permalink

    Hi Janice,

    I updated my post with the solution.

    Cheers,
    Pierre

  3. Agnès Carlos permalink

    Thanks Pierre to keep us updated,
    from France (different time-to-markets) it s interesting.
    And by the way, I am a big Mac fan…
    Agnès

  4. paddoum permalink

    :-) You can check our iPhone app at agwine.com and cutmycake.com we are getting decent traction. My studio is called anisettestudio.com (Under construction)
    Do you code?
    P.

Trackbacks & Pingbacks

  1. Tweets that mention iPhone App fails to properly launch ONLY when downloaded from the app-store and NOT in development mode. | My First iPhone Application -- Topsy.com

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS