iOS应用程序在闲置一段时间后崩溃

时间:2014-01-23 12:26:48

标签: ios crash

我的应用程序在闲置30分钟后崩溃了。以下是崩溃报告..

应用程序已加载,但是当我尝试打开一个弹出窗口控件(WYPopoverControl)时,它无法打开,一段时间后,当我专注于任何文本框时,它将随机崩溃。崩溃后,当应用程序重新打开时,一切都将恢复正常运行。我该如何调试这些问题?

崩溃看起来好像我没有从通知中心移除观察者..我把RemoveObserver放在dealloc操作系统所需的所有位置..但它仍然崩溃

Thread 0 Crashed:
0   libobjc.A.dylib                 0x39a8fb26 objc_msgSend + 6
1   CoreFoundation                  0x2f616116 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
2   CoreFoundation                  0x2f58a252 _CFXNotificationPost + 1714
3   Foundation                      0x2ff6fc28 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
4   UIKit                           0x31dcc6b2 -[UIDevice setOrientation:animated:] + 290
5   UIKit                           0x31dcbcfc -[UIApplication handleEvent:withNewEvent:] + 1304
6   UIKit                           0x31dcb71c -[UIApplication sendEvent:] + 68
7   UIKit                           0x31e30b38 _UIApplicationHandleEvent + 660
8   GraphicsServices                0x342af70a _PurpleEventCallback + 606
9   GraphicsServices                0x342af2f2 PurpleEventCallback + 30
10  CoreFoundation                  0x2f61e9dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
11  CoreFoundation                  0x2f61e976 __CFRunLoopDoSource1 + 342
12  CoreFoundation                  0x2f61d14a __CFRunLoopRun + 1394
13  CoreFoundation                  0x2f587c22 CFRunLoopRunSpecific + 518
14  CoreFoundation                  0x2f587a06 CFRunLoopRunInMode + 102
15  GraphicsServices                0x342ae27e GSEventRunModal + 134
16  UIKit                           0x31e2b044 UIApplicationMain + 1132
17  dark                            0x000e7a78 0xe0000 + 31352
18  libdyld.dylib                   0x39f9cab4 start + 0

Thread 1:
0   libsystem_kernel.dylib          0x3a04083c kevent64 + 24
1   libdispatch.dylib               0x39f81210 _dispatch_mgr_invoke + 228
2   libdispatch.dylib               0x39f80f96 _dispatch_mgr_thread$VARIANT$mp + 34

Thread 2:
0   libsystem_kernel.dylib          0x3a052f38 __psynch_cvwait + 24
1   libsystem_pthread.dylib         0x3a0bb224 _pthread_cond_wait + 536
2   libsystem_pthread.dylib         0x3a0bc000 pthread_cond_wait + 36
3   Foundation                      0x2ffc23f2 -[NSCondition wait] + 190
4   dark                            0x002e11aa 0xe0000 + 2101674
5   Foundation                      0x30037c82 __NSThread__main__ + 1058
6   libsystem_pthread.dylib         0x3a0bbc1a _pthread_body + 138
7   libsystem_pthread.dylib         0x3a0bbb8a _pthread_start + 98
8   libsystem_pthread.dylib         0x3a0b9c8c thread_start + 4

Thread 3:
0   libsystem_kernel.dylib          0x3a040a8c mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3a040888 mach_msg + 44
2   CoreFoundation                  0x2f61e7be __CFRunLoopServiceMachPort + 150
3   CoreFoundation                  0x2f61cee4 __CFRunLoopRun + 780
4   CoreFoundation                  0x2f587c22 CFRunLoopRunSpecific + 518
5   CoreFoundation                  0x2f587a06 CFRunLoopRunInMode + 102
6   Foundation                      0x2ff753d6 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7   Foundation                      0x2ffc630c -[NSRunLoop(NSRunLoop) run] + 76
8   dark                            0x003073a0 0xe0000 + 2257824
9   Foundation                      0x30037c82 __NSThread__main__ + 1058
10  libsystem_pthread.dylib         0x3a0bbc1a _pthread_body + 138
11  libsystem_pthread.dylib         0x3a0bbb8a _pthread_start + 98
12  libsystem_pthread.dylib         0x3a0b9c8c thread_start + 4

Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x3a040a8c mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3a040888 mach_msg + 44
2   CoreFoundation                  0x2f61e7be __CFRunLoopServiceMachPort + 150
3   CoreFoundation                  0x2f61cee4 __CFRunLoopRun + 780
4   CoreFoundation                  0x2f587c22 CFRunLoopRunSpecific + 518
5   CoreFoundation                  0x2f587a06 CFRunLoopRunInMode + 102
6   Foundation                      0x2ffc22f2 +[NSURLConnection(Loader) _resourceLoadLoop:] + 314
7   Foundation                      0x30037c82 __NSThread__main__ + 1058
8   libsystem_pthread.dylib         0x3a0bbc1a _pthread_body + 138
9   libsystem_pthread.dylib         0x3a0bbb8a _pthread_start + 98
10  libsystem_pthread.dylib         0x3a0b9c8c thread_start + 4

Thread 5 name:  AFNetworking
Thread 5:
0   libsystem_kernel.dylib          0x3a040a8c mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3a040888 mach_msg + 44
2   CoreFoundation                  0x2f61e7be __CFRunLoopServiceMachPort + 150
3   CoreFoundation                  0x2f61cee4 __CFRunLoopRun + 780
4   CoreFoundation                  0x2f587c22 CFRunLoopRunSpecific + 518
5   CoreFoundation                  0x2f587a06 CFRunLoopRunInMode + 102
6   Foundation                      0x2ff753d6 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7   Foundation                      0x2ffc630c -[NSRunLoop(NSRunLoop) run] + 76
8   dark                            0x00151150 0xe0000 + 463184
9   Foundation                      0x30037c82 __NSThread__main__ + 1058
10  libsystem_pthread.dylib         0x3a0bbc1a _pthread_body + 138
11  libsystem_pthread.dylib         0x3a0bbb8a _pthread_start + 98
12  libsystem_pthread.dylib         0x3a0b9c8c thread_start + 4

Thread 6 name:  com.apple.CFSocket.private
Thread 6:
0   libsystem_kernel.dylib          0x3a053440 select$DARWIN_EXTSN + 20
1   CoreFoundation                  0x2f622680 __CFSocketManager + 480
2   libsystem_pthread.dylib         0x3a0bbc1a _pthread_body + 138
3   libsystem_pthread.dylib         0x3a0bbb8a _pthread_start + 98
4   libsystem_pthread.dylib         0x3a0b9c8c thread_start + 4

Thread 7:
0   libsystem_kernel.dylib          0x3a040a8c mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3a040888 mach_msg + 44
2   CoreFoundation                  0x2f61e7be __CFRunLoopServiceMachPort + 150
3   CoreFoundation                  0x2f61cee4 __CFRunLoopRun + 780
4   CoreFoundation                  0x2f587c22 CFRunLoopRunSpecific + 518
5   CoreFoundation                  0x2f5cb736 CFRunLoopRun + 94
6   CoreMotion                      0x2fc3e230 ___lldb_unnamed_function1404$$CoreMotion + 724
7   libsystem_pthread.dylib         0x3a0bbc1a _pthread_body + 138
8   libsystem_pthread.dylib         0x3a0bbb8a _pthread_start + 98
9   libsystem_pthread.dylib         0x3a0b9c8c thread_start + 4

Thread 8:
0   libsystem_kernel.dylib          0x3a053c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3a0b9dc6 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3a0b9c80 start_wqthread + 4

Thread 9:
0   libsystem_kernel.dylib          0x3a053c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3a0b9dc6 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3a0b9c80 start_wqthread + 4

Thread 10:
0   libsystem_kernel.dylib          0x3a053c7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x3a0b9dc6 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x3a0b9c80 start_wqthread + 4

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x17f45e70    r1: 0x00333765      r2: 0x1b88c240      r3: 0x00002060
    r4: 0x17f1cbc0    r5: 0x27d21b80      r6: 0x27d21bdc      r7: 0x27d21aa0
    r8: 0x1658a788    r9: 0x756f5935     r10: 0x00000000     r11: 0x00000001
    ip: 0x3a326744    sp: 0x27d21aa0      lr: 0x2f616119      pc: 0x39a8fb26
  cpsr: 0x20000030

2 个答案:

答案 0 :(得分:2)

您使用addObserver注册了通知,但您从未将自己删除为该注释的接收者。使用removeObserver(均使用Notification Center)。

现在你原来的'听众'消失了,但因为它仍然是注册的 - BOOM

所以不要忘记取消注册!

答案 1 :(得分:-1)

之前我见过类似的骚扰者。我有两个建议: 1.在viewWillAppear中添加一个观察者,并在viewWillDisAppear中将其删除 2.将观察者分配到如下实例:

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.localObserver = [center addObserverForName:NSManagedObjectContextObjectsDidChangeNotification
                                                   object:self.managedObjectContext queue:mainQueue usingBlock:^(NSNotification *notification) {
                                                      //do something when you get this notification
                                                   }];

然后在你的viewWillDisAppear中使用:

取消注册
[[NSNotificationCenter defaultCenter] removeObserver:self.localObserver];

我看到的是在iOS 8中没有调用dealloc。只有在收到内存警告时才会调用它。所以尽量不要在那里取消注册。在早期版本中,它曾经像那样工作。

注意:在上面的代码片段中,我正在观察NSManagedObjectContextObjectsDidChangeNotification。您可以根据自己的要求进行更改。