Nirav Bhatt
Nirav Bhatt

Reputation: 6969

iOS app failed to launch in time 0x000000008badf00d - delay in applicationDidBecomeActive

I put entire didFinishLaunchingWithOptions with minimal code which is here:

 [UIApplication sharedApplication].idleTimerDisabled = YES;
 m_bDataLoadingNeeded = YES;
 return YES;

As a result, I had to put crucial initialization in applicationDidBecomeActive. Yet, I get the above error.

All references I get about it mentions to complete didFinishLaunchingWithOptions sooner which I have done. Is there any check required for applicationDidBecomeActive?

My crash log is here (somehow, I can't symbolicate it with all dsym and app in place, so I can't know which statement is exact culprit. But everyone can see that it is definitely not didFinishLaunchingWithOptions)

Exception Type:  00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread:  0

Application Specific Information:
<MyBundleID> failed to launch in time

Elapsed total CPU time (seconds): 1.600 (user 1.600, system 0.000), 4% CPU 
Elapsed application CPU time (seconds): 0.438, 1% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x3c66f0fc 0x3c65e000 + 69884
1   libsystem_c.dylib               0x3c5b8124 0x3c5b7000 + 4388
2   SystemConfiguration             0x360d43ca 0x360c0000 + 82890
3   MyApp                           0x001cd406 0xf9000 + 869382
4   MyApp                           0x001ccb78 0xf9000 + 867192
5   MyApp                           0x001cd148 0xf9000 + 868680
6   MyApp                           0x001d77e4 0xf9000 + 911332
7   MyApp                           0x001d7ed0 0xf9000 + 913104
8   MyApp                           0x001cd908 0xf9000 + 870664
9   MyApp                           0x001d46e0 0xf9000 + 898784
10  MyApp                           0x000fb870 0xf9000 + 10352
11  UIKit                           0x36177af6 0x36102000 + 482038
12  UIKit                           0x3615d9bc 0x36102000 + 375228
13  UIKit                           0x36105c34 0x36102000 + 15412
14  UIKit                           0x361056c8 0x36102000 + 14024
15  UIKit                           0x36105116 0x36102000 + 12566
16  GraphicsServices                0x37dfb5a0 0x37df5000 + 26016
17  GraphicsServices                0x37dfb1ce 0x37df5000 + 25038
18  CoreFoundation                  0x342d2170 0x3423b000 + 618864
19  CoreFoundation                  0x342d2112 0x3423b000 + 618770
20  CoreFoundation                  0x342d0f94 0x3423b000 + 614292
21  CoreFoundation                  0x34243eb8 0x3423b000 + 36536
22  CoreFoundation                  0x34243d44 0x3423b000 + 36164
23  UIKit                           0x3615c480 0x36102000 + 369792
24  UIKit                           0x361592fc 0x36102000 + 357116
25  MyApp                           0x000fb4be 0xf9000 + 9406
26  MyApp                           0x000fb474 0xf9000 + 9332

Considering applicationDidBecomeActive is indeed the culprit:

I can move my applicationDidBecomeActive initialization inside background thread - something quite simplistic like this, but I am not sure what other things I will have to do, because this initialize code will in turn internally spawn more threads. I am using AFNetworking, Reachability and other frameworks which are block based. I don't know if I will end up so doing so many modifications to already built architecture and common code.

I am pretty confused how to tackle this in best and shortest possible way.

Upvotes: 6

Views: 5946

Answers (1)

justin
justin

Reputation: 104708

I suspect your program is making a bunch of network requests on the main thread before it is usable -- blocking the user out of interaction for seconds.

The backtrace is not (always/necessarily) important -- your app is being killed after a certain time.

You can probably just run this in Instruments and see where you are doing things which have the potential to take a long time; I/O, network requests -- move these off the main thread, and perform them asynchronously. Also evaluate the CPU hotspots. Initial launch times should be nowhere near that long.

Upvotes: 5

Related Questions