I got the app crashed on the iOS Simulator 16.2 when layout 2 text fields horizontally.
Step by step to reproduce on iOS Simulator 16.2:
Environments:
Xcode 14.2
iOS 16.2
Simulator
Step 1: 2 text fields (UITextField) into a horizontal stackview with leading, trailing, top and bottom constraints.
Step 2: Set a long text for both of 2 text fields (appear three dots at the end of the textfield)
Step 3: click on the first text field
Step 4: click on the second text field
Result: The app is crashed at step 4
Error information:
2023-01-30 14:16:57.647873+0700 iOS16dot2TextFieldBug[18988:1850296] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff8004288ab __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff80004dba3 objc_exception_throw + 48
2 CoreFoundation 0x00007ff800428789 -[NSException initWithCoder:] + 0
3 QuartzCore 0x00007ff80897d05e -[CALayer setPosition:] + 388
4 UIKitCore 0x000000010a2d90f4 -[UIView setCenter:] + 253
5 UIKitCore 0x0000000109105c2a -[_UIEditMenuPresentation _displayMenu:reason:] + 1959
6 UIKitCore 0x0000000109105387 -[_UIEditMenuPresentation displayMenu:configuration:] + 81
7 UIKitCore 0x000000010a29772a __58-[UIEditMenuInteraction presentEditMenuWithConfiguration:]_block_invoke + 207
8 UIKitCore 0x000000010a299222 __80-[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:]_block_invoke + 87
9 UIKitCore 0x000000010a0085cb __133-[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:]_block_invoke + 208
10 UIKitCore 0x000000010a008732 -[_UIContextMenuInteractionBasedTextContextInteraction _querySelectionCommandsForConfiguration:suggestedActions:completionHandler:] + 325
11 UIKitCore 0x000000010a0084da -[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:] + 126
12 UIKitCore 0x000000010a29918f -[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:] + 296
13 UIKitCore 0x000000010a297485 -[UIEditMenuInteraction presentEditMenuWithConfiguration:] + 240
14 UIKitCore 0x000000010a008d6d -[_UIContextMenuInteractionBasedTextContextInteraction presentSelectionCommandsWithConfiguration:] + 94
15 UIKitCore 0x000000010a05cb6f -[UITextSelectionView _presentEditMenuWithPreferredDirection:replacements:] + 103
16 UIKitCore 0x000000010a05c792 -[UITextSelectionView _showCommandsWithReplacements:isForContextMenu:forDictation:arrowDirection:] + 1487
17 UIKitCore 0x000000010a05c157 __77-[UITextSelectionView _showCommandsWithReplacements:forDictation:afterDelay:]_block_invoke + 262
18 libdispatch.dylib 0x000000010246bf5b _dispatch_client_callout + 8
19 libdispatch.dylib 0x000000010246f164 _dispatch_continuation_pop + 836
20 libdispatch.dylib 0x0000000102486d2e _dispatch_source_invoke + 2198
21 libdispatch.dylib 0x000000010247cbc7 _dispatch_main_queue_drain + 1065
22 libdispatch.dylib 0x000000010247c790 _dispatch_main_queue_callback_4CF + 31
23 CoreFoundation 0x00007ff800387b1f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
24 CoreFoundation 0x00007ff800382436 __CFRunLoopRun + 2482
25 CoreFoundation 0x00007ff8003816a7 CFRunLoopRunSpecific + 560
26 GraphicsServices 0x00007ff809cb128a GSEventRunModal + 139
27 UIKitCore 0x0000000109ccbad3 -[UIApplication _run] + 994
28 UIKitCore 0x0000000109cd09ef UIApplicationMain + 123
29 libswiftUIKit.dylib 0x0000000102a18c72 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
30 iOS16dot2TextFieldBug 0x000000010223c908 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
31 iOS16dot2TextFieldBug 0x000000010223c897 $s21iOS16dot2TextFieldBug11AppDelegateC5$mainyyFZ + 39
32 iOS16dot2TextFieldBug 0x000000010223c988 main + 24
33 dyld 0x00000001025912bf start_sim + 10
34 ??? 0x0000000102375310 0x0 + 4332147472
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 (BA2F723B-EEE6-48D0-89DD-9DAEC9E9A11E) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14
I just got this issue on iOS Simulator 16.2. Everything is normal on the lower than iOS 16.2.
Full of code here
I don't know this is an issue from iOS 16.2 or not.
Have you seen this issue? Please help me fix it if you can.
Thank you.
It certainly appears to be a bug.
One work-around is to add this in viewDidLoad() (or set in Storyboard):
[emailTextField, websiteTextField].forEach {
if let tf = $0 {
tf.autocorrectionType = .no
tf.spellCheckingType = .no
}
}
Your example is looking for "email" and "website" entries, so you probably don't want/need those anyway.
Related
I got the app crashed on the iOS Simulator 16.2 when layout 2 text fields horizontally.
Step by step to reproduce on iOS Simulator 16.2:
Environments:
Xcode 14.2
iOS 16.2
Simulator
Step 1: 2 text fields (UITextField) into a horizontal stackview with leading, trailing, top and bottom constraints.
Step 2: Set a long text for both of 2 text fields (appear three dots at the end of the textfield)
Step 3: click on the first text field
Step 4: click on the second text field
Result: The app is crashed at step 4
Error information:
2023-01-30 14:16:57.647873+0700 iOS16dot2TextFieldBug[18988:1850296] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff8004288ab __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff80004dba3 objc_exception_throw + 48
2 CoreFoundation 0x00007ff800428789 -[NSException initWithCoder:] + 0
3 QuartzCore 0x00007ff80897d05e -[CALayer setPosition:] + 388
4 UIKitCore 0x000000010a2d90f4 -[UIView setCenter:] + 253
5 UIKitCore 0x0000000109105c2a -[_UIEditMenuPresentation _displayMenu:reason:] + 1959
6 UIKitCore 0x0000000109105387 -[_UIEditMenuPresentation displayMenu:configuration:] + 81
7 UIKitCore 0x000000010a29772a __58-[UIEditMenuInteraction presentEditMenuWithConfiguration:]_block_invoke + 207
8 UIKitCore 0x000000010a299222 __80-[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:]_block_invoke + 87
9 UIKitCore 0x000000010a0085cb __133-[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:]_block_invoke + 208
10 UIKitCore 0x000000010a008732 -[_UIContextMenuInteractionBasedTextContextInteraction _querySelectionCommandsForConfiguration:suggestedActions:completionHandler:] + 325
11 UIKitCore 0x000000010a0084da -[_UIContextMenuInteractionBasedTextContextInteraction _editMenuInteraction:menuForConfiguration:suggestedActions:completionHandler:] + 126
12 UIKitCore 0x000000010a29918f -[UIEditMenuInteraction _prepareMenuAtLocation:configuration:completionHandler:] + 296
13 UIKitCore 0x000000010a297485 -[UIEditMenuInteraction presentEditMenuWithConfiguration:] + 240
14 UIKitCore 0x000000010a008d6d -[_UIContextMenuInteractionBasedTextContextInteraction presentSelectionCommandsWithConfiguration:] + 94
15 UIKitCore 0x000000010a05cb6f -[UITextSelectionView _presentEditMenuWithPreferredDirection:replacements:] + 103
16 UIKitCore 0x000000010a05c792 -[UITextSelectionView _showCommandsWithReplacements:isForContextMenu:forDictation:arrowDirection:] + 1487
17 UIKitCore 0x000000010a05c157 __77-[UITextSelectionView _showCommandsWithReplacements:forDictation:afterDelay:]_block_invoke + 262
18 libdispatch.dylib 0x000000010246bf5b _dispatch_client_callout + 8
19 libdispatch.dylib 0x000000010246f164 _dispatch_continuation_pop + 836
20 libdispatch.dylib 0x0000000102486d2e _dispatch_source_invoke + 2198
21 libdispatch.dylib 0x000000010247cbc7 _dispatch_main_queue_drain + 1065
22 libdispatch.dylib 0x000000010247c790 _dispatch_main_queue_callback_4CF + 31
23 CoreFoundation 0x00007ff800387b1f __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
24 CoreFoundation 0x00007ff800382436 __CFRunLoopRun + 2482
25 CoreFoundation 0x00007ff8003816a7 CFRunLoopRunSpecific + 560
26 GraphicsServices 0x00007ff809cb128a GSEventRunModal + 139
27 UIKitCore 0x0000000109ccbad3 -[UIApplication _run] + 994
28 UIKitCore 0x0000000109cd09ef UIApplicationMain + 123
29 libswiftUIKit.dylib 0x0000000102a18c72 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
30 iOS16dot2TextFieldBug 0x000000010223c908 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
31 iOS16dot2TextFieldBug 0x000000010223c897 $s21iOS16dot2TextFieldBug11AppDelegateC5$mainyyFZ + 39
32 iOS16dot2TextFieldBug 0x000000010223c988 main + 24
33 dyld 0x00000001025912bf start_sim + 10
34 ??? 0x0000000102375310 0x0 + 4332147472
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 274.667]. Layer: <CALayer:0x60000281a600; position = CGPoint (0 0); bounds = CGRect (0 0; 199.667 48); delegate = <_UIEditMenuListView: 0x7f9bac61b960; frame = (-99.8333 -24; 199.667 48); alpha = 0; layer = <CALayer: 0x60000281a600>>; sublayers = (<CALayer: 0x6000028d3740>); opaque = YES; opacity = 0; shadowOpacity = 0.25; shadowOffset = CGSize (0 3); shadowRadius = 12>'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPhone 14 (BA2F723B-EEE6-48D0-89DD-9DAEC9E9A11E) - Runtime: iOS 16.2 (20C52) - DeviceType: iPhone 14
I just got this issue on iOS Simulator 16.2. Everything is normal on the lower than iOS 16.2.
Full of code here
I don't know this is an issue from iOS 16.2 or not.
Have you seen this issue? Please help me fix it if you can.
Thank you.
It certainly appears to be a bug.
One work-around is to add this in viewDidLoad() (or set in Storyboard):
[emailTextField, websiteTextField].forEach {
if let tf = $0 {
tf.autocorrectionType = .no
tf.spellCheckingType = .no
}
}
Your example is looking for "email" and "website" entries, so you probably don't want/need those anyway.
It's fixed at iOS 16.1 Beta 4 ✅
There is a weird crash that only happens in iOS 16. When I try to create a TabView with page style, it's crashing when the array is empty. But it's working perfectly fine in iOS 15. Is this an iOS 16 bug?
Xcode version: Version 14.0 (14A309)
iOS Version: 16.0 & 16.1 Beta
struct TestView: View {
#State private var data: [Int] = []
var body: some View {
TabView {
ForEach(0..<data.count, id: \.self) { index in
RoundedRectangle(cornerRadius: 12)
}
}
.frame(height: 200)
.tabViewStyle(.page(indexDisplayMode: .never))
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.data = [1,2,3,4]
}
}
}
}
Crash Log
2022-10-04 18:01:56.275879+0300 TestFirebaseCrash[24331:486169] *** Assertion failure in -[_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF020PagingCollectionView _validateScrollingTargetIndexPath:], UICollectionView.m:7339
2022-10-04 18:01:56.278900+0300 TestFirebaseCrash[24331:486169] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to scroll the collection view to an out-of-bounds item (0) when there are only 0 items in section 0. Collection view: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF020PagingCollectionView: 0x140841e00; baseClass = UICollectionView; frame = (0 0; 428 200); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600001d8d260>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x600001386d20>; contentOffset: {0, 0}; contentSize: {0, 200}; adjustedContentInset: {0, 0, 0, 0}; layout: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF012PagingLayout: 0x140514090>; dataSource: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF011Coordinator: 0x6000021f46c0>>.'
*** First throw call stack:
(
0 CoreFoundation 0x000000018040c304 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x000000018005131c objc_exception_throw + 56
2 Foundation 0x0000000180b11f88 _userInfoForFileAndLine + 0
3 UIKitCore 0x00000001032279a8 -[UICollectionView _validateScrollingTargetIndexPath:] + 408
4 UIKitCore 0x0000000103227cc0 -[UICollectionView _contentOffsetForScrollingToItemAtIndexPath:atScrollPosition:] + 48
5 UIKitCore 0x0000000103228838 -[UICollectionView _scrollToItemAtIndexPath:atScrollPosition:animated:] + 220
6 SwiftUI 0x0000000106f5de08 OUTLINED_FUNCTION_15 + 18076
7 SwiftUI 0x0000000106f5dea8 OUTLINED_FUNCTION_15 + 18236
8 SwiftUI 0x0000000106f5dc88 OUTLINED_FUNCTION_15 + 17692
9 SwiftUI 0x0000000106f5dcf4 OUTLINED_FUNCTION_15 + 17800
10 UIKitCore 0x0000000103ea214c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1920
11 QuartzCore 0x0000000187ed749c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 440
12 QuartzCore 0x0000000187ee1f54 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 128
13 QuartzCore 0x0000000187e117d0 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 452
14 QuartzCore 0x0000000187e3d47c _ZN2CA11Transaction6commitEv + 652
15 UIKitCore 0x0000000103a257f0 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
16 CoreFoundation 0x0000000180370e38 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
17 CoreFoundation 0x0000000180370580 __CFRunLoopDoBlocks + 364
18 CoreFoundation 0x000000018036ae7c __CFRunLoopRun + 776
19 CoreFoundation 0x000000018036a75c CFRunLoopRunSpecific + 584
20 GraphicsServices 0x0000000188f60c98 GSEventRunModal + 160
21 UIKitCore 0x0000000103a0cb74 -[UIApplication _run] + 868
22 UIKitCore 0x0000000103a10b1c UIApplicationMain + 124
23 SwiftUI 0x0000000107702130 OUTLINED_FUNCTION_51 + 496
24 SwiftUI 0x0000000107701fd8 OUTLINED_FUNCTION_51 + 152
25 SwiftUI 0x0000000106ee5894 OUTLINED_FUNCTION_10 + 88
26 TestFirebaseCrash 0x000000010269ec6c $s17TestFirebaseCrash0abC3AppV5$mainyyFZ + 40
27 TestFirebaseCrash 0x000000010269ed14 main + 12
28 dyld 0x00000001028e9fa0 start_sim + 20
29 ??? 0x00000001029bd08c 0x0 + 4338733196
30 ??? 0x1a00000000000000 0x0 + 1873497444986126336
)
libc++abi: terminating with uncaught exception of type NSException
terminating with uncaught exception of type NSException
CoreSimulator 857.10 - Device: iPhone 13 Pro Max (29ECC9E3-B223-4591-A18A-1C858F528C45) - Runtime: iOS 16.0 (20A360) - DeviceType: iPhone 13 Pro Max
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to scroll the collection view to an out-of-bounds item (0) when there are only 0 items in section 0. Collection view: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF020PagingCollectionView: 0x140841e00; baseClass = UICollectionView; frame = (0 0; 428 200); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600001d8d260>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x600001386d20>; contentOffset: {0, 0}; contentSize: {0, 200}; adjustedContentInset: {0, 0, 0, 0}; layout: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF012PagingLayout: 0x140514090>; dataSource: <_TtC7SwiftUIP33_8825076C2763A50452A210CBE1FA4AF011Coordinator: 0x6000021f46c0>>.'
(lldb)
Try returning Text("") (basically an empty view) if data is empty.
TabView {
if data.isEmpty {
Text("")
} else {
ForEach(data, id: \.self) { _ in
RoundedRectangle(cornerRadius: 12)
}
}
}
It looks like it's fixed at iOS 16.1 Beta 4 ✅
Working on iOS12 and prior, but crashes on iOS13 with this error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UISearchController's control over its search bar has been destroyed. Please use the search bar provided by the UISearchController. searchController = <AdvancedSearchController: 0x7fbd9d224a00>, searchBar = <TDSearchBar: 0x7fbd9b768480; baseClass = UISearchBar; frame = (0 0; 1024 50); text = ''; gestureRecognizers = <NSArray: 0x600002791770>; layer = <CALayer: 0x600002ef9be0>>'
How con i solve? What does this exception mean?
*** First throw call stack:
(
0 CoreFoundation 0x000000010e296c3e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x000000010e104de0 objc_exception_throw + 48
2 CoreFoundation 0x000000010e296a7c +[NSException raise:format:] + 188
3 UIKitCore 0x000000011fa6e6b0 -[UISearchController _animatorForBarPresentationStyle:dismissing:] + 185
4 UIKitCore 0x000000011fa6eb24 -[UISearchController animationControllerForPresentedController:presentingController:sourceController:] + 34
5 UIKitCore 0x000000011f3a03a0 -[UIViewController _customAnimatorForPresentedController:presentingController:sourceController:] + 154
6 UIKitCore 0x000000011f3a4534 -[UIViewController _presentViewController:withAnimationController:completion:] + 4472
7 UIKitCore 0x000000011f3a6d1b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
8 UIKitCore 0x000000011f3a7233 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
9 UIKitCore 0x000000011f3a6c79 -[UIViewController _presentViewController:animated:completion:] + 187
10 UIKitCore 0x000000011f3a6ee0 -[UIViewController presentViewController:animated:completion:] + 150
Solved. You cannot neither subclass UISearchBar in UISearchController...at least in beta 3.
Note: please don't mark this question as a duplicate, as I've searched the other similar questions but they are slightly different.
After submitting my app for review, it was rejected after it crashed on the app's first screen on an iPad Mini (iOS 11.2). This screen is just a basic registration page, and the app has never been rejected during review any time previously (and the page wasn't recently updated either). Unfortunately I don't have an iPad Mini, and I haven't experienced any crash in my simulator or physical iPhone devices.
Here is the reason for the crash (from what I've gathered, its most likely due to trying to access a variable that no longer exists in memory):
Exception Type: EXC_BAD_ACCESS (SIGKILL)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000020
And here is the thread that crashed:
Thread 0 name: tid_303 Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001820fc1a0 objc_retain + 16 (objc-object.h:440)
1 AXRuntime 0x000000019249ee00 _AXElementForAXUIElementUniqueId + 208 (AXSimpleRuntimeManager.m:0)
2 AXRuntime 0x000000019249ed08 _UIAXElementForAXUIElementRef + 48 (AXSimpleRuntimeManager.m:402)
3 UIAccessibility 0x000000019427ae98 -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotDescendantsWithAttributes:maxDepth:maxChildren:maxArrayCount:] + 1444 (UIAccessibilityAutomation.m:593)
4 UIAccessibility 0x000000019427cf08 -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotWithOptions:] + 640 (UIAccessibilityAutomation.m:779)
5 UIAccessibility 0x0000000194250268 -[NSObject(AXPrivCategory) accessibilityAttributeValue:forParameter:] + 8836 (NSObjectAccessibility.m:4304)
6 UIAccessibility 0x000000019422fc80 _copyParameterizedAttributeValueCallback + 224 (UIAccessibilityRuntime.m:752)
7 AXRuntime 0x00000001924a6ad0 ___AXXMIGCopyParameterizedAttributeValue_block_invoke + 100 (AccessibilityPriv.m:1128)
8 AXRuntime 0x00000001924a6238 _handleNonMainThreadCallback + 60 (AccessibilityPriv.m:363)
9 AXRuntime 0x00000001924a6924 _AXXMIGCopyParameterizedAttributeValue + 344 (AccessibilityPriv.m:1127)
10 AXRuntime 0x00000001924a1220 _XCopyParameterizedAttributeValue + 380 (AccessibilityClientDefsServer.c:1160)
11 AXRuntime 0x00000001924b328c mshMIGPerform + 252 (MachServerHelper.c:448)
12 CoreFoundation 0x0000000182e3fe00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56 (CFRunLoop.c:1998)
13 CoreFoundation 0x0000000182e3f504 __CFRunLoopDoSource1 + 440 (CFRunLoop.c:2135)
14 CoreFoundation 0x0000000182e3cfd8 __CFRunLoopRun + 2196 (CFRunLoop.c:3150)
15 CoreFoundation 0x0000000182d5cc58 CFRunLoopRunSpecific + 436 (CFRunLoop.c:3245)
16 GraphicsServices 0x0000000184c08f84 GSEventRunModal + 100 (GSEvent.c:2245)
17 UIKit 0x000000018c4b55c4 UIApplicationMain + 236 (UIApplication.m:3956)
18 MyAppiOS 0x0000000102346db0 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 16494000 (/<unknown>:1)
19 MyAppiOS 0x00000001022b764c UIKit_UIApplication_Main_string___intptr_intptr + 15906380 (UIApplication.cs:79)
20 MyAppiOS 0x00000001022b760c UIKit_UIApplication_Main_string___string_string + 15906316 (UIApplication.cs:63)
21 MyAppiOS 0x00000001013bfc84 MyApp_iOS_Application_Main_string__ + 212100 (/<unknown>:1)
22 MyAppiOS 0x00000001016fd204 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
23 MyAppiOS 0x0000000103297148 mono_jit_runtime_invoke + 32551240 (mini-runtime.c:2768)
24 MyAppiOS 0x00000001032fe574 do_runtime_invoke + 32974196 (object.c:2862)
25 MyAppiOS 0x00000001033010e4 do_exec_main_checked + 32985316 (object.c:4690)
26 MyAppiOS 0x000000010327fb90 mono_jit_exec + 32455568 (driver.g.c:1036)
27 MyAppiOS 0x0000000103392da8 xamarin_main + 33582504 (monotouch-main.m:0)
28 MyAppiOS 0x00000001013bf178 main + 209272 (main.m:203)
29 libdyld.dylib 0x000000018287c56c start + 4
And then there are thousands of lines similar to these in the symbolicated crash log:
UIAccessibility: Trying pt: {660.00001764298941, 512.00013971327644}
UIAccessibility: Hit testing found: UIAccessibilityPickerComponent [0x127e7cba0] (null) {{0, 514.5}, {1024, 291}}
UIAccessibility: Is descendant of desired element
UIAccessibility: Received visible point {512, 660} for <UIPickerView: 0x1279d5da0; frame = (0 99; 1024 216); clipsToBounds = YES; layer = <CALayer: 0x1279d5d70>>
UIAccessibility: Checking visibility for UIAccessibilityPickerComponent [0x127e7cba0] (null) {{0, 514.5}, {1024, 291}}
UIAccessibility: Trying pt: {660.00001764298941, 512.00013971327644}
UIAccessibility: Element matched start element
UIAccessibility: Received visible point {512, 660} for UIAccessibilityPickerComponent [0x127e7cba0] (null) {{0, 514.5}, {1024, 291}}
UIAccessibility: Did post notification. notification: (4002) error:0 data:{
event = AnimationsNonActive;
}
UIAccessibility: Did post notification. notification: (4002) error:0 data:{
event = RunLoopIsIdle;
}
UIKit: NavBar: set identifier (null) <UINavigationBar: 0x1279ad2f0; frame = (0 20; 1024 96); autoresize = W; tintColor = UIExtendedSRGBColorSpace 0 0.478431 1 1; layer = <CALayer: 0x1279a4490>>
UIKit: NavBar: top most item <<UINavigationItem: 0x127b9ab00>: title:'Register'> <UINavigationBar: 0x1279ad2f0; frame = (0 20; 1024 96); autoresize = W; tintColor = UIExtendedSRGBColorSpace 0 0.478431 1 1; layer = <CALayer: 0x1279a4490>>
// Note: the line above is the last line that is shown, before showing the crashed thread information
I really don't know what to make of this log. I even checked any other callback methods that may be taking place during the time the first screen is shown, but I just can't figure it out (especially when I can't even get it to crash on my end). Any help would be really appreciated.
This code is in the initialization for a subclass of a UIView object. The UIView is circular in shape and displays a percentChange value using a nested UILabel. The following code resizes the UILabel and the font size to fit the text in the UIView. percentChange is some Int.
let stringAttrs: NSMutableDictionary = [NSFontAttributeName: stringFont, NSForegroundColorAttributeName: self.GreenColor]
if percentChange > 0 {
self.layer.borderColor = self.GreenColor.CGColor
stringAttrs.setValue(self.GreenColor, forKey: NSForegroundColorAttributeName)
indicator = ""
}
else if percentChange < 0 {
self.layer.borderColor = UIColor.redColor().CGColor
stringAttrs.setValue(UIColor.redColor().CGColor, forKey: NSForegroundColorAttributeName)
indicator = "▼"
}
else {
self.layer.borderColor = UIColor.grayColor().CGColor
stringAttrs.setValue(UIColor.grayColor().CGColor, forKey: NSForegroundColorAttributeName)
indicator = ""
}
do {
fontPointSize -= 0.5
stringFont = UIFont(name: "AmericanTypewriter", size: fontPointSize)!
stringAttrs.setValue(stringFont, forKey: NSFontAttributeName)
percentChangeLabel.attributedText = NSAttributedString(string: "\(indicator)\(abs(Int(percentChange)))%", attributes: stringAttrs)
percentChangeLabel.sizeToFit()
} while percentChangeLabel.frame.width > (self.frame.width - PaddingLeft - PaddingRight)
The three conditionals set indicator with "▲" (percentChange > 0), "▼" (percentChange < 0), or "" (percentChange == 0). Heres the bizarre thing, the app will only crash if percentChange is 0 and if indicator != "▲" or != "▼". If I change indicator to be "▼" or "▲" in the else statement, the app works fine. Every other character/string I have tried so far results in the same crash. Setting indicator to "" for percentChange > 0 or percentChange < 0 also does not cause any problems. I have attached the crash log and was hoping if someone could help me figure out whats going on, or perhaps guide me in the right direction.
2014-11-04 22:09:48.208 Cassandra[796:11817] -[__NSCFType set]: unrecognized selector sent to instance 0x7ff951b475f0
2014-11-04 22:09:48.210 Cassandra[796:11817] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType set]: unrecognized selector sent to instance 0x7ff951b475f0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010937af35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b36fbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010938204d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001092da27c ___forwarding___ + 988
4 CoreFoundation 0x00000001092d9e18 _CF_forwarding_prep_0 + 120
5 UIFoundation 0x000000010f42dcf3 __NSStringDrawingEngine + 28766
6 UIFoundation 0x000000010f42e1ec -[NSAttributedString(NSExtendedStringDrawing) drawWithRect:options:context:] + 561
7 UIKit 0x000000010a282a4c -[UILabel _drawTextInRect:baselineCalculationOnly:] + 5549
8 UIKit 0x000000010a280cab -[UILabel drawTextInRect:] + 624
9 UIKit 0x000000010a282c60 -[UILabel drawRect:] + 100
10 UIKit 0x000000010a130569 -[UIView(CALayerDelegate) drawLayer:inContext:] + 496
11 QuartzCore 0x0000000109f42942 -[CALayer drawInContext:] + 113
12 QuartzCore 0x0000000109e3fd5b CABackingStoreUpdate_ + 2793
13 QuartzCore 0x0000000109f42851 ___ZN2CA5Layer8display_Ev_block_invoke + 59
14 QuartzCore 0x0000000109f426e9 _ZN2CA5Layer8display_Ev + 1469
15 QuartzCore 0x0000000109f37801 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 301
16 QuartzCore 0x0000000109f37889 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35
17 QuartzCore 0x0000000109ea563e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
18 QuartzCore 0x0000000109ea674a _ZN2CA11Transaction6commitEv + 390
19 QuartzCore 0x0000000109ea6db5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
20 CoreFoundation 0x00000001092afdc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
21 CoreFoundation 0x00000001092afd20 __CFRunLoopDoObservers + 368
22 CoreFoundation 0x00000001092a5b53 __CFRunLoopRun + 1123
23 CoreFoundation 0x00000001092a5486 CFRunLoopRunSpecific + 470
24 GraphicsServices 0x000000010e05e9f0 GSEventRunModal + 161
25 UIKit 0x000000010a0b7420 UIApplicationMain + 1282
26 Cassandra 0x0000000108da8ade top_level_code + 78
27 Cassandra 0x0000000108da8b1a main + 42
28 libdyld.dylib 0x000000010bb49145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Update: The UIView above is nested in a subclass of UITableCellView which is being added to a UITableView. It seems that the crash occurs consistently after the last UITableViewCell is added.
I still don't know whats wrong, but I circumvented the problem by using the UILabel properties to set the text, font and textColor instead of using an attributedText string.
I don't use this function: stringAttrs.setValue(stringFont, forKey: NSFontAttributeName)
Don't set the font like you did. Look at this example:
let stringFont = [NSFontAttributeName:UIFont(name: "AmericanTypewriter", size: 18.0)]
let stringAttrs= NSAttributedString(string: "Hello Swift! This is a tutorial looking at ", attributes:textFont)
Look at this link for usage: http://sketchytech.blogspot.com/2014/08/swift-creating-styled-and-attributed.html