I'm getting quite a lot of crashes like this.
In my code, I'm not doing any KVO on my MKAnnotation objects that could explain this exception. So to me, it looks like an iOS bug.
Did anybody else experience similar crashes?
*** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer for the key path "title" from because it is not registered as an observer.'
Thread 0 Crashed:
0 libSystem.B.dylib 0x000792d4 __kill + 8
1 libSystem.B.dylib 0x000792bd raise + 17
2 WhereTo 0x000a430d uncaught_exception_handler (PLCrashReporter.m:137)
3 CoreFoundation 0x000a0adf __handleUncaughtException + 239
4 libobjc.A.dylib 0x00006593 _objc_terminate + 103
5 libstdc++.6.dylib 0x00042df9 __cxxabiv1::__terminate(void (*)()) + 53
6 libstdc++.6.dylib 0x00042e4d std::terminate() + 17
7 libstdc++.6.dylib 0x00042f1d __cxa_throw + 85
8 libobjc.A.dylib 0x000054cb objc_exception_throw + 71
9 CoreFoundation 0x000a07c9 +[NSException raise:format:arguments:] + 69
10 CoreFoundation 0x000a0803 +[NSException raise:format:] + 35
11 Foundation 0x00031b4d -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 545
12 Foundation 0x000318a1 -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 121
13 MapKit 0x00024e75 -[MKAnnotationContainerView _unregisterObserverForBubbleAnnotation:] + 133
14 MapKit 0x0001fd29 -[MKAnnotationContainerView setBubbleAnnotationView:] + 73
15 MapKit 0x0001f4e3 -[MKAnnotationContainerView _showBubbleForAnnotationView:bounce:scrollToFit:userInitiated:avoid:] + 211
16 MapKit 0x0001f235 -[MKAnnotationContainerView _setSelectedAnnotationView:bounce:pressed:scrollToFit:userInitiated:avoid:] + 357
17 MapKit 0x0001f0bf -[MKAnnotationContainerView _setSelectedAnnotationView:bounce:pressed:scrollToFit:userInitiated:] + 83
18 MapKit 0x000248ab -[MKMapView handleTap:] + 195
19 CoreFoundation 0x0003ebbf -[NSObject(NSObject) performSelector:withObject:] + 23
20 UIKit 0x0009a3d3 -[UIGestureRecognizer _updateGestureWithEvent:] + 575
21 UIKit 0x0009a18b -[UIGestureRecognizer _delayedUpdateGesture] + 23
22 UIKit 0x000017b1 _UIGestureRecognizerUpdateObserver + 437
23 CoreFoundation 0x00030c59 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 17
24 CoreFoundation 0x00030acd __CFRunLoopDoObservers + 413
25 CoreFoundation 0x000280cb __CFRunLoopRun + 855
26 CoreFoundation 0x00027c87 CFRunLoopRunSpecific + 231
27 CoreFoundation 0x00027b8f CFRunLoopRunInMode + 59
28 GraphicsServices 0x000044ab GSEventRunModal + 115
29 GraphicsServices 0x00004557 GSEventRun + 63
30 UIKit 0x00037329 -[UIApplication _run] + 413
31 UIKit 0x00034e93 UIApplicationMain + 671
32 WhereTo 0x00003475 main (main.m:14)
I had a similar crash with MapKit starting in OS 4.x.
By 'similar' I mean it was related to KVO and observers but I don't remember the details.
The problem was:
I had a class implenting the MKAnnotation protocol.
But in this class I was accessing the coordinate property without using KVO (directly via the corresponding ivar):
_coordinate = ....
instead of
self.coordinate = ...
It seems that Mapkit is now (starting in OS 4) relying on KVO notification to monitor annotations position.
Turns out, I wrote to the property from background threads which is a no-go. If I make sure to only set it from the main thread, the problem seems to go away.
For future reference; I got the exact same error, but in my case it was caused by trying to programmatically select an annotation that hadn't yet been added to the mapview.
I had a similar issue, but the property getter was a defined function but there was no setter. The MKAnnotation protocol requires a property (getter and setter).
I use same in two MKMapView's and exception thrown when call removeAnnotations: from second map, this try-catch fix problem.
#implementation MyAnnotation //<MKAnnotation>
- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath
{
#try
{
[super removeObserver:observer forKeyPath:keyPath];
}
#catch(...)
{
}
}
#end
Related
I am adding around 1000 MKPolygons onto an MKMapView.
After adding the overlays onto the MKMapView it works fine. However if I zoom in and zoom out quickly (occasionally letting go of the zoom so the mapView processes it's new visibleMapRect) I find the app (sometimes) crashes with the following exception stack trace:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM removeObject:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107db6b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010781b141 objc_exception_throw + 48
2 CoreFoundation 0x0000000107d1712a -[__NSSetM removeObject:] + 538
3 VectorKit 0x000000010bae84fa -[VKRasterOverlayTileSource removeOverlay:] + 89
4 VectorKit 0x000000010b79a648 -[VKMapModel removeRasterOverlay:] + 68
5 MapKit 0x0000000106f93bf1 -[MKOverlayContainerView _removeDrawable:forOverlay:level:] + 502
6 MapKit 0x0000000106f92633 -[MKOverlayContainerView addAndRemoveOverlayViews] + 785
7 MapKit 0x0000000106f44772 -[MKMapView _didChangeRegionMidstream:] + 229
8 MapKit 0x0000000106f49528 -[MKMapView mapLayer:didChangeRegionAnimated:] + 91
9 VectorKit 0x000000010b7d39e8 -[VKMapCameraController rotateToYaw:withPoint:animated:] + 884
10 VectorKit 0x000000010b7d4e7b -[VKMapCameraController snapMapIfNecessary:] + 389
11 MapKit 0x0000000106f93bf1 -[MKOverlayContainerView _removeDrawable:forOverlay:level:] + 502
12 MapKit 0x0000000106f92633 -[MKOverlayContainerView addAndRemoveOverlayViews] + 785
13 MapKit 0x0000000106f44772 -[MKMapView _didChangeRegionMidstream:] + 229
14 MapKit 0x0000000106f49528 -[MKMapView mapLayer:didChangeRegionAnimated:] + 91
15 VectorKit 0x000000010b9f7b0e -[VKScreenCameraController stopPinchingWithFocusPoint:] + 64
16 MapKit 0x0000000106fbb1e3 __38-[MKMapGestureController handlePinch:]_block_invoke.184 + 126
17 VectorKit 0x000000010b78aaa2 -[VKAnimation stopAnimation:] + 109
18 VectorKit 0x000000010b8f9a3d -[VKDynamicAnimation stopAnimation:] + 45
19 MapKit 0x0000000106fb7819 -[MKMapGestureController stopDynamicAnimations] + 50
20 MapKit 0x0000000106fba254 -[MKMapGestureController gestureRecognizerTouchesBegan:] + 39
21 MapKit 0x0000000106fbbab1 -[_MKUserInteractionGestureRecognizer touchesBegan:withEvent:] + 198
22 UIKit 0x0000000108e9b934 -[UIGestureRecognizer _touchesBegan:withEvent:] + 113
23 UIKit 0x0000000108e8901c __55-[UIGestureEnvironment _updateGesturesForEvent:window:]_block_invoke + 337
24 UIKit 0x0000000108e89b79 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 282
25 UIKit 0x0000000108e88e0a -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
26 UIKit 0x00000001089d4eea -[UIWindow sendEvent:] + 4092
27 UIKit 0x0000000108981a84 -[UIApplication sendEvent:] + 352
28 UIKit 0x00000001091655d4 __dispatchPreprocessedEventFromEventQueue + 2926
29 UIKit 0x000000010915d532 __handleEventQueue + 1122
30 UIKit 0x000000010915e800 __handleEventQueue + 5936
31 CoreFoundation 0x0000000107d5cc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
32 CoreFoundation 0x0000000107d420cf __CFRunLoopDoSources0 + 527
33 CoreFoundation 0x0000000107d415ff __CFRunLoopRun + 911
34 CoreFoundation 0x0000000107d41016 CFRunLoopRunSpecific + 406
35 GraphicsServices 0x000000010cc97a24 GSEventRunModal + 62
36 UIKit 0x0000000108964134 UIApplicationMain + 159
37 MyProject 0x0000000106e51a9f main + 111
38 libdyld.dylib 0x000000010e56165d start + 1
This doesn't always happen. Often it's quite rare.
You can see that it's hard to debug and work out what's going wrong because my project doesn't appear in the stack trace (except that it's running in my application...).
When trying to track down the issue I created a very basic app with nothing but an MKMapView and 1000 random MKPolygons with 5 randomly generated CLLocationCoordinate2D each.
I found that the app still crashes when zooming, resting, zooming, resting, etc. But less likely?
All I am doing here is adding basic random MKPolygons to the MKMapView!
Note the MKPolygonRenderer for each MKPolygon does nothing apart from give it a random fillColor.
Note: I am running the application in Xcode on an iPhone 7 Simulator.
What's going wrong here?
Thanks!
I had a very similar problem when adding & removing annotations to a map view.
The answer turned out to be put everything that accesses the annotations - even calculations that only read the annotations array - onto the main thread.
I had only put the actual adding & removing on the main thread and it was ok for the most part, but would randomly crash with
[__NSSetM removeObject:]: object cannot be nil
About 10+ crash reported by crittercism.
Name: SIGSEGV
Reason: SEGV_MAPERR
Seems it is a UIScrollView/UITableView animating or scrolling issue.
How can I find the root cause?
Stack:
0
libobjc.A.dylib 0x0000000195fafbd0 objc_msgSend + 12
1
UIKit 0x00000001892b1db8 -[UIScrollView(UIScrollViewInternal) _delegateScrollViewAnimationEnded] + 64
2
UIKit 0x00000001892b1d30 -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded:finished:] + 204
3
UIKit 0x0000000189366814 -[UIAnimator stopAnimation:] + 500
4
UIKit 0x0000000189366248 -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 332
5
QuartzCore 0x0000000188b4629c CA::Display::DisplayLinkItem::dispatch() + 28
6
QuartzCore 0x0000000188b46134 CA::Display::DisplayLink::dispatch_items() + 320
7
IOKit 0x0000000185921470 IODispatchCalloutFromCFMessage + 372
8
CoreFoundation 0x0000000184712dc4 __CFMachPortPerform + 176
9
CoreFoundation 0x0000000184727a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
10
CoreFoundation 0x00000001847279b4 __CFRunLoopDoSource1 + 432
11
CoreFoundation 0x0000000184725934 __CFRunLoopRun + 1636
12
CoreFoundation 0x00000001846512d4 CFRunLoopRunSpecific + 392
13
GraphicsServices 0x000000018de676fc GSEventRunModal + 164
14
UIKit 0x0000000189216fac UIApplicationMain + 1484
15
MyApp 0x000000010001d280 main (main.m:14)
16
libdyld.dylib 0x000000019661aa08 start + 0
I've seen this happen when a controller and/or its table is deallocated during an animation. The OS still triggers delegate methods (e.g., -scrollViewDidEndScrollingAnimation: or -scrollViewDidEndDecelerating:) when it finishes with the animation, but because the objects no longer exist things get weird.
The best fix is to nil the delegate in the controller's dealloc method.
We receive some reports for crashes in UIWebSelectSinglePicker. We guess it's due to an empty datasource array. This occurs in a webview though. How can we work around this? would prefer a native only solution
edit
happens only on iphones, running both iOS7 and iOS8
1 CoreFoundation __exceptionPreprocess + 127
2 libobjc.A.dylib objc_exception_throw + 36
3 CoreFoundation -[__NSArrayM objectAtIndex:] + 228
4 UIKit -[UIWebSelectSinglePicker pickerView:didSelectRow:inComponent:] + 56
5 UIKit -[UIPickerView _sendSelectionChangedForComponent:notify:] + 90
6 UIKit -[UIPickerTableView _scrollingFinished] + 152
7 UIKit -[UIScrollView(UIScrollViewInternal) _stopScrollDecelerationNotify:] + 842
8 UIKit -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 502
9 UIKit -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 28
10 UIKit -[UIScrollView _smoothScrollWithUpdateTime:] + 208
11 QuartzCore CA::Display::DisplayLinkItem::dispatch() + 96
12 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 364
13 IOMobileFramebuffer IOMobileFramebufferVsyncNotifyFunc + 88
14 IOKit IODispatchCalloutFromCFMessage + 254
15 CoreFoundation __CFMachPortPerform + 130
16 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
17 CoreFoundation __CFRunLoopDoSource1 + 344
18 CoreFoundation __CFRunLoopRun + 1606
19 CoreFoundation CFRunLoopRunSpecific + 474
20 CoreFoundation CFRunLoopRunInMode + 104
21 GraphicsServices GSEventRunModal + 134
22 UIKit UIApplicationMain + 1438
23 MYAPP main (main.m:16)
24 libdyld.dylib start + 0
I would guess this is related to another issue here on SO
There is an issue with the WebView and system controls triggered from HTML.
I think there is no link with UIWebSelectSinglePicker. I think you are trying to access to an object at an index outside the range of your array.
To prevent this you can add something like:
if(index < [self.myArray count] && [self.myArray count] > 0){
id myobject = [self.myArray objectAtIndex:index];
// do what you want here with your object
}
To debug this kind of issue and find where it happens, try to add a symbolic breakpoint:
Select the breakpoint navigator
click on "+"
"add symbolic breakpoint"
add "objectAtIndex" in the symbol field
My app is crashing with the following crashlog when ran on ipad.
It just work fine on iphone devices.
As you might notice, it crash while trying to setup the window. I have searched everywhere but don't see such an issue in any other topic.
Thanks for you help.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: NSParagraphStyle)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010e38ff35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010e028bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010e296998 -[__NSDictionaryM setObject:forKey:] + 968
3 UIKit 0x000000010ca99d2d -[UILabel _setLineBreakMode:] + 529
4 UIKit 0x000000010cb7a572 -[UIButtonLabel setLineBreakMode:] + 93
5 UIKit 0x000000010cb86e5c -[UIButton _setupTitleViewRequestingLayout:] + 308
6 UIKit 0x000000010cb7ed15 -[UIButton titleLabel] + 51
7 UIKit 0x000000010cd3c6d8 -[UIZoomViewController loadView] + 476
8 UIKit 0x000000010c9f67f9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010c9f6c8e -[UIViewController view] + 27
10 UIKit 0x000000010cd3bfa4 -[UIZoomViewController init] + 78
11 UIKit 0x000000010cd39eeb -[UIClassicController _setupWindow] + 544
12 UIKit 0x000000010cd39b7c +[UIClassicController sharedClassicController] + 140
13 UIKit 0x000000010c8e47dd -[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:] + 666
14 UIKit 0x000000010c8e42ae __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 138
15 UIKit 0x000000010c8e4215 -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 349
16 UIKit 0x000000010c8cf31a -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 486
17 UIKit 0x000000010c8cedb8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 336
18 FrontBoardServices 0x000000011064f612 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 265
19 FrontBoardServices 0x000000011065e2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
20 CoreFoundation 0x000000010e2c553c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
21 CoreFoundation 0x000000010e2bb285 __CFRunLoopDoBlocks + 341
22 CoreFoundation 0x000000010e2bb045 __CFRunLoopRun + 2389
23 CoreFoundation 0x000000010e2ba486 CFRunLoopRunSpecific + 470
24 UIKit 0x000000010c8ce669 -[UIApplication _run] + 413
25 UIKit 0x000000010c8d1420 UIApplicationMain + 1282
26 Edyn 0x0000000109704323 main + 115
27 libdyld.dylib 0x000000010ebd2145 start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
Edit 1
The problem is more complicated than I thought. Here is what I have done.
Implemented method swizzling around [UIButtonLabel setLineBreakMode:] so that I can see what is causing to use nil for the LineBreakMode. I found out that if lineBreakMode is set to something else than NSLineBreakByWordWrapping it ultimately crash.
To temporary make it work I am forcing the lineBreakMode to NSLineBreakByWordWrapping which is not a big deal in this case because the label is never seens in my app.
Edit 2
After fixing the issue with lineBreakMode, I am now getting the same issue but this time with [UILabel setShadow:].
Note that it crash on label where I didn't change anything to the shadow attributes (color, offset or blurRadius).
I also get the same issue but this time with paragraphStyle
Which mean I can't definitely not keep using this approach as it seems to be something broken in what's happening.
Edit 3
When I change the deployment target of my app to universal, I don't have any of the above issues.
I was overriding those two functions in a category and guess what? those function seems to be called by ios even before you get control of the app in your AppDelegate. And for some reason on ipad this return nil.
Removing the category fixed the problem.
+ (id)systemFontOfSize:(CGFloat)sz {
return [UIFont fontWithName:#"HelveticaNeue-Regular" size:sz];
}
+ (id)boldSystemFontOfSize:(CGFloat)sz {
return [UIFont fontWithName:#"HelveticaNeue-Bold" size:sz];
}
I'm using Crittercism (SDK 4.1.2) crash reporting service to catch reports on my iOS app. i've been getting this crash many times and i've no idea why it's happening.
Name: SIGSEGV - Reason: Main
Crashed Thread
0 libobjc.A.dylib 0x397c4b26 objc_msgSend + 6
1 UIKit 0x31965a2d -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded:finished:] + 177
2 UIKit 0x31a0e4b3 -[UIAnimator stopAnimation:] + 471
3 UIKit 0x31a0de9d -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 285
4 UIKit 0x31a0dd7d -[UIAnimator(Static) _LCDHeartbeatCallback:] + 53
5 QuartzCore 0x315419cf _ZN2CA7Display15DisplayLinkItem8dispatchEv + 99
6 QuartzCore 0x31541779 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 345
7 IOMobileFramebuffer 0x3411b76d IOMobileFramebufferVsyncNotifyFunc + 105
8 IOKit 0x2fdd9a75 IODispatchCalloutFromCFMessage + 249
9 CoreFoundation 0x2f0b7e21 __CFMachPortPerform + 137
10 CoreFoundation 0x2f0c29df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 35
11 CoreFoundation 0x2f0c297b __CFRunLoopDoSource1 + 347
12 CoreFoundation 0x2f0c114f __CFRunLoopRun + 1399
13 CoreFoundation 0x2f02bc27 CFRunLoopRunSpecific + 523
14 CoreFoundation 0x2f02ba0b CFRunLoopRunInMode + 107
15 GraphicsServices 0x33cff283 GSEventRunModal + 139
16 UIKit 0x318cf049 UIApplicationMain + 1137
17 AppName 0x000b1fef main + 67
Not sure if this is the case for you, but I've had a similar crash caused by a button in an UIView trying to invoke a callback method on a already released object. The UI was displayed, and then the object was released.