App Store crash report EXC_BREAKPOINT (SIGTRAP) - ios

Below is the crash report downloaded from iTunes Connect, Apple guys says "We were unable to review your app as it crashed on launch".
i know 'EXC_BREAKPOINT (SIGTRAP)' means a non-optional type with a nil value or a failed forced type conversion, i checked the row 0, 1, 2 and 41 concerned about my app's property, new installed, and try updated from old version, all on real device, everything works fine, no crash happens. i've no idea where is the crash kicked?
it's very helpful you can give some me advice. thank you very much!!!
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000101066d5c
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 Cloud 0x0000000101066d5c specialized static ContentViewController.iphone.getter + 388444 (ContentViewController.swift:20)
1 Cloud 0x0000000101049584 specialized PageViewController.init(coder:) + 267652 (PageViewController.swift:16)
2 Cloud 0x000000010104657c #objc PageViewController.init(coder:) + 255356 (PageViewController.swift:0)
3 UIKit 0x000000018acee8bc -[UIClassSwapper initWithCoder:] + 248
4 UIKit 0x000000018ae97588 UINibDecoderDecodeObjectForValue + 688
5 UIKit 0x000000018ae972c0 -[UINibDecoder decodeObjectForKey:] + 104
6 UIKit 0x000000018acee560 -[UIRuntimeConnection initWithCoder:] + 188
7 UIKit 0x000000018ae97588 UINibDecoderDecodeObjectForValue + 688
8 UIKit 0x000000018ae97700 UINibDecoderDecodeObjectForValue + 1064
9 UIKit 0x000000018ae972c0 -[UINibDecoder decodeObjectForKey:] + 104
10 UIKit 0x000000018aced8a0 -[UINib instantiateWithOwner:options:] + 1168
11 UIKit 0x000000018b06a7f0 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 196
12 UIKit 0x000000018a9d08dc -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 124
13 UIKit 0x000000018a7d6cdc -[UIApplication _loadMainInterfaceFile] + 264
14 UIKit 0x000000018a9cf5c0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1420
15 UIKit 0x000000018ac5d454 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 800
16 UIKit 0x000000018af2d1f0 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
17 UIKit 0x000000018ac5d0b8 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 252
18 UIKit 0x000000018ac5d928 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 748
19 UIKit 0x000000018b3c66e8 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 260
20 UIKit 0x000000018b3c658c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 448
21 UIKit 0x000000018b1429c0 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
22 UIKit 0x000000018b2d7fc8 _performActionsWithDelayForTransitionContext + 112
23 UIKit 0x000000018b142870 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 252
24 UIKit 0x000000018af2c850 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 364
25 UIKit 0x000000018a9cde28 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
26 UIKit 0x000000018add16ec -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364
27 FrontBoardServices 0x00000001839f9768 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364
28 FrontBoardServices 0x0000000183a02070 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224
29 libdispatch.dylib 0x0000000180cdd048 _dispatch_client_callout + 16
30 libdispatch.dylib 0x0000000180ce46c8 _dispatch_block_invoke_direct$VARIANT$mp + 288
31 FrontBoardServices 0x0000000183a2da04 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
32 FrontBoardServices 0x0000000183a2d6a8 -[FBSSerialQueue _performNext] + 404
33 FrontBoardServices 0x0000000183a2dc44 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
34 CoreFoundation 0x0000000181300358 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
35 CoreFoundation 0x00000001813002d8 __CFRunLoopDoSource0 + 88
36 CoreFoundation 0x00000001812ffb60 __CFRunLoopDoSources0 + 204
37 CoreFoundation 0x00000001812fd738 __CFRunLoopRun + 1048
38 CoreFoundation 0x000000018121e2d8 CFRunLoopRunSpecific + 436
39 GraphicsServices 0x00000001830aff84 GSEventRunModal + 100
40 UIKit 0x000000018a7cb880 UIApplicationMain + 208
41 Cloud 0x0000000101010e04 main + 36356 (SearchTableViewController.swift:13)
42 libdyld.dylib 0x0000000180d4256c start + 4
the following is the code for static ContentViewController.iphone.getter:
defined in common.swift:
enum iPhone: CGFloat {
case iPhoneSE = 568
case iPhone = 667
case iPhonePlus = 736
case iPhoneX = 812
init!(_ rawValue: CGFloat) {
self.init(rawValue: rawValue)
}
}
defined in ContentViewController.swift:
static var iphone: iPhone {
let sceneHeight: CGFloat = UIScreen.main.bounds.height
if iPhone(sceneHeight) == .iPhoneSE {
return .iPhoneSE
} else if iPhone(sceneHeight) == .iPhone {
return .iPhone
} else if iPhone(sceneHeight) == .iPhonePlus {
return .iPhonePlus
} else {
return .iPhoneX
}
}

init!(_ rawValue: CGFloat) {
self.init(rawValue: rawValue) }
You use here force unwrapped init but you have cases where enum can return nil if no cases corresponds with the passed value. It can be iPad (768) or iPhone 4s (480). So you are unwrapping nil and system throws an exception.

Related

Crash in presenting a view controller

My application crashes while trying to present a view controller. It only seems to happen in the device but not in the simulator.
Also do I need to disable the breakpoints before archiving the build for TestFlight?
Here is the crash log:
Incident Identifier: E8E38296-EB9E-47FD-AC91-DC6231A32CE2
Beta Identifier: C0074033-1ABA-4888-9906-B0E709FDC0D5
Hardware Model: iPhone10,6
Process: Darb [6943]
Path: /private/var/containers/Bundle/Application/134E7292-FC58-4A08-9C73-E5B27C8BE5D2/Darb.app/Darb
Identifier: com.dot.Darb
Version: 7 (3.6.14)
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.dot.Darb [2421]
Date/Time: 2018-07-23 10:51:48.2281 +0400
Launch Time: 2018-07-23 10:51:44.0025 +0400
OS Version: iPhone OS 11.2.6 (15D100)
Baseband Version: 1.03.06
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x183c2b164 __exceptionPreprocess + 124 (NSException.m:166)
1 libobjc.A.dylib 0x182e74528 objc_exception_throw + 56 (objc-exception.mm:521)
2 CoreFoundation 0x183c2ae2c -[NSException raise] + 12 (NSException.m:98)
3 Foundation 0x184542630 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 272 (NSKeyValueCoding.m:418)
4 UIKit 0x18d551134 -[UIViewController setValue:forKey:] + 104 (UIViewController.m:1275)
5 UIKit 0x18d779224 -[UIRuntimeOutletConnection connect] + 124 (UIRuntimeOutletConnection.m:17)
6 CoreFoundation 0x183b37d14 -[NSArray makeObjectsPerformSelector:] + 284 (NSArray.m:497)
7 UIKit 0x18d777c18 -[UINib instantiateWithOwner:options:] + 1696 (UINib.m:0)
8 UIKit 0x18d554be0 -[UIViewController _loadViewFromNibNamed:bundle:] + 372 (UIViewController.m:2866)
9 UIKit 0x18d3028e8 -[UIViewController loadView] + 176 (UIViewController.m:2995)
10 UIKit 0x18d1e56a8 -[UIViewController loadViewIfRequired] + 184 (UIViewController.m:3094)
11 UIKit 0x18d1e55d8 -[UIViewController view] + 28 (UIViewController.m:3155)
12 UIKit 0x18dd8ed24 -[_UIFullscreenPresentationController _setPresentedViewController:] + 92 (_UIFullscreenPresentationController.m:232)
13 UIKit 0x18d52da18 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 140 (UIPresentationController.m:81)
14 UIKit 0x18d55e84c -[UIViewController _presentViewController:withAnimationController:completion:] + 2676 (UIViewController.m:7081)
15 UIKit 0x18d56188c __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2 + 68 (UIViewController.m:7543)
16 UIKit 0x18d1f392c +[UIView(Animation) performWithoutAnimation:] + 104 (UIView.m:11877)
17 UIKit 0x18d5617e0 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 220 (UIViewController.m:7541)
18 UIKit 0x18d561ca0 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 528 (UIViewController.m:7621)
19 UIKit 0x18d5616bc -[UIViewController _presentViewController:animated:completion:] + 188 (UIViewController.m:7552)
20 UIKit 0x18d2c32d0 -[UIViewController presentViewController:animated:completion:] + 160 (UIViewController.m:7565)
21 Darb 0x1025fdd7c MainViewController.viewDidLoad() + 5940 (MainViewController.swift:320)
22 Darb 0x1025ff3c0 #objc MainViewController.viewDidLoad() + 28 (MainViewController.swift:0)
23 UIKit 0x18d1e5a00 -[UIViewController loadViewIfRequired] + 1040 (UIViewController.m:3133)
24 UIKit 0x18d28ceb8 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 76 (UINavigationController.m:6345)
25 UIKit 0x18d28c358 -[UINavigationController _startTransition:fromViewController:toViewController:] + 196 (UINavigationController.m:6380)
26 UIKit 0x18d28bd5c -[UINavigationController _startDeferredTransitionIfNeeded:] + 1168 (UINavigationController.m:6601)
27 UIKit 0x18d28b7d8 -[UINavigationController __viewWillLayoutSubviews] + 164 (UINavigationController.m:6872)
28 UIKit 0x18d28b6d8 -[UILayoutContainerView layoutSubviews] + 188 (UILayoutContainerView.m:87)
29 UIKit 0x18d1e2e18 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1276 (UIView.m:15124)
30 QuartzCore 0x187c6f948 -[CALayer layoutSublayers] + 184 (CALayer.mm:9302)
31 QuartzCore 0x187c73ad0 CA::Layer::layout_if_needed(CA::Transaction*) + 332 (CALayer.mm:9182)
32 QuartzCore 0x187be031c CA::Context::commit_transaction(CA::Transaction*) + 336 (CALayer.mm:2416)
33 QuartzCore 0x187c07b40 CA::Transaction::commit() + 540 (CATransactionInternal.mm:425)
34 UIKit 0x18d45eb6c __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 140 (UIApplication.m:9904)
35 CoreFoundation 0x183bd3590 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20 (CFRunLoop.c:1840)
36 CoreFoundation 0x183bd2e60 __CFRunLoopDoBlocks + 288 (CFRunLoop.c:1881)
37 CoreFoundation 0x183bd0b70 __CFRunLoopRun + 1068 (CFRunLoop.c:2922)
38 CoreFoundation 0x183af0c58 CFRunLoopRunSpecific + 436 (CFRunLoop.c:3245)
39 GraphicsServices 0x18599cf84 GSEventRunModal + 100 (GSEvent.c:2245)
40 UIKit 0x18d2495c4 UIApplicationMain + 236 (UIApplication.m:3956)
41 Darb 0x1025b1064 main + 56 (AppDelegate.swift:19)
42 libdyld.dylib 0x18361056c start + 4
Could some one please look into the logs and point me in the right direction?
following is the code which crash log points to
let lastLaunch = Foundation.UserDefaults.standard.double(forKey: "lastLaunch")
let lastLaunchDate = Date(timeIntervalSince1970: lastLaunch)
let lastLaunchIsToday = Calendar.current.isDateInToday(lastLaunchDate)
if !lastLaunchIsToday {
// Show the GIF
let zayedVC: ZayedVideoViewController = self.storyboard?.instantiateViewController(withIdentifier: "ZayedVC") as! ZayedVideoViewController
zayedVC.providesPresentationContextTransitionStyle = true
zayedVC.definesPresentationContext = true
zayedVC.isModalInPopover = true
zayedVC.modalPresentationStyle = .overFullScreen
self.navigationController?.present(zayedVC, animated: false, completion: nil)
}
Foundation.UserDefaults.standard.set(Date().timeIntervalSince1970, forKey: "lastLaunch")
Alright,
I have managed to solve the problem,the issue i had is the broken outlet connection.
I have removed it from the storyboard and it worked fine

Decipher the iOS crashlog. The program crashes at layoutIfNeeded

I've got crash logs for my app from App Store. I'm not able to reproduce the crash and having a hard time deciphering it.
Following is the log -
Incident Identifier: AEF0FFDD-77E4-460F-97E4-B97A32EAE36D
CrashReporter Key: 78177aeeda1175c67f4467d02c023a2a165d1a01
Hardware Model: iPhone7,1
Process: Visits [4558]
Path: /private/var/containers/Bundle/Application/81AC75BC-433C-43E7-887D-8FC6BF5B5703/Visits.app/Visits
Identifier: com.x.y
Version: 1.1.1 (1.1.1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.x.y [1143]
Date/Time: 2018-07-20 22:30:36.6608 +0530
Launch Time: 2018-07-20 22:30:35.9017 +0530
OS Version: iPhone OS 11.4.1 (15G77)
Baseband Version: 6.80.00
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x184136d8c __exceptionPreprocess + 228 (NSException.m:166)
1 libobjc.A.dylib 0x1832f05ec objc_exception_throw + 56 (objc-exception.mm:521)
2 CoreFoundation 0x1840cfd80 -[__NSSingleObjectArrayI objectAtIndex:] + 128 (NSSingleObjectArray.m:16)
3 UIKit 0x18e6b0aa8 -[UITableViewDataSource tableView:cellForRowAtIndexPath:] + 172 (UITableViewDataSource.m:170)
4 UIKit 0x18e3c90f4 -[UITableViewController tableView:cellForRowAtIndexPath:] + 68 (UITableViewController.m:441)
5 UIKit 0x18de130cc -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 668 (UITableView.m:13463)
6 UIKit 0x18de12d84 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80 (UITableView.m:13514)
7 UIKit 0x18de11aa0 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2280 (UITableView.m:2599)
8 UIKit 0x18de0d5ec -[UITableView layoutSubviews] + 140 (UITableView.m:8565)
9 UIKit 0x18dd4a6f4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1420 (UIView.m:15239)
10 QuartzCore 0x1882bfe54 -[CALayer layoutSublayers] + 184 (CALayer.mm:9357)
11 QuartzCore 0x1882c3fe4 CA::Layer::layout_if_needed(CA::Transaction*) + 324 (CALayer.mm:9237)
12 UIKit 0x18dd62bf4 -[UIView(Hierarchy) layoutBelowIfNeeded] + 548 (UIView.m:10438)
13 Visits 0x1007a8300 MainViewController.initialSetupForScreen() + 804 (MainViewController.swift:217)
14 Visits 0x1007a7ea4 MainViewController.viewDidLoad() + 924 (MainViewController.swift:175)
15 Visits 0x1007a8838 #objc MainViewController.viewDidLoad() + 28
16 UIKit 0x18dd51e64 -[UIViewController loadViewIfRequired] + 1020 (UIViewController.m:3192)
17 UIKit 0x18dd51a50 -[UIViewController view] + 28 (UIViewController.m:3214)
18 UIKit 0x18dd42ce4 -[UIWindow addRootViewControllerViewIfPossible] + 136 (UIWindow.m:1358)
19 UIKit 0x18dd41b18 -[UIWindow _setHidden:forced:] + 272 (UIWindow.m:1455)
20 UIKit 0x18ddcf62c -[UIWindow makeKeyAndVisible] + 48 (UIWindow.m:4883)
21 UIKit 0x18dd45274 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3660 (UIApplication.m:2210)
22 UIKit 0x18dd125e0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1680 (UIApplication.m:3491)
23 UIKit 0x18e342b1c __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 784 (_UICanvasLifecycleMonitor.m:175)
24 UIKit 0x18dd11dd0 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160 (_UICanvas.m:591)
25 UIKit 0x18dd11c6c -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 240 (_UICanvasLifecycleMonitor.m:153)
26 UIKit 0x18dd10afc -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 724 (_UICanvasLifecycleMonitor.m:229)
27 UIKit 0x18e9a684c __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 296 (_UIApplicationCanvas.m:0)
28 UIKit 0x18dd101ec -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 432 (_UIApplicationCanvas.m:156)
29 UIKit 0x18e78bac8 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220 (_UICanvasLifecycleSettingsDiffAction.m:211)
30 UIKit 0x18e8d9bf8 _performActionsWithDelayForTransitionContext + 112 (_UICanvasSettingsDiffAction.m:34)
31 UIKit 0x18dd0fc0c -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 248 (_UICanvasLifecycleSettingsDiffAction.m:182)
32 UIKit 0x18dd0f5a8 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 368 (_UICanvas.m:517)
33 UIKit 0x18dd0c5e0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540 (UIApplication.m:3109)
34 UIKit 0x18dd0c330 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364 (UIApplicationSceneClientAgent.m:41)
35 FrontBoardServices 0x186938470 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364 (FBSSceneImpl.m:460)
36 FrontBoardServices 0x186940d6c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224 (FBSWorkspace.m:606)
37 libdispatch.dylib 0x183a28a60 _dispatch_client_callout + 16 (object.m:507)
38 libdispatch.dylib 0x183a30170 _dispatch_block_invoke_direct$VARIANT$mp + 224 (queue.c:3018)
39 FrontBoardServices 0x18696c878 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:164)
40 FrontBoardServices 0x18696c51c -[FBSSerialQueue _performNext] + 404 (FBSSerialQueue.m:196)
41 FrontBoardServices 0x18696cab8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:232)
42 CoreFoundation 0x1840df404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1982)
43 CoreFoundation 0x1840dec2c __CFRunLoopDoSources0 + 276 (CFRunLoop.c:2017)
44 CoreFoundation 0x1840dc79c __CFRunLoopRun + 1204 (CFRunLoop.c:2920)
45 CoreFoundation 0x183ffcda8 CFRunLoopRunSpecific + 552 (CFRunLoop.c:3245)
46 GraphicsServices 0x185fe2020 GSEventRunModal + 100 (GSEvent.c:2245)
47 UIKit 0x18e01c758 UIApplicationMain + 236 (UIApplication.m:3965)
48 Visits 0x1007a589c main + 56 (Location+CoreDataClass.swift:15)
49 libdyld.dylib 0x183a8dfc0 start + 4
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000183bbd2e0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x0000000183d5e288 pthread_kill$VARIANT$mp + 376 (pthread.c:1484)
2 libsystem_c.dylib 0x0000000183b2bd0c abort + 140 (abort.c:91)
3 libc++abi.dylib 0x00000001832c72c8 abort_message + 132 (abort_message.cpp:75)
4 libc++abi.dylib 0x00000001832c7470 default_terminate_handler() + 304 (cxa_default_handlers.cpp:68)
5 libobjc.A.dylib 0x00000001832f08d4 _objc_terminate() + 124 (objc-exception.mm:657)
6 libc++abi.dylib 0x00000001832e137c std::__terminate(void (*)()) + 16 (cxa_handlers.cpp:66)
7 libc++abi.dylib 0x00000001832e1400 std::terminate() + 84 (cxa_handlers.cpp:97)
8 libdispatch.dylib 0x0000000183a28a74 _dispatch_client_callout + 36 (object.m:510)
9 libdispatch.dylib 0x0000000183a30170 _dispatch_block_invoke_direct$VARIANT$mp + 224 (queue.c:3018)
10 FrontBoardServices 0x000000018696c878 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:164)
11 FrontBoardServices 0x000000018696c51c -[FBSSerialQueue _performNext] + 404 (FBSSerialQueue.m:196)
12 FrontBoardServices 0x000000018696cab8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:232)
13 CoreFoundation 0x00000001840df404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1982)
14 CoreFoundation 0x00000001840dec2c __CFRunLoopDoSources0 + 276 (CFRunLoop.c:2017)
15 CoreFoundation 0x00000001840dc79c __CFRunLoopRun + 1204 (CFRunLoop.c:2920)
16 CoreFoundation 0x0000000183ffcda8 CFRunLoopRunSpecific + 552 (CFRunLoop.c:3245)
17 GraphicsServices 0x0000000185fe2020 GSEventRunModal + 100 (GSEvent.c:2245)
18 UIKit 0x000000018e01c758 UIApplicationMain + 236 (UIApplication.m:3965)
19 Visits 0x00000001007a589c main + 56 (Location+CoreDataClass.swift:15)
20 libdyld.dylib 0x0000000183a8dfc0 start + 4
Following is the code snippet where the program crashes. The crash happens at the self.view.layoutIfNeeded().
func initialSetupForScreen(){
let screenHeight = UIScreen.main.bounds.height
let statusBarHeight = UIApplication.shared.statusBarFrame.height
fullyOpenSheetTop = -(screenHeight - (statusBarHeight * 2))
partiallyOpenSheetTop = -((screenHeight * 0.50) - titleBarHeight)
closedSheetTop = -titleBarHeight
notVisibleSheetTop = 40 //(+40 for iphone X)
fullyOrPartiallyThreshold = (fullyOpenSheetTop + partiallyOpenSheetTop)/2
partiallyOrClosedThreshold = (partiallyOpenSheetTop + closedSheetTop)/2
// set primary & secondary sheet height //(+40 for iphone X) (-40 fixed for iphone X)
primarySheetViewHeightConstraint.constant = -fullyOpenSheetTop
secondarySheetViewHeightConstraint.constant = -fullyOpenSheetTop
// primary sheet is set to fully open state
primarySheetViewTopConstraint.constant = fullyOpenSheetTop
primarySheetCurrentState = .fullyOpen
// secondary sheet is set to not visible state
secondarySheetViewTopConstraint.constant = notVisibleSheetTop
secondarySheetCurrentState = .notVisible
// settings View move it out of screen
settingsViewTopConstraint.constant = notVisibleSheetTop
primarySheetController.configurePrimarySheetContentView()
self.view.layoutIfNeeded()
}
Earlier, I was calling this function inside my viewDidLoad. I thought it was too early to call layoutIfNeeded inside viewDidLoad. So I moved the function to viewWillAppear. However, the crashes still seem to be happening . What am I missing/overseeing?
The crash is happening across very few devices and I'm not able to reproduce it.

State restoration crash reports (decodeObject?)

I'm getting these crash reports from XCode (I pasted one at the bottom) and I can't reproduce the error or figure out what the problem is.
From the backtrace I'm thinking it could be related to the decodeObject stuff… I did have some problems with the new decodeBool and decodeDouble functions, so to be sure I made an NSCoder extension:
func safeDecodeDouble(key: String) -> Double? {
if self.containsValue(forKey: key) {
if let value = self.decodeObject(forKey: key) as? Double {
return value
}
return self.decodeDouble(forKey: key)
}
return nil
}
func safeDecodeBool(key: String) -> Bool? {
if self.containsValue(forKey: key) {
if let value = self.decodeObject(forKey: key) as? Bool {
return value
}
return self.decodeBool(forKey: key)
}
return nil
}
func safeDecodeDate(key: String) -> Date? {
if self.containsValue(forKey: key) {
if let value = self.decodeObject(forKey: key) as? Date {
return value
}
}
return nil
}
func safeDecodeString(key: String) -> String? {
if self.containsValue(forKey: key) {
if let value = self.decodeObject(forKey: key) as? String {
return value
}
}
return nil
}
Now I only use the safeDecode functions in my code, but I'm still getting those same crash reports.
The third item in the backtrace says [UIStoryboard storyboardWithName:bundle:], but I don't know what that could have to do with anything. Also every crash report has something about state restoration and decodeObject, so I'm thinking the problem isn't the storyboard instantiation per se.
At the same time I never have any problems when I test state restoration on the simulator or on my devices, so apparently it's only happening to some people.
Any ideas on what could be going on here?
Last Exception Backtrace:
0 CoreFoundation 0x18a146fd8 __exceptionPreprocess + 124 (NSException.m:165)
1 libobjc.A.dylib 0x188ba8538 objc_exception_throw + 56 (objc-exception.mm:521)
2 UIKit 0x190a36850 +[UIStoryboard storyboardWithName:bundle:] + 776 (UIStoryboard.m:99)
3 UIKit 0x190bfacfc -[_UIStoryboardProxy initWithCoder:] + 192 (UIStateRestorationSupport.m:324)
4 Foundation 0x18ab96420 _decodeObjectBinary + 2076 (NSKeyedArchiver.m:2304)
5 Foundation 0x18ab95b58 _decodeObject + 308 (NSKeyedArchiver.m:2467)
6 UIKit 0x1903e62ec -[UIStateRestorationKeyedUnarchiver decodeObjectForKey:] + 88 (UIStateRestorationSupport.m:454)
7 UIKit 0x1903e5ba8 -[UIApplication(StateRestoration) _restoreApplicationPreservationStateWithSessionIdentifier:beginHandler:completionHandler:] + 4772 (UIApplication.m:13551)
8 UIKit 0x1902e76b4 -[UIApplication(StateRestoration) _doRestorationIfNecessary] + 244 (UIApplication.m:13979)
9 UIKit 0x1902e7288 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 296 (UIApplication.m:1792)
10 UIKit 0x1904f3800 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3452 (UIApplication.m:2129)
11 UIKit 0x1904f92a8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684 (UIApplication.m:3625)
12 UIKit 0x19050dde0 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3151 + 48 (UIApplication.m:10365)
13 UIKit 0x1904f653c -[UIApplication workspaceDidEndTransaction:] + 168 (UIApplication.m:2990)
14 FrontBoardServices 0x18bcef884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:158)
15 FrontBoardServices 0x18bcef6f0 -[FBSSerialQueue _performNext] + 176 (FBSSerialQueue.m:177)
16 FrontBoardServices 0x18bcefaa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:206)
17 CoreFoundation 0x18a0f5424 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
18 CoreFoundation 0x18a0f4d94 __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1989)
19 CoreFoundation 0x18a0f29a0 __CFRunLoopRun + 744 (CFRunLoop.c:2821)
20 CoreFoundation 0x18a022d94 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
21 UIKit 0x1902e045c -[UIApplication _run] + 652 (UIApplication.m:2658)
22 UIKit 0x1902db130 UIApplicationMain + 208 (UIApplication.m:4089)
23 Leio 0x1000b6ecc main + 120 (BookInfoTableViewController.swift:19)
24 libdyld.dylib 0x18903159c start + 4
Edit: Here's a different crash report that showed up and suggests there really is a problem with state restoration. I can never reproduce it myself, though. :/
0 CoreFoundation 0x18385adb0 __exceptionPreprocess + 124 (NSException.m:162)
1 libobjc.A.dylib 0x182ebff80 objc_exception_throw + 56 (objc-exception.mm:531)
2 Foundation 0x1841d4704 -[NSCoder(Exceptions) __failWithException:] + 132 (NSCoder.m:544)
3 Foundation 0x1841d48bc -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 440 (NSCoder.m:580)
4 Foundation 0x1841a33b8 _decodeObjectBinary + 2996 (NSKeyedArchiver.m:2173)
5 Foundation 0x1841a274c _decodeObject + 304 (NSKeyedArchiver.m:2313)
6 UIKit 0x188b3e20c -[UIStateRestorationKeyedUnarchiver decodeObjectForKey:] + 88 (UIStateRestorationSupport.m:454)
7 UIKit 0x188b3daf8 -[UIApplication(StateRestoration) _restoreApplicationPreservationStateWithSessionIdentifier:beginHandler:completionHandler:] + 4908 (UIApplication.m:15043)
8 UIKit 0x188a32d44 -[UIApplication(StateRestoration) _doRestorationIfNecessary] + 244 (UIApplication.m:15471)
9 UIKit 0x188a32964 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 308 (UIApplication.m:1860)
10 UIKit 0x188c62184 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904 (UIApplication.m:2112)
11 UIKit 0x188c665f0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684 (UIApplication.m:3355)
12 UIKit 0x188c63764 -[UIApplication workspaceDidEndTransaction:] + 168 (UIApplication.m:2748)
13 FrontBoardServices 0x1851fb7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:158)
14 FrontBoardServices 0x1851fb618 -[FBSSerialQueue _performNext] + 168 (FBSSerialQueue.m:177)
15 FrontBoardServices 0x1851fb9c8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:206)
16 CoreFoundation 0x18381109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1761)
17 CoreFoundation 0x183810b30 __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1807)
18 CoreFoundation 0x18380e830 __CFRunLoopRun + 724 (CFRunLoop.c:2536)
19 CoreFoundation 0x183738c50 CFRunLoopRunSpecific + 384 (CFRunLoop.c:2814)
20 UIKit 0x188a2b94c -[UIApplication _run] + 460 (UIApplication.m:2578)
21 UIKit 0x188a26088 UIApplicationMain + 204 (UIApplication.m:3772)
22 Leio 0x1000f6ecc main + 120 (BookInfoTableViewController.swift:19)
23 libdyld.dylib 0x1832d68b8 start + 4 (start_glue.s:78)

Understanding Swift stacktrace in Crashlytics

So, as a novice IOS developer I find it hard to determine what cases this exception.
Case: the IOS app has a UIScrollView that allows the user to drag down to sync with a web service - just like the build in mail app.
Once in a while a user in the wild will encounter an app crash. In crashlytics i see:
Crashed: com.apple.main-thread: EXC_BREAKPOINT 0x00000000e7ffdefe
0 myApp 0xba760 specialized WeekPlanController.scrollViewWillBeginDragging(UIScrollView) -> () (WeekPlanController.swift:428)
1 myApp 0xba4a0 specialized WeekPlanController.scrollViewWillBeginDragging(UIScrollView) -> () (WeekPlanController.swift:428)
2 myApp 0xb702c #objc WeekPlanController.scrollViewWillBeginDragging(UIScrollView) -> () (WeekPlanController.swift)
3 UIKit 0x2cee4ad3 -[UIScrollView _updatePanGesture] + 282
4 UIKit 0x2ced206b _UIGestureRecognizerSendActions + 294
5 UIKit 0x2cd810f9 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 668
6 UIKit 0x2d19af9b ___UIGestureRecognizerUpdate_block_invoke661 + 46
7 UIKit 0x2cd4a181 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 216
8 UIKit 0x2cd4805f _UIGestureRecognizerUpdate + 2926
9 UIKit 0x2cd7f4d9 -[UIWindow _sendGesturesForEvent:] + 784
10 UIKit 0x2cd7eddd -[UIWindow sendEvent:] + 524
11 UIKit 0x2cd54fe5 -[UIApplication sendEvent:] + 196
12 UIKit 0x2cfcb8fb _UIApplicationHandleEventFromQueueEvent + 14414
13 UIKit 0x2cd539f9 _UIApplicationHandleEventQueue + 1352
14 CoreFoundation 0x296c5faf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
15 CoreFoundation 0x296c53bf __CFRunLoopDoSources0 + 218
16 CoreFoundation 0x296c3a25 __CFRunLoopRun + 772
17 CoreFoundation 0x29610201 CFRunLoopRunSpecific + 476
18 CoreFoundation 0x29610013 CFRunLoopRunInMode + 106
19 GraphicsServices 0x30eef201 GSEventRunModal + 136
20 UIKit 0x2cdb4a59 UIApplicationMain + 1440
21 myApp 0x5d084 main (AppDelegate.swift:14)
22 libdyld.dylib 0x37f3daaf start + 2
This is the code from the controller:
func scrollViewWillBeginDragging(scrollView: UIScrollView){
if Settings.isSyncActive {
if let lastSyncDate = Settings.lastSyncedDate { // ln 427
self.refreshControl.attributedTitle = NSAttributedString(string: "Last sync \(lastSyncDate.relativeTimeToString()) ago") // ln 428
} // ln 429
else{
self.refreshControl.attributedTitle = NSAttributedString(string: "")
}
}
}
Any hint or tips are appreciated

Understanding an iOS stacktrace

I'm kinda new to debugging iOS exceptions.
On the fabric.io site I can see that a few users has seen this crash.
Can anyone please help me get started?
Crashed: com.apple.main-thread
0 gismoapp 0x114760 specialized WeekPlanController.scrollViewWillBeginDragging(UIScrollView) -> () (WeekPlanController.swift:428)
1 gismoapp 0x1144a0 specialized WeekPlanController.scrollViewWillBeginDragging(UIScrollView) -> () (WeekPlanController.swift:428)
2 gismoapp 0x11102c #objc WeekPlanController.scrollViewWillBeginDragging(UIScrollView) -> () (WeekPlanController.swift)
3 UIKit 0x261b4609 -[UIScrollView(UIScrollViewInternal) _scrollViewWillBeginDragging] + 232
4 UIKit 0x261b3a9d -[UIScrollView _updatePanGesture] + 284
5 UIKit 0x265685db _UIGestureRecognizerSendTargetActions + 142
6 UIKit 0x261a08e3 _UIGestureRecognizerSendActions + 170
7 UIKit 0x26030d15 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 1004
8 UIKit 0x2656993f ___UIGestureRecognizerUpdate_block_invoke898 + 62
9 UIKit 0x25ff1587 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 298
10 UIKit 0x25fedaf9 _UIGestureRecognizerUpdate + 2920
11 UIKit 0x2602ec01 -[UIWindow _sendGesturesForEvent:] + 904
12 UIKit 0x2602e3b3 -[UIWindow sendEvent:] + 622
13 UIKit 0x25ffec85 -[UIApplication sendEvent:] + 204
14 UIKit 0x25ffd229 _UIApplicationHandleEventQueue + 5016
15 CoreFoundation 0x219efa67 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
16 CoreFoundation 0x219ef657 __CFRunLoopDoSources0 + 454
17 CoreFoundation 0x219ed9bf __CFRunLoopRun + 806
18 CoreFoundation 0x2193c289 CFRunLoopRunSpecific + 516
19 CoreFoundation 0x2193c07d CFRunLoopRunInMode + 108
20 GraphicsServices 0x22f58af9 GSEventRunModal + 160
21 UIKit 0x260672c5 UIApplicationMain + 144
22 gismoapp 0xb7084 main (AppDelegate.swift:14)
23 libdispatch.dylib 0x215e8873 (Missing)
The code in question:
func scrollViewWillBeginDragging(scrollView: UIScrollView){
if let lastSyncDate = Settings.lastSyncedDate {
// This is line 428 in WeekPlanController
self.refreshControl.attributedTitle = NSAttributedString(string: "last synced \(lastSyncDate.relativeTimeToString()) ago")
}
}

Resources