Not getting why the app is crashing random time. unable to find any str. Please help.. I am not able to track the issue by this log. please also help me how to deal with such difficult log to track where exactly the issue is.
Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSSetM: 0x7fda3c871090> was mutated while being enumerated.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105ed1f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104ce1bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105ed1894 __NSFastEnumerationMutationHandler + 132
3 Foundation 0x000000010488e3be -[NSISEngine _coreReplaceMarker:withMarkerPlusDelta:] + 347
4 Foundation 0x000000010488e1dc -[NSISEngine constraintDidChangeSuchThatMarker:shouldBeReplacedByMarkerPlusDelta:] + 239
5 Foundation 0x000000010488adea -[NSLayoutConstraint _containerGeometryDidChange] + 310
6 UIKit 0x0000000103c03a04 ___UITagLayoutConstraintsForConstantChangeForSelectedAttributes_block_invoke + 409
7 UIKit 0x0000000103c1027b -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 115
8 UIKit 0x0000000103c03865 _UITagLayoutConstraintsForConstantChangeForSelectedAttributes + 80
9 UIKit 0x00000001035ea079 -[UIView _layoutMarginsDidChange] + 60
10 UIKit 0x00000001035ea248 -[UIView setLayoutMargins:] + 426
11 UIKit 0x00000001036a9296 -[UIViewController _setContentOverlayInsets:] + 270
12 UIKit 0x00000001036a9bc7 -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] + 1857
13 UIKit 0x00000001036038cd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
14 QuartzCore 0x0000000109d9dde8 -[CALayer layoutSublayers] + 150
15 QuartzCore 0x0000000109d92a0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x0000000109d9287e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
17 QuartzCore 0x0000000109d0063e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
18 QuartzCore 0x0000000109d0174a _ZN2CA11Transaction6commitEv + 390
19 UIKit 0x000000010358714d _UIApplicationHandleEventQueue + 2035
20 CoreFoundation 0x0000000105e07551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x0000000105dfd41d __CFRunLoopDoSources0 + 269
22 CoreFoundation 0x0000000105dfca54 __CFRunLoopRun + 868
23 CoreFoundation 0x0000000105dfc486 CFRunLoopRunSpecific + 470
24 GraphicsServices 0x0000000107a659f0 GSEventRunModal + 161
25 UIKit 0x000000010358a420 UIApplicationMain + 1282
26 HomeDiary 0x0000000102c861c3 main + 115
27 libdyld.dylib 0x0000000106fa5145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) bt
* thread #1: tid = 0x1f5db, 0x00000001072c3286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001072c3286 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00000001072f642f libsystem_pthread.dylib`pthread_kill + 90
frame #2: 0x000000010705319a libsystem_sim_c.dylib`abort + 129
frame #3: 0x0000000106e14481 libc++abi.dylib`abort_message + 257
frame #4: 0x0000000106e3c3d5 libc++abi.dylib`default_terminate_handler() + 267
frame #5: 0x0000000104ce1e19 libobjc.A.dylib`_objc_terminate() + 103
frame #6: 0x0000000106e39b01 libc++abi.dylib`std::__terminate(void (*)()) + 8
frame #7: 0x0000000106e397aa libc++abi.dylib`__cxa_rethrow + 99
frame #8: 0x0000000104ce1d2c libobjc.A.dylib`objc_exception_rethrow + 40
frame #9: 0x0000000105dfc53e CoreFoundation`CFRunLoopRunSpecific + 654
frame #10: 0x0000000107a659f0 GraphicsServices`GSEventRunModal + 161
frame #11: 0x000000010358a420 UIKit`UIApplicationMain + 1282
* frame #12: 0x0000000102c861c3 HomeDiary`main(argc=1, argv=0x00007fff5cf8e348) + 115 at main.m:16
frame #13: 0x0000000106fa5145 libdyld.dylib`start + 1
The reason it is crashing is in the first line... Collection <__NSSetM: 0x7fda3c871090> was mutated while being enumerated.
This means you have an NSMutableSet and you are enumerating it for (id someObject in mySet) {} or [mySet enumerateObjects... and inside that enumeration you are mutating the set.
Something like this...
for (id someObject in mySet) {
[mySet removeObject:someObject];
}
Or something like that. You can't do this, it will crash... hence your crash.
To find where this is happening you need to add an Exception Breakpoint to the project. This will then stop the execution on the line of code causing the crash.
Related
I am relatively new to Swift and iOS in general. When I create a segue from a button to another view, I get a nasty error message (below). Can someone help me decipher this?
2016-04-17 16:25:49.133 FoodPin[9322:676896] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-u9a-Ka-ctP" from storyboard "Main", but didn't get a UITableView.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102d58d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104afcdeb objc_exception_throw + 48
2 CoreFoundation 0x0000000102d58cbd +[NSException raise:format:] + 205
3 UIKit 0x000000010396e4e2 -[UITableViewController loadView] + 638
4 UIKit 0x000000010371b560 -[UIViewController loadViewIfRequired] + 138
5 UIKit 0x000000010372193b -[UIViewController __viewWillAppear:] + 120
6 UIKit 0x0000000103751750 -[UINavigationController _startCustomTransition:] + 1203
7 UIKit 0x0000000103761b9b -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
8 UIKit 0x0000000103762d0b -[UINavigationController __viewWillLayoutSubviews] + 57
9 UIKit 0x0000000103911503 -[UILayoutContainerView layoutSubviews] + 248
10 UIKit 0x000000010363b980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
11 QuartzCore 0x0000000108006c00 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x0000000107ffb08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
13 QuartzCore 0x0000000107ffaf0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000107fef3c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
15 QuartzCore 0x000000010801d086 _ZN2CA11Transaction6commitEv + 486
16 QuartzCore 0x000000010801d7f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
17 CoreFoundation 0x0000000102c7dc37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
18 CoreFoundation 0x0000000102c7dba7 __CFRunLoopDoObservers + 391
19 CoreFoundation 0x0000000102c737fb __CFRunLoopRun + 1147
20 CoreFoundation 0x0000000102c730f8 CFRunLoopRunSpecific + 488
21 GraphicsServices 0x00000001073eead2 GSEventRunModal + 161
22 UIKit 0x0000000103580f09 UIApplicationMain + 171
23 FoodPin 0x0000000102b589f2 main + 114
24 libdyld.dylib 0x00000001055c092d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I a rookie in OBjective C. I am writing a login feature in Xcode. But it crashes. Seeking for help!
2016-02-06 03:14:09.331 Login[3466:392205] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewController''
* First throw call stack:
(
0 CoreFoundation 0x0000000101b81f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001015fbdeb objc_exception_throw + 48
2 CoreFoundation 0x0000000101b81e7d +[NSException raise:format:] + 205
3 UIKit 0x00000001022e4eff -[UINib instantiateWithOwner:options:] + 499
4 UIKit 0x00000001020bfc16 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
5 UIKit 0x00000001020c0542 -[UIViewController loadView] + 178
6 UIKit 0x00000001020c08a0 -[UIViewController loadViewIfRequired] + 138
7 UIKit 0x00000001020c1013 -[UIViewController view] + 27
8 UIKit 0x0000000101f9a51c -[UIWindow addRootViewControllerViewIfPossible] + 61
9 UIKit 0x0000000101f9ac05 -[UIWindow _setHidden:forced:] + 282
10 UIKit 0x0000000101fac4a5 -[UIWindow makeKeyAndVisible] + 42
11 UIKit 0x0000000101f26396 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
12 UIKit 0x0000000101f2c9c3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1750
13 UIKit 0x0000000101f29ba3 -[UIApplication workspaceDidEndTransaction:] + 188
14 FrontBoardServices 0x00000001048d9784 -[FBSSerialQueue _performNext] + 192
15 FrontBoardServices 0x00000001048d9af2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
16 CoreFoundation 0x0000000101aae011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x0000000101aa3f3c __CFRunLoopDoSources0 + 556
18 CoreFoundation 0x0000000101aa33f3 __CFRunLoopRun + 867
19 CoreFoundation 0x0000000101aa2e08 CFRunLoopRunSpecific + 488
20 UIKit 0x0000000101f294f5 -[UIApplication _run] + 402
21 UIKit 0x0000000101f2e30d UIApplicationMain + 171
22 Login 0x00000001010fd33f main + 111
23 libdyld.dylib 0x00000001042a592d start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) bt
* thread #1: tid = 0x5fc0d, 0x00000001045db286 libsystem_kernel.dylib__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00000001045db286 libsystem_kernel.dylib__pthread_kill + 10
frame #1: 0x00000001045a49f9 libsystem_pthread.dylibpthread_kill + 90
frame #2: 0x000000010434ca44 libsystem_c.dylibabort + 129
frame #3: 0x000000010414a051 libc++abi.dylibabort_message + 257
frame #4: 0x000000010416fac9 libc++abi.dylibdefault_terminate_handler() + 267
frame #5: 0x00000001015fc046 libobjc.A.dylib_objc_terminate() + 103
frame #6: 0x000000010416d26e libc++abi.dylibstd::__terminate(void (*)()) + 8
frame #7: 0x000000010416cef9 libc++abi.dylib__cxa_rethrow + 99
frame #8: 0x00000001015fbf5e libobjc.A.dylibobjc_exception_rethrow + 40
frame #9: 0x0000000101aa2ec4 CoreFoundationCFRunLoopRunSpecific + 676
frame #10: 0x0000000101f294f5 UIKit-[UIApplication _run] + 402
frame #11: 0x0000000101f2e30d UIKitUIApplicationMain + 171
* frame #12: 0x00000001010fd33f Loginmain(argc=1, argv=0x00007fff5eb02650) + 111 at main.m:14
frame #13: 0x00000001042a592d libdyld.dylib`start + 1
(lldb)
To fix the problem,in Two ways:
Option-1
regarding the nib name. Check the nib name spelling, it's correct, case sensitive.
Option-2
if option -1 does not work try this
Open XCode Target
Go to the "Build phases" tab
Click the "Copy bundle resources" section
Click the add button
Add the missing Nib file
then works fine
My app was working fine prior to the forced upgrade to Swift 2.x. My code below is executed on an IBAction for a button that "collapses" the cell, e.g. it replaces it with another layout and then attempts to reload the cell, which for various reasons I've been forced to include each cell in its own section (so, extensibly I'm reloading the section). I've tried outputting various variables to the terminal; the inputs are sound. I've also tried wrapping this in .beginUpdates() and .endUpdates() and when walking through this in the debugger, it will just throw the below exception on the .endUpdates() call instead of the .reloadSections() call. I have also tried replacing .reloadSections() with a blanket call to .reloadData() and I receive the same stack trace, making me believe it's internal to the TableView object somehow.
// Set Selected Patient Configuration to "Collapsed"
patientList.patients[ sender.tag ].updateConfiguration( collapsedConfiguration )
let animation = UITableViewRowAnimation.Automatic
// Retrieve Current Table View and Animate Changes
let tableView = self.superview!.superview as! UITableView
// Reload Section with Animation
tableView.reloadSections(NSIndexSet( index: sender.tag ), withRowAnimation: animation )
My code will evaluate the backing data's collapsed state and draw it in either the full or collapsed view.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM insertObject:atIndex:]: index 2 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x00e2fa84 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x03235e02 objc_exception_throw + 50
2 CoreFoundation 0x00cdd211 -[__NSArrayM insertObject:atIndex:] + 881
3 Foundation 0x01510134 -[NSKeyValueSlowMutableArray insertObject:atIndex:] + 115
4 CoreFoundation 0x00d38630 -[NSMutableArray insertObjects:count:atIndex:] + 192
5 CoreFoundation 0x00d38322 -[NSMutableArray insertObjectsFromArray:range:atIndex:] + 322
6 CoreFoundation 0x00d381c2 -[NSMutableArray addObjectsFromArray:] + 834
7 UIKit 0x024f4d4f -[UIRuntimeOutletCollectionConnection performConnect] + 964
8 UIKit 0x024f4daf -[UIRuntimeOutletCollectionConnection connect] + 33
9 libobjc.A.dylib 0x0324a00c -[NSObject performSelector:] + 62
10 CoreFoundation 0x00d60571 -[NSArray makeObjectsPerformSelector:] + 273
11 UIKit 0x021b06f6 -[UINib instantiateWithOwner:options:] + 2102
12 UIKit 0x01eeed6c -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 457
13 UIKit 0x01eef173 -[UITableView dequeueReusableCellWithIdentifier:] + 48
14 Halo 0x001b5174 _TFC4Halo18MainViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 2356
15 Halo 0x001be459 _TToFC4Halo18MainViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 89
16 UIKit 0x01f03a19 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 782
17 UIKit 0x01f03b47 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 90
18 UIKit 0x022568cc -[_UITableViewUpdateSupport(Private) _setupAnimationsForNewlyInsertedCells] + 8353
19 UIKit 0x0226181a -[_UITableViewUpdateSupport _setupAnimations] + 161
20 UIKit 0x01ed7fd3 -[UITableView _updateWithItems:updateSupport:] + 3653
21 UIKit 0x01ecfc91 -[UITableView _endCellAnimationsWithContext:] + 17491
22 UIKit 0x01eea538 -[UITableView _updateSections:updateAction:withRowAnimation:headerFooterOnly:] + 460
23 UIKit 0x01eea625 -[UITableView reloadSections:withRowAnimation:] + 73
24 Halo 0x00105e10 _TFC4Halo28FullPatientViewTableViewCell19collapseButtonPressfS0_FCSo8UIButtonT_ + 6208
25 Halo 0x0010645d _TToFC4Halo28FullPatientViewTableViewCell19collapseButtonPressfS0_FCSo8UIButtonT_ + 61
26 libobjc.A.dylib 0x0324a0b5 -[NSObject performSelector:withObject:withObject:] + 84
27 UIKit 0x01d8016a -[UIApplication sendAction:to:from:forEvent:] + 118
28 UIKit 0x01d800e9 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
29 UIKit 0x01f1e19f -[UIControl sendAction:to:forEvent:] + 79
30 UIKit 0x01f1e51f -[UIControl _sendActionsForEvents:withEvent:] + 408
31 UIKit 0x01f1d525 -[UIControl touchesEnded:withEvent:] + 714
32 UIKit 0x022efeaa _UIGestureRecognizerUpdate + 12763
33 UIKit 0x01dfabdf -[UIWindow _sendGesturesForEvent:] + 1559
34 UIKit 0x01dfc298 -[UIWindow sendEvent:] + 1137
35 UIKit 0x01da1efb -[UIApplication sendEvent:] + 266
36 UIKit 0x01d77cb6 _UIApplicationHandleEventQueue + 7802
37 CoreFoundation 0x00d49d1f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
38 CoreFoundation 0x00d3f9ab __CFRunLoopDoSources0 + 523
39 CoreFoundation 0x00d3edc8 __CFRunLoopRun + 1032
40 CoreFoundation 0x00d3e706 CFRunLoopRunSpecific + 470
41 CoreFoundation 0x00d3e51b CFRunLoopRunInMode + 123
42 GraphicsServices 0x058c0664 GSEventRunModal + 192
43 GraphicsServices 0x058c04a1 GSEventRun + 104
44 UIKit 0x01d7e1eb UIApplicationMain + 160
45 Halo 0x0011eb6c main + 140
46 libdyld.dylib 0x03ceca21 start + 1
47 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The stack is not very helpful to me and I can't even figure out the opening message: "insertObject:atIndex:]: index 2 beyond bounds [0 .. 0]." No where in this sample and my test with a single table entry should there be an index of '2.' Any help you could provide would be appreciated.
Here's my 'bt' on this exception:
* thread #1: tid = 0xc9ca7, 0x0401969a libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0401969a libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x03fe4634 libsystem_pthread.dylib`pthread_kill + 101
frame #2: 0x03d9339d libsystem_c.dylib`abort + 156
frame #3: 0x04034ae7 libc++abi.dylib`abort_message + 151
frame #4: 0x04055683 libc++abi.dylib`default_terminate_handler() + 300
frame #5: 0x032360b6 libobjc.A.dylib`_objc_terminate() + 108
frame #6: 0x04052d0d libc++abi.dylib`std::__terminate(void (*)()) + 14
frame #7: 0x0405293e libc++abi.dylib`__cxa_rethrow + 103
frame #8: 0x03235fad libobjc.A.dylib`objc_exception_rethrow + 47
frame #9: 0x00d3e7d0 CoreFoundation`CFRunLoopRunSpecific + 672
frame #10: 0x00d3e51b CoreFoundation`CFRunLoopRunInMode + 123
frame #11: 0x058c0664 GraphicsServices`GSEventRunModal + 192
frame #12: 0x058c04a1 GraphicsServices`GSEventRun + 104
frame #13: 0x01d7e1eb UIKit`UIApplicationMain + 160
* frame #14: 0x0011eb6c Halo`main + 140 at AppDelegate.swift:26
frame #15: 0x03ceca21 libdyld.dylib`start + 1
Per request, here's the code followed by the output:
// Retrieve Current Table View and Animate Changes
let tableView = self.superview!.superview as! UITableView
// Test Output
print( "tableView.numberOfSections: \(tableView.numberOfSections)" )
print( "tableView.numberOfRowsInSection( sender.tag ): \(tableView.numberOfRowsInSection( sender.tag ))" )
// Reload Section with Animation
tableView.reloadSections(NSIndexSet( index: sender.tag ), withRowAnimation: animation )
tableView.numberOfSections: 1
tableView.numberOfRowsInSection( sender.tag ): 1
This section of the stack trace (probably) means that you have an IBOutletCollection, and UIKit is now trying to populate it from a storyboard or nib:
7 UIKit 0x024f4d4f -[UIRuntimeOutletCollectionConnection performConnect] + 964
8 UIKit 0x024f4daf -[UIRuntimeOutletCollectionConnection connect] + 33
And this section looks like it’s trying to add bound objects to an existing array:
2 CoreFoundation 0x00cdd211 -[__NSArrayM insertObject:atIndex:] + 881
3 Foundation 0x01510134 -[NSKeyValueSlowMutableArray insertObject:atIndex:] + 115
4 CoreFoundation 0x00d38630 -[NSMutableArray insertObjects:count:atIndex:] + 192
5 CoreFoundation 0x00d38322 -[NSMutableArray insertObjectsFromArray:range:atIndex:] + 322
6 CoreFoundation 0x00d381c2 -[NSMutableArray addObjectsFromArray:] + 834
All of that means that the error may not have anything to do with the code you posted, but rather with your nib and how it interacts with the properties it’s bound to.
Take a look at whether you’re using an IBOutletCollection, and if so, start debugging the things it’s bound to.
I have detected a rare crash in my application. The stack trace was not helpful. It is not directly related to my code:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSAttributeDictionary textContainerForAttributedString:containerSize:lineFragmentPadding:]: unrecognized selector sent to instance 0x1b8d89c0'
Last Exception Backtrace:
0 CoreFoundation 0x2e23bfd3 __exceptionPreprocess + 131
1 libobjc.A.dylib 0x38ab2ccf objc_exception_throw + 38
2 CoreFoundation 0x2e23f967 -[NSObject(NSObject) doesNotRecognizeSelector:] + 202
3 CoreFoundation 0x2e23e253 ___forwarding___ + 706
4 CoreFoundation 0x2e18d7f8 __forwarding_prep_0___ + 24
5 UIFoundation 0x35e77a25 __NSStringDrawingEngine + 12204
6 UIFoundation 0x35e749a7 -[NSString(NSExtendedStringDrawing) drawWithRect:options:attributes:context:] + 150
7 UIKit 0x30a70d21 -[UILabel _drawTextInRect:baselineCalculationOnly:] + 4224
8 UIKit 0x30ad7009 -[UILabel drawTextInRect:] + 500
9 UIKit 0x30ad6e0b -[UILabel drawRect:] + 78
10 UIKit 0x30ad6da5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 372
11 QuartzCore 0x307042c1 -[CALayer drawInContext:] + 100
12 QuartzCore 0x306ede3f CABackingStoreUpdate_ + 1854
13 QuartzCore 0x307c8d6d ___ZN2CA5Layer8display_Ev_block_invoke + 52
14 QuartzCore 0x306ed6f3 x_blame_allocations + 82
15 QuartzCore 0x306ed39b CA::Layer::display_() + 1106
16 QuartzCore 0x306d103d CA::Layer::display_if_needed(CA::Transaction*) + 208
17 QuartzCore 0x306d0cd5 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
18 QuartzCore 0x306d06df CA::Context::commit_transaction(CA::Transaction*) + 230
19 QuartzCore 0x306d04ef CA::Transaction::commit() + 314
20 QuartzCore 0x306fda83 CA::Transaction::release_thread(void*) + 162
21 libsystem_pthread.dylib 0x390dd68d _pthread_tsd_cleanup + 164
22 libsystem_pthread.dylib 0x390dd40b _pthread_exit + 86
23 libsystem_pthread.dylib 0x390de17d pthread_exit + 28
24 Foundation 0x2eb7846f +[NSThread exit] + 10
25 Foundation 0x2ec24a7d __NSThread__main__ + 1092
26 libsystem_pthread.dylib 0x390de919 _pthread_body + 140
27 libsystem_pthread.dylib 0x390de88b _pthread_start + 102
28 libsystem_pthread.dylib 0x390dcaa4 thread_start + 8
Therefore, I tried to add more debug information to find out more about the crash. I could find traces to viewWillLayoutSubviews. It is being called in the background. I can just exit from the function if I detect it is in the background. But this is a dirty hack. I want to fix it correctly by preventing "things" from making the app call viewWillLayoutSubviews in the background thread.
I couldn't yet found those "things" as stacktrace is not helpful.
frame #1: 0x32946d16 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 314
frame #2: 0x325c462a QuartzCore`-[CALayer layoutSublayers] + 142
frame #3: 0x325bfe3a QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 350
frame #4: 0x325bfccc QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
frame #5: 0x325bf6de QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 230
frame #6: 0x325bf4ee QuartzCore`CA::Transaction::commit() + 314
frame #7: 0x325eca82 QuartzCore`CA::Transaction::release_thread(void*) + 162
frame #8: 0x3af0568c libsystem_pthread.dylib`_pthread_tsd_cleanup + 164
frame #9: 0x3af0540a libsystem_pthread.dylib`_pthread_exit + 86
frame #10: 0x3af0617c libsystem_pthread.dylib`pthread_exit + 28
frame #11: 0x30a6746e Foundation`+[NSThread exit] + 10
frame #12: 0x30b13a7c Foundation`__NSThread__main__ + 1092
frame #13: 0x3af06918 libsystem_pthread.dylib`_pthread_body + 140
frame #14: 0x3af0688a libsystem_pthread.dylib`_pthread_start + 102`
What can be those "things"?
This kind of crash occurs when you call something in the background that must run on the main thread.
Finding the exact line may be almost impossible. I found the result with lots of NSLog lines and [NSThread isMainThread] lines.
Calling almost anything on UI elements (especially those require size calculations/changes, triggers viewWillLayoutSubviews. In my case it was both UIImageViews and UILabels.
If you can't find where you make UI updates in the background, check if you post NSNotifications in the background.
I am still fairly new to objective-c and I am looking for some help figuring a crash on my App.
In my storyboard I basically have a containerview which is using an embed segue to display a UITableView. Basically everything has been working fine for months, but now I am getting this crash whenever the AddPOIViewController is accessed (view does not appear). The builds without warnings or errors. Any help would be greatly appreciated.
* Assertion failure in -[UIStoryboardEmbedSegue perform], /SourceCache/UIKit_Sim/UIKit-2903.23/UIStoryboardEmbedSegue.m:18
* thread #1: tid = 0xd9c7c2, 0x0202988a libobjc.A.dylibobjc_exception_throw, queue = 'com.apple.main-thread, stop reason = breakpoint 1.1
frame #0: 0x0202988a libobjc.A.dylibobjc_exception_throw
frame #1: 0x02afe448 CoreFoundation+[NSException raise:format:arguments:] + 136
frame #2: 0x019fcfee Foundation-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
frame #3: 0x01225438 UIKit-[UIStoryboardEmbedSegue perform] + 154
frame #4: 0x010bf07e UIKit-[UIStoryboardSegueTemplate _perform:] + 174
frame #5: 0x010bf0f9 UIKit-[UIStoryboardSegueTemplate perform:] + 115
frame #6: 0x00c9e2bd UIKit-[UIViewController loadViewIfRequired] + 605
frame #7: 0x00c9e5b4 UIKit-[UIViewController view] + 35
frame #8: 0x00cadab9 UIKit-[UIViewController shouldAutorotate] + 36
frame #9: 0x00cade01 UIKit-[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
frame #10: 0x00f325e5 UIKit-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
frame #11: 0x00caa0fc UIKit-[UIViewController presentViewController:withTransition:completion:] + 6433
frame #12: 0x00caa61f UIKit-[UIViewController presentViewController:animated:completion:] + 130
frame #13: 0x00caa65f UIKit-[UIViewController presentModalViewController:animated:] + 56
frame #14: 0x010cee16 UIKit-[UIStoryboardModalSegue perform] + 271
frame #15: 0x010bf07e UIKit-[UIStoryboardSegueTemplate _perform:] + 174
frame #16: 0x010bf0f9 UIKit-[UIStoryboardSegueTemplate perform:] + 115
frame #17: 0x0203b874 libobjc.A.dylib-[NSObject performSelector:withObject:withObject:] + 77
frame #18: 0x00b8c0c2 UIKit-[UIApplication sendAction:to:from:forEvent:] + 108
frame #19: 0x00e60c9b UIKit-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
frame #20: 0x0203b874 libobjc.A.dylib-[NSObject performSelector:withObject:withObject:] + 77
frame #21: 0x00b8c0c2 UIKit-[UIApplication sendAction:to:from:forEvent:] + 108
frame #22: 0x00b8c04e UIKit-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
frame #23: 0x00c840c1 UIKit-[UIControl sendAction:to:forEvent:] + 66
frame #24: 0x00c84484 UIKit-[UIControl _sendActionsForEvents:withEvent:] + 577
frame #25: 0x00c83733 UIKit-[UIControl touchesEnded:withEvent:] + 641
frame #26: 0x00bc951d UIKit-[UIWindow sendTouchesForEvent:] + 852
frame #27: 0x00bca184 UIKit-[UIWindow sendEvent:] + 1232
frame #28: 0x00b9de86 UIKit-[UIApplication sendEvent:] + 242
frame #29: 0x00b8818f UIKit_UIApplicationHandleEventQueue + 11421
frame #30: 0x02a8783f CoreFoundation_CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #31: 0x02a871cb CoreFoundation__CFRunLoopDoSources0 + 235
frame #32: 0x02aa429e CoreFoundation__CFRunLoopRun + 910
frame #33: 0x02aa3ac3 CoreFoundationCFRunLoopRunSpecific + 467
frame #34: 0x02aa38db CoreFoundationCFRunLoopRunInMode + 123
frame #35: 0x03a759e2 GraphicsServicesGSEventRunModal + 192
frame #36: 0x03a75809 GraphicsServicesGSEventRun + 104
frame #37: 0x00b8ad3b UIKitUIApplicationMain + 1225
frame #38: 0x0000206d Pawclub.camain(argc=1, argv=0xbfffeed4) + 141 at main.m:16
2013-11-18 12:56:41.093 Pawclub.ca[70486:70b] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'containerView is required.'
** First throw call stack:
(
0 CoreFoundation 0x02afe5e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x020298b6 objc_exception_throw + 44
2 CoreFoundation 0x02afe448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x019fcfee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x01225438 -[UIStoryboardEmbedSegue perform] + 154
5 UIKit 0x010bf07e -[UIStoryboardSegueTemplate _perform:] + 174
6 UIKit 0x010bf0f9 -[UIStoryboardSegueTemplate perform:] + 115
7 UIKit 0x00c9e2bd -[UIViewController loadViewIfRequired] + 605
8 UIKit 0x00c9e5b4 -[UIViewController view] + 35
9 UIKit 0x00cadab9 -[UIViewController shouldAutorotate] + 36
10 UIKit 0x00cade01 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
11 UIKit 0x00f325e5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
12 UIKit 0x00caa0fc -[UIViewController presentViewController:withTransition:completion:] + 6433
13 UIKit 0x00caa61f -[UIViewController presentViewController:animated:completion:] + 130
14 UIKit 0x00caa65f -[UIViewController presentModalViewController:animated:] + 56
15 UIKit 0x010cee16 -[UIStoryboardModalSegue perform] + 271
16 UIKit 0x010bf07e -[UIStoryboardSegueTemplate _perform:] + 174
17 UIKit 0x010bf0f9 -[UIStoryboardSegueTemplate perform:] + 115
18 libobjc.A.dylib 0x0203b874 -[NSObject performSelector:withObject:withObject:] + 77
19 UIKit 0x00b8c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
20 UIKit 0x00e60c9b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 139
21 libobjc.A.dylib 0x0203b874 -[NSObject performSelector:withObject:withObject:] + 77
22 UIKit 0x00b8c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
23 UIKit 0x00b8c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
24 UIKit 0x00c840c1 -[UIControl sendAction:to:forEvent:] + 66
25 UIKit 0x00c84484 -[UIControl _sendActionsForEvents:withEvent:] + 577
26 UIKit 0x00c83733 -[UIControl touchesEnded:withEvent:] + 641
27 UIKit 0x00bc951d -[UIWindow _sendTouchesForEvent:] + 852
28 UIKit 0x00bca184 -[UIWindow sendEvent:] + 1232
29 UIKit 0x00b9de86 -[UIApplication sendEvent:] + 242
30 UIKit 0x00b8818f _UIApplicationHandleEventQueue + 11421
31 CoreFoundation 0x02a8783f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
32 CoreFoundation 0x02a871cb __CFRunLoopDoSources0 + 235
33 CoreFoundation 0x02aa429e __CFRunLoopRun + 910
34 CoreFoundation 0x02aa3ac3 CFRunLoopRunSpecific + 467
35 CoreFoundation 0x02aa38db CFRunLoopRunInMode + 123
36 GraphicsServices 0x03a759e2 GSEventRunModal + 192
37 GraphicsServices 0x03a75809 GSEventRun + 104
38 UIKit 0x00b8ad3b UIApplicationMain + 1225
39 Pawclub.ca 0x0000206d main + 141
40 libdyld.dylib 0x0251070d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Program ended with exit code: 0
Try to set breakpoints and find the exact line that crashes?
Sounds like the segue is being run more than once. Either your calling perform segue or some other actions is trying to call it again while it's active. There's an internal assertion being hit.
Just don't do that ;)