My app get crash two times while enter in to foreground. I tried hard to simulate but i can't. I have attached the crash log also. I can't get the reason from this log. Help me to get ride of this issue. Thanks in advance.
Incident Identifier: 644DF722-CCB1-4A62-9802-43AAE8FD7998
CrashReporter Key: a78f95d5bb2b0cb796602919073666aa96af75e4
Hardware Model: iPhone5,1
Process: myapp [1611]
Path: /var/mobile/Applications/5123A551-8D9B-4890-89B9-10AF4A84FDDF/myapp.app/myapp
Identifier: com.myapp.iphone.myappequ
Version: 6.0 (6.0)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-12-19 16:36:10.710 -0600
OS Version: iOS 7.0.4 (11B554a)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x2e65fe7e __exceptionPreprocess + 126
1 libobjc.A.dylib 0x389bc6c2 objc_exception_throw + 34
2 CoreFoundation 0x2e595ff4 -[__NSArrayI objectAtIndex:] + 172
3 myapp 0x0010a4f2 0xee000 + 115954
4 UIKit 0x30de8956 -[UIViewController loadViewIfRequired] + 514
5 UIKit 0x30de8714 -[UIViewController view] + 20
6 UIKit 0x30e60588 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 384
7 UIKit 0x30e5eeec -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1196
8 UIKit 0x30e5ea32 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 42
9 UIKit 0x30e5e9ba -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 90
10 UIKit 0x30e5e952 -[UIWindow _setRotatableViewOrientation:duration:force:] + 38
11 UIKit 0x30e57454 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 104
12 UIKit 0x30dea392 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 378
13 UIKit 0x30e5e6a4 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 692
14 UIKit 0x30e5e178 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 156
15 UIKit 0x30def57c -[UIWindow addRootViewControllerViewIfPossible] + 460
16 UIKit 0x30decae0 -[UIWindow _setHidden:forced:] + 304
17 UIKit 0x30e57828 -[UIWindow makeKeyAndVisible] + 56
18 myapp 0xee000 + 22384
19 UIKit 0x30e54aa8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
20 UIKit 0x30e544ee -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1386
21 UIKit 0x30e4eb3c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 716
22 UIKit 0x30de9a02 -[UIApplication handleEvent:withNewEvent:] + 3138
23 UIKit 0x30de8cf8 -[UIApplication sendEvent:] + 68
24 myapp 0x00153774 0xee000 + 415604
25 UIKit 0x30e4e31c _UIApplicationHandleEvent + 660
26 GraphicsServices 0x332ce768 _PurpleEventCallback + 604
27 GraphicsServices 0x332ce352 PurpleEventCallback + 30
28 CoreFoundation 0x2e62a772 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
29 CoreFoundation 0x2e62a70e __CFRunLoopDoSource1 + 342
30 CoreFoundation 0x2e628eda __CFRunLoopRun + 1402
31 CoreFoundation 0x2e59346c CFRunLoopRunSpecific + 520
32 CoreFoundation 0x2e59324e CFRunLoopRunInMode + 102
33 UIKit 0x30e4d5be -[UIApplication _run] + 758
34 UIKit 0x30e48840 UIApplicationMain + 1132
35 myapp 0x000f3136 0xee000 + 20790
36 myapp 0xee000 + 20668
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x38f6c1fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x38fd3a4e pthread_kill + 54
2 libsystem_c.dylib 0x38f1d028 abort + 72
3 libc++abi.dylib 0x3836b98a abort_message + 70
4 libc++abi.dylib 0x383846e2 default_terminate_handler() + 250
5 libobjc.A.dylib 0x389bc936 _objc_terminate() + 190
6 libc++abi.dylib 0x383821b0 std::__terminate(void (*)()) + 76
7 libc++abi.dylib 0x38381d12 __cxa_rethrow + 98
8 libobjc.A.dylib 0x389bc80a objc_exception_rethrow + 38
9 CoreFoundation 0x2e5934e2 CFRunLoopRunSpecific + 638
10 CoreFoundation 0x2e59324e CFRunLoopRunInMode + 102
11 UIKit 0x30e4d5be -[UIApplication _run] + 758
12 UIKit 0x30e48840 UIApplicationMain + 1132
13 myapp 0x000f3136 0xee000 + 20790
14 myapp 0x000f30bc 0xee000 + 20668
Thread 1:
0 libsystem_kernel.dylib 0x38f59838 kevent64 + 24
1 libdispatch.dylib 0x38ea80d0 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x38ea261e _dispatch_mgr_thread + 34
Thread 2:
0 libsystem_kernel.dylib 0x38f6cc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38fd0e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38fd0cc0 start_wqthread + 4
Thread 3:
0 libsystem_kernel.dylib 0x38f6cc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38fd0e06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38fd0cc0 start_wqthread + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x00000000 r2: 0x00000000 r3: 0x00002060
r4: 0x00000006 r5: 0x3ad9918c r6: 0x00000000 r7: 0x27d15594
r8: 0x14d8cfd0 r9: 0x00000001 r10: 0x14e50ea0 r11: 0x14e8c7a0
ip: 0x00000148 sp: 0x27d15588 lr: 0x38fd3a53 pc: 0x38f6c1fc
cpsr: 0x00000010
Code in applicationWillEnterForeground
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
*/
[application endBackgroundTask:self.bgTaskId];
self.bgTaskId = UIBackgroundTaskInvalid;
}
The problem is not in your AppDelegate code, it's likely in the UIViewController getting loaded, probably in viewDidLoad
. The crash is not fully symbolicated as you can see on line 3: "myapp" should show the object and message that's from your code.
For a more comprehensive answer, please post your viewDidLoad
code from the UIViewController
presented on screen on app launch.
Check the statements in your loadView
and/or viewDidLoad
(because that's what iOS' loadViewIfRequired
calls) that access an object in an NSArray
.
Also have a look here, similar top of stack trace.
Looks like when the app is coming to foreground you are trying to access data from NSArray which would have been invalidated while the app went to background. Try registering
//in viewWillAppear
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAppComingToForeground)name:UIApplicationWillEnterForegroundNotification object:nil];
//in viewWillDisapear
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
and in the handleAppComingToForeground method you can reinitialize the data for your Array.
Similarly you can setup observers for UIApplicationDidEnterBackgroundNotification and store viewcontroller level data as app goes to background.
User contributions licensed under CC BY-SA 3.0