alex-alex/iOS-Ingress — pull request #419 by alistairmcmillan (2013-07-15 01:07:39+00:00)
Title: Fix for Issue #408 Crash on submitting new portal

So we open a view controller which registers a couple of notification observers, which calls DAKeyboardControl's addKeyboardPanningWithActionHandler and it registers its own notification observers.

Then we close our view controller and it removes its observers, but we don't remove the observers that were created in addKeyboardPanningWithActionHandler.

So the next time the view controller is launched, the user clicks on a textfield and the system tries to pass a notification to the previous view controller which doesn't exist. So the app crashes.

Sample crash report:

Date/Time: 2013-07-15 00:57:32.574 +0100
OS Version: iOS 6.1.3 (10B329)
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x427352d9
Crashed Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib	0x3b9675b0 objc_msgSend + 16
1 CoreFoundation	0x33a12034 _CFXNotificationPost + 1424
2 Foundation	0x34328594 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
3 Foundation	0x3432c056 -[NSNotificationCenter postNotificationName:object:] + 26
4 UIKit	0x359b7a46 -[UITextField _becomeFirstResponder] + 626
5 UIKit	0x358cdc3e -[UIResponder becomeFirstResponder] + 350
6 UIKit	0x359e7c3c -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 116
7 UIKit	0x359e755e -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 1734
8 UIKit	0x359e6d84 _UIGestureRecognizerSendActions + 124
9 UIKit	0x359ae3f0 -[UIGestureRecognizer _updateGestureWithEvent:] + 388
10 UIKit	0x35b9ba34 ___UIGestureRecognizerUpdate_block_invoke_0543 + 44
11 UIKit	0x358d282c _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 216
12 UIKit	0x358d128e _UIGestureRecognizerUpdate + 1270
13 UIKit	0x358dc1e2 -[UIWindow _sendGesturesForEvent:] + 762
14 UIKit	0x358dbdae -[UIWindow sendEvent:] + 86
15 UIKit	0x358c97fc -[UIApplication sendEvent:] + 376
16 UIKit	0x358c9116 _UIApplicationHandleEvent + 6150
17 GraphicsServices	0x375d45a0 _PurpleEventCallback + 588
18 GraphicsServices	0x375d41ce PurpleEventCallback + 30
19 CoreFoundation	0x33a96170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
20 CoreFoundation	0x33a96112 __CFRunLoopDoSource1 + 134
21 CoreFoundation	0x33a94f94 __CFRunLoopRun + 1380
22 CoreFoundation	0x33a07eb8 CFRunLoopRunSpecific + 352
23 CoreFoundation	0x33a07d44 CFRunLoopRunInMode + 100
24 GraphicsServices	0x375d32e6 GSEventRunModal + 70
25 UIKit	0x3591d2fc UIApplicationMain + 1116
26 Ingress	0x000fad22 0xf8000 + 11554
27 libdyld.dylib	0x3bda3b1c start + 0