Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App hangs on restart with latest Flurry SDK and ios4

Tags:

ios4

flurry

I have a frustrating problem with the latest version of Flurry (Flurry iPhone SDK v2.5). When I start my app, quickly exit, then restart the App, the app briefly loads, flickers a black screen, then stays on the black screen. The black screen stays there until I press the home button, at which point I can restart the app normally. I looked into this further, and it turns out that app state delegates are getting called in the wrong order:

  1. applicationDidBecomeActive //app finishes loading the first time
  2. applicationWillResignActive //app begins to resign
  3. applicationWillEnterForeground //At this point, I have quickly restarted the app, and this is called
  4. applicationDidEnterBackground //When this delegate is called, the screen goes black
  5. applicationDidEnterBackground //This gets called when I hit the home button again, after the screen has been hanging for a while.

So what I think this means is some processes take a bit longer to wrap up once I hit the home button, and if I try to start the app again too quickly there is some very odd behavior. If I wait a few seconds to restart the app, the app behaves normally.

To demonstrate this problem, I created the simplest app I could think of, which I will post here. I built this with XCode 3.2.3, in the 4.0 build directly onto my iphone device (iphone 4). This is important, because I couldn't reproduce this problem on the simulator. You can reproduce this app by creating a new navigation based project named simpleApp, and dropping this code in, with your own Flurry API key of course. Here is simpleAppAppDelegate.m:

#import "simpleAppAppDelegate.h"
#import "RootViewController.h"
#import "FlurryAPI.h"


@implementation simpleAppAppDelegate

@synthesize window;
@synthesize navigationController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    [FlurryAPI startSession:@"<your api key here>"];    

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

    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    printf("applicationWillResignActive\n");
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    printf("applicationDidEnterBackground\n");
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    printf("applicationWillEnterForeground\n");
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    printf("applicationDidBecomeActive\n");
}


- (void)applicationWillTerminate:(UIApplication *)application {
    printf("applicationWillTerminate\n");
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}

- (void)dealloc {
    [navigationController release];
    [window release];
    [super dealloc];
}

@end

And here is simpleAppAppDelegate.h:

#import <UIKit/UIKit.h>

@interface simpleAppAppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end

So anyway, because so many apps are using Flurry I feel like I must be missing something very basic. What really boggles my mind is that I haven't found anyone at all complaining about this particular problem. Also, this is different from the problem in previous versions where the app would appear to start immediately, go black for a few seconds, then resume normally. That problem was solved by calling [FlurryAPI setSessionReportsOnCloseEnabled:false]; after I set the session, but that doesn't help in this case.

Anyway, has anyone else had this problem? I really hope it's just a stupid error on my part. I'm really excited to use Flurry but something like this would cause my app to get rejected.

like image 949
Rick Avatar asked Jul 03 '10 08:07

Rick


1 Answers

I wrote Flurry about this and they got back to me really quickly that they'd look into this. About a week later they wrote back and said they fixed it in v2.6 which is now available. I can't seem to reproduce the problem anymore.

Not to say I'm awesome or anything, but I did kind of single handedly fix this bug.

like image 98
kuma Avatar answered Oct 13 '22 05:10

kuma