Getting the following stack trace from Crashlytics.
Code that is crashing is return string
extension UserVisit: DashboardItem {
public var dashboardItemAttributedTitle: NSAttributedString {
let string = NSMutableAttributedString(string: "\(withUser.publicName) (\(withUser.publicAddress.fullDescription))", attributes: [NSFontAttributeName: UIFont.regularLight()])
string.addAttribute(NSFontAttributeName, value: UIFont.regularBold(), range: NSMakeRange(0 , count(withUser.publicName)))
return string /* Crash points to this line of code */
}
}
The code points to the return statement. The only reason I can think of for this crash is string being nil, which is not possible because if it was nil it would have crashed on the line above when addAttribute was called. Getting lots of these crashes and the stacktrace says absolutely nothing about what's causing it
Thread : Crashed: com.apple.main-thread
0 Company 0x00000001001c05c0 function signature specialization <Arg[0] = Owned To Guaranteed> of Company.UserVisit.dashboardItemAttributedTitle.getter : ObjectiveC.NSAttributedString (DashboardItemExtensions.swift:122)
1 Company 0x00000001001be674 #objc Company.UserVisit.dashboardItemAttributedTitle.getter : ObjectiveC.NSAttributedString (DashboardItemExtensions.swift)
2 Company 0x00000001001d3618 function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed> of Company.DashboardItemCell.configure (Company.DashboardItemCell)(Company.DashboardItem) -> () (DashboardItemCell.swift:93)
3 Company 0x00000001001d100c Company.DashboardItemCell.configure (Company.DashboardItemCell)(Company.DashboardItem) -> () (DashboardItemCell.swift)
4 Company 0x0000000100163cb4 function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed, Arg[2] = Owned To Guaranteed> of Company.DashboardViewController.collectionView (Company.DashboardViewController)(ObjectiveC.UICollectionView, cellForItemAtIndexPath : ObjectiveC.NSIndexPath) -> ObjectiveC.UICollectionViewCell (DashboardViewController.swift:567)
5 Company 0x000000010015f3b8 #objc Company.DashboardViewController.collectionView (Company.DashboardViewController)(ObjectiveC.UICollectionView, cellForItemAtIndexPath : ObjectiveC.NSIndexPath) -> ObjectiveC.UICollectionViewCell (DashboardViewController.swift)
6 UIKit 0x0000000187650710 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 284
7 UIKit 0x0000000187c7a850 __51-[UICollectionView _viewAnimationsForCurrentUpdate]_block_invoke1381 + 480
8 UIKit 0x00000001877c5164 -[UICollectionView _viewAnimationsForCurrentUpdate] + 2892
9 UIKit 0x0000000187c7b694 -[UICollectionView _updateWithItems:tentativelyForReordering:] + 1948
10 UIKit 0x0000000187c79c30 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:] + 10120
11 UIKit 0x0000000187c7c988 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 352
12 Company 0x000000010016c214 Company.DashboardViewController.((fetchAndPopulateDashboard in _59C7F3AF672DD71404DED200B8F15814) (Company.DashboardViewController) -> () -> ()).(closure #1) (DashboardViewController.swift:370)
13 Company 0x00000001000e1728 Company.BaseNetworkManager.(fetchObject (Company.BaseNetworkManager) -> <A>(A.Type, path : Swift.String, method : Company.Method, parameters : Swift.Optional<Swift.Dictionary<ObjectiveC.NSObject, Swift.AnyObject>>, errorHandler : Company.NetworkErrorHandler, completion : (Company.SingleNetworkResponse<A>) -> ()) -> Company.RequestMirror).(closure #1).(closure #1).(closure #1) (BaseNetworkManager.swift:219)
14 libdispatch.dylib 0x0000000194e6d994 _dispatch_call_block_and_release + 24
15 libdispatch.dylib 0x0000000194e6d954 _dispatch_client_callout + 16
16 libdispatch.dylib 0x0000000194e7220c _dispatch_main_queue_callback_4CF + 1608
17 CoreFoundation 0x0000000182b2b7f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
18 CoreFoundation 0x0000000182b298a0 __CFRunLoopRun + 1492
19 CoreFoundation 0x0000000182a552d4 CFRunLoopRunSpecific + 396
20 GraphicsServices 0x000000018c4b36fc GSEventRunModal + 168
21 UIKit 0x0000000187652f40 UIApplicationMain + 1488
22 Company 0x000000010003ac1c main (main.m:13)
23 libdyld.dylib 0x0000000194e9aa08 start + 4
The range for an attributed string must be in UTF-16 units.
Related
Here is the code where the crash had occurred :-
private func dispatchMessageImmediately(topicName : String, mqttMessage : MQTTMessage){
AppDelegate.getAppDelegate().log.debug("Message: \(String(describing: mqttMessage.payloadString))")
let listener = self.topicToListenerMap?[topicName]
if listener != nil {
DispatchQueue.main.async(execute: { () -> Void in
MessageDispatchUtils.dispatchMessageToListeners(topicName: topicName, mqttMessage: mqttMessage, topicListener: listener!)
})
}
}
The Xcode version I am using is 9.3. My os version is iOS 11.4.1 Device is iPhone 5s. The crash is caused in libswift.dylib
Here is the crash report for the crash.Any help? Thanks in advance
Crashed: com.apple.main-thread
0 libsystem_platform.dylib 0x18358de38 _os_unfair_lock_recursive_abort + 36
1 libsystem_platform.dylib 0x18358ebb8 _os_unfair_lock_lock_slow + 264
2 libobjc.A.dylib 0x182b45720 objc_object::sidetable_clearDeallocating() + 104
3 libobjc.A.dylib 0x182b349d8 objc_destructInstance + 140
4 libswiftCore.dylib 0x10263ec0c swift_deallocClassInstance + 32
5 libswiftCore.dylib 0x10263eb4c _swift_release_dealloc + 28
6 Razorpay 0x1020f09b0 _T08Razorpay0A13UtilFunctionsC24handleUnhandledExceptionys5Int32V16havingSignalCode_SS03andI4NametFZTf4nnd_n + 248
7 libsystem_platform.dylib 0x183590b48 _sigtramp + 36
8 libobjc.A.dylib 0x182b45740 objc_object::sidetable_clearDeallocating() + 136
9 libobjc.A.dylib 0x182b45740 objc_object::sidetable_clearDeallocating() + 136
10 libobjc.A.dylib 0x182b349d8 objc_destructInstance + 140
11 libswiftCore.dylib 0x10263ec0c swift_deallocClassInstance + 32
12 libswiftCore.dylib 0x10263eb4c _swift_release_dealloc + 28
13 libswiftCore.dylib 0x1025750ec specialized String.debugDescription.getter + 4580
14 libswiftCore.dylib 0x1024bd66c protocol witness for CustomDebugStringConvertible.debugDescription.getter in conformance String + 290904
15 libswiftCore.dylib 0x1023da008 _debugPrint_unlocked<A, B>(_:_:) + 252544
16 libswiftCore.dylib 0x10257bc04 specialized _debugPrint<A>(_:separator:terminator:to:) + 31996
17 libswiftCore.dylib 0x10245a8fc Optional.debugDescription.getter + 68296
18 libswiftCore.dylib 0x10245aa4c protocol witness for CustomStringConvertible.description.getter in conformance <A> A! + 68632
19 libswiftCore.dylib 0x10257bf44 specialized _print_unlocked<A, B>(_:_:) + 32828
20 Quickride 0x10090c37c implicit closure #1 in EventServiceProxy.dispatchMessageImmediately(topicName:mqttMessage:) (EventServiceProxy.swift:238)
21 Quickride 0x1009186c4 partial apply for implicit closure #1 in EventServiceProxy.onNewMessageArrived(mqttMessage:) + 4314498756
22 XCGLogger 0x1021b86f4 _T09XCGLoggerAAC5loglnyAB5LevelO_SS12functionNameSS04fileE0Si10lineNumbers10DictionaryVySSypG8userInfoypSgyc7closuretFTf4ngXgXnggn_n + 232
23 XCGLogger 0x1021b3bac _T09XCGLoggerAAC7verboseyypSgyXK_s12StaticStringV12functionNameAF04fileF0Si10lineNumbers10DictionaryVySSypG8userInfotFTm + 500
24 XCGLogger 0x1021b2aa8 _T09XCGLoggerAAC5debugyypSgyXK_s12StaticStringV12functionNameAF04fileF0Si10lineNumbers10DictionaryVySSypG8userInfotF + 32
25 Quickride 0x100915144 specialized EventServiceProxy.dispatchMessageImmediately(topicName:mqttMessage:) (EventServiceProxy.swift:238)
26 Quickride 0x100916918 specialized EventServiceProxy.onNewMessageArrived(mqttMessage:) (EventServiceProxy.swift:145)
27 Quickride 0x10090d8c8 protocol witness for MqttCallback.onNewMessageArrived(mqttMessage:) in conformance EventServiceProxy (EventServiceProxy.swift)
28 Quickride 0x100cf309c specialized closure #1 in closure #4 in EventServiceConnection.createMqttConfig() (EventServiceConnection.swift:100)
29 Quickride 0x100cf29f4 partial apply for closure #1 in closure #4 in EventServiceConnection.createMqttConfig() (EventServiceConnection.swift)
30 Quickride 0x1008c19fc thunk for #callee_owned () -> () (RideManagementModuleSessonHandler.swift)
31 libdispatch.dylib 0x183260aa0 _dispatch_call_block_and_release + 24
32 libdispatch.dylib 0x183260a60 _dispatch_client_callout + 16
33 libdispatch.dylib 0x18326d65c _dispatch_main_queue_callback_4CF$VARIANT$mp + 1012
34 CoreFoundation 0x183917070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
35 CoreFoundation 0x183914bc8 __CFRunLoopRun + 2272
36 CoreFoundation 0x183834da8 CFRunLoopRunSpecific + 552
37 GraphicsServices 0x18581a020 GSEventRunModal + 100
38 UIKit 0x18d854758 UIApplicationMain + 236
39 Quickride 0x1007d4bf0 main (AppDelegate.swift:26)
40 libdyld.dylib 0x1832c5fc0 start + 4
I have instantiated and am using two FMDatabase instances, each one in a different class, with paths to two distinct databases.
From what I understand this usage shouldn't be the cause of the crash on the main thread below, but I may be mistaken. If it is indeed the reason behind the crash, could someone help me understand why?
Main thread:
Crashed: com.apple.main-thread
0 libsqlite3.dylib 0x18461d9f0 (null) + 972
1 libsqlite3.dylib 0x18461d9c4 (null) + 928
2 libsqlite3.dylib 0x1846a4644 (null) + 37328
3 libsqlite3.dylib 0x1846acb14 (null) + 71328
4 libsqlite3.dylib 0x1846abdb4 (null) + 67904
5 libsqlite3.dylib 0x1846370c4 (null) + 9180
6 libsqlite3.dylib 0x184635b7c sqlite3_step + 3732
[*CRASH*]
7 FMDB 0x100d55950 -[FMResultSet nextWithError:] (FMResultSet.m:165)
8 ZiiZii 0x100713d68 specialized static CatalogManager.countItems() -> Int (CatalogManager.swift:157)
9 ZiiZii 0x10079ad34 specialized CustomerInfoCell.render(Customer!, isCatalogAvailable : Bool?, for : UIViewController, at : IndexPath?) -> () (CatalogManager.swift)
10 ZiiZii 0x1007a7a34 specialized MainController.(viewDidLoad() -> ()).(closure #1).(closure #2).(closure #2).(closure #1).(closure #1) (MainController.swift)
11 ZiiZii 0x1007afbc0 partial apply for MainController.(viewDidLoad() -> ()).(closure #1).(closure #2).(closure #2).(closure #1).(closure #2) + 4304190400
12 ZiiZii 0x10084cf20 DynamicTableRow.(show(String, onRender : (UITableViewCell) -> ()) -> ()).(closure #1) (DynamicTableRow.swift:111)
13 ZiiZii 0x1008661b8 specialized DynamicTableSection.cellForRow(UITableView, rowIndex : Int) -> UITableViewCell (DynamicTableRow.swift:157)
14 ZiiZii 0x100676d58 specialized DynamicTable.tableView(UITableView, cellForRowAt : IndexPath) -> UITableViewCell (DynamicTableSection.swift)
15 ZiiZii 0x100675edc #objc DynamicTable.tableView(UITableView, cellForRowAt : IndexPath) -> UITableViewCell (DynamicTable.swift)
16 UIKit 0x18d96b948 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 664
17 UIKit 0x18d96beac -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
18 UIKit 0x18d813934 -[_UITableViewUpdateSupport(Private) _setupAnimationsForNewlyInsertedCells] + 5188
19 UIKit 0x18d80f9f0 -[_UITableViewUpdateSupport _setupAnimations] + 208
20 UIKit 0x18d80f3a8 -[UITableView _updateWithItems:updateSupport:] + 2456
21 UIKit 0x18d7f6fe0 -[UITableView _endCellAnimationsWithContext:] + 15456
22 UIKit 0x18d7f328c -[UITableView endUpdates] + 92
23 ZiiZii 0x100675948 DynamicTable.performUpdates() -> () (DynamicTable.swift:213)
24 ZiiZii 0x1006e935c DynamicTableViewController.refresh(Bool) -> () (DynamicTableViewController.swift)
25 ZiiZii 0x1007a0ba4 MainController.viewWillAppear(Bool) -> () (MainController.swift:421)
26 ZiiZii 0x1007a0c00 #objc MainController.viewWillAppear(Bool) -> () (MainController.swift)
27 UIKit 0x18d64996c -[UIViewController _setViewAppearState:isAnimating:] + 628
28 UIKit 0x18d6496e0 -[UIViewController __viewWillAppear:] + 156
29 UIKit 0x18d6d46c8 -[UINavigationController viewWillAppear:] + 440
30 UIKit 0x18d64996c -[UIViewController _setViewAppearState:isAnimating:] + 628
31 UIKit 0x18d6496e0 -[UIViewController __viewWillAppear:] + 156
32 UIKit 0x18d97c734 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 1152
33 UIKit 0x18d8a0f74 _runAfterCACommitDeferredBlocks + 292
34 UIKit 0x18d894318 _cleanUpAfterCAFlushAndRunDeferredBlocks + 288
35 UIKit 0x18d623ac8 _afterCACommitHandler + 132
36 CoreFoundation 0x1841a1848 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
37 CoreFoundation 0x18419f200 __CFRunLoopDoObservers + 412
38 CoreFoundation 0x18419f7bc __CFRunLoopRun + 1292
39 CoreFoundation 0x1840bffb8 CFRunLoopRunSpecific + 436
40 GraphicsServices 0x185f57f84 GSEventRunModal + 100
41 UIKit 0x18d6942f4 UIApplicationMain + 208
42 ZiiZii 0x10064fc20 main (AppDelegate.swift:23)
43 libdyld.dylib 0x183be256c start + 4
Background thread:
com.apple.root.default-qos
0 libsystem_kernel.dylib 0x183cf2ebc fsync + 8
1 libsqlite3.dylib 0x18465ec58 (null) + 59172
2 libsqlite3.dylib 0x18465e50c (null) + 57304
3 libsqlite3.dylib 0x18464addc (null) + 21892
4 libsqlite3.dylib 0x1846181b0 (null) + 3472
5 libsqlite3.dylib 0x184644540 (null) + 63576
6 libsqlite3.dylib 0x184635b7c sqlite3_step + 3732
7 FMDB 0x100d50ae0 -[FMDatabase executeUpdate:error:withArgumentsInArray:orDictionary:orVAList:] (FMDatabase.m:1104)
8 FMDB 0x100d50f1c -[FMDatabase executeUpdate:withArgumentsInArray:] (FMDatabase.m:1198)
9 ZiiZii 0x100793000 specialized static LabelsManager.createLabel(format : LabelFormat?, item : CatalogItem?) -> Label? (LabelsManager.swift:66)
10 ZiiZii 0x1007beebc specialized MainPrintingFeature.(lookupBarcode(String, String, (ScannerResponse) -> ()) -> ()).(closure #1) (LabelsManager.swift)
11 ZiiZii 0x1007bcb10 partial apply for MainPrintingFeature.(lookupBarcode(String, String, (ScannerResponse) -> ()) -> ()).(closure #1) (MainPrintingFeature.swift)
12 libdispatch.dylib 0x183b7d088 _dispatch_call_block_and_release + 24
13 libdispatch.dylib 0x183b7d048 _dispatch_client_callout + 16
14 libdispatch.dylib 0x183b84090 _dispatch_queue_override_invoke$VARIANT$mp + 716
15 libdispatch.dylib 0x183b8a1c8 _dispatch_root_queue_drain + 596
16 libdispatch.dylib 0x183b89f10 _dispatch_worker_thread3 + 120
17 libsystem_pthread.dylib 0x183e23120 _pthread_wqthread + 1268
18 libsystem_pthread.dylib 0x183e22c20 start_wqthread + 4
Ok, so I understand that this question is a bit broad, but I do not know how to proceed.
So this is what my crash looks like from fabric (I have not been able to reproduce this, but I'm getting alot of crashes like this)
Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x101085cb8 _assertionFailed(StaticString, String, StaticString, UInt, flags : UInt32) -> Never (__hidden#16085_:167)
1 libswiftCore.dylib 0x1010a5a70 _hidden#1062_ + 504
2 libswiftCore.dylib 0x1010a5878 swift_errorInMain + 26
3 MYAPPPPPP 0x10006da44 specialized static FFBaseApiService.accessTokenGetString.getter (FFBaseApiService.swift)
4 libdispatch.dylib 0x191a9a1bc _dispatch_client_callout + 16
5 libdispatch.dylib 0x191a9afb0 dispatch_once_f + 56
6 MYAPPPPPP 0x100105208 specialized FFAppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [UIApplicationLaunchOptionsKey : Any]?) -> Bool (FFAppDelegate.swift:62)
7 MYAPPPPPP 0x100101b70 #objc FFAppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [UIApplicationLaunchOptionsKey : Any]?) -> Bool (FFAppDelegate.swift)
8 UIKit 0x198b386a4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
9 UIKit 0x198d48a98 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3524
10 UIKit 0x198d4e808 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1656
11 UIKit 0x198d63104 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3139 + 48
12 UIKit 0x198d4b7ec -[UIApplication workspaceDidEndTransaction:] + 168
13 FrontBoardServices 0x1947e792c __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
14 FrontBoardServices 0x1947e7798 -[FBSSerialQueue _performNext] + 176
15 FrontBoardServices 0x1947e7b40 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
16 CoreFoundation 0x192bbeb5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
17 CoreFoundation 0x192bbe4a4 __CFRunLoopDoSources0 + 524
18 CoreFoundation 0x192bbc0a4 __CFRunLoopRun + 804
19 CoreFoundation 0x192aea2b8 CFRunLoopRunSpecific + 444
20 UIKit 0x198b317b0 -[UIApplication _run] + 608
21 UIKit 0x198b2c534 UIApplicationMain + 208
22 MYAPPPPPP 0x100059138 main (UserDefaultsWrapper.swift:21)
23 libdispatch.dylib 0x191acd5b8 (Missing)
To me it seems as if it's this row that is crashing on appdelegate startup:
specialized static FFBaseApiService.accessTokenGetString.getter (FFBaseApiService.swift)
This is the code for this:
class var accessTokenGetString : String {
return "?accessToken=\(currentUserAccessToken)"
}
class var currentUserAccessToken : String {
return FFUserManager.sharedInstance.getUserAccessToken()
}
Also, I am using realm, and the getUserAccessToken looks like this:
func getUserAccessToken() -> String {
if let user = user, let accessToken = user.accessToken {
return accessToken
}
else {
print("Returning empty access token")
return ""
}
}
Where the user property is fetched like this:
private var user : FFUser? {
return realm.objects(FFUser.self).first
}
I have NO IDEA whatsoever what could be wrong here. Any takers?
I am using Crashlytics to log crashes. The crash logs are Symbolicated but it only shows line at which it crashed (Usually first or last line of a method). It does not show exception type or reason for exception. Do need to enable something to get more detailed logs ? Please find raw information about the crash below.
Crashed: com.apple.main-thread
0 Zilingo Sellers 0x1002520e8 specialized RegularPendingOrderPickupSummarySource.getBySubOrderId(RegularPendingOrderPickupSummarySource) -> (String) -> PendingOrderPickupSummary? (RegularPendingOrderPickupSummarySource.swift:108)
1 Zilingo Sellers 0x100251708 _TTWC15Zilingo_Sellers38RegularPendingOrderPickupSummarySourceS_31PendingOrderPickupSummarySourceS_FS1_15getBySubOrderIduRq_S1__fq_FSSGSqCS_25PendingOrderPickupSummary_ (RegularPendingOrderPickupSummarySource.swift:68)
2 Zilingo Sellers 0x100219b18 PendingOrderPickupOrderSummarySection.__allocating_init(PendingOrderPickupOrderSummarySection.Type) -> (subOrderId : String, viewController : PendingOrderPickupViewController) -> PendingOrderPickupOrderSummarySection (PendingOrderPickupOrderSummarySection.swift:17)
3 Zilingo Sellers 0x100194f74 specialized PendingOrderPickupViewController.initSections(PendingOrderPickupViewController) -> (String) -> () (PendingOrderPickupViewController.swift:30)
4 Zilingo Sellers 0x100193838 PendingOrderPickupViewController.initSections(PendingOrderPickupViewController) -> (String) -> () (PendingOrderPickupViewController.swift:28)
5 Zilingo Sellers 0x10025e638 _TTSf4g_g_d___TFC15Zilingo_Sellers24OrdersListViewController15prepareForSeguefS0_FTCSo17UIStoryboardSegue6senderGSqPSs9AnyObject___T_ (OrdersListViewController.swift:173)
6 Zilingo Sellers 0x10025cfc4 _TToFC15Zilingo_Sellers24OrdersListViewController15prepareForSeguefS0_FTCSo17UIStoryboardSegue6senderGSqPSs9AnyObject___T_ (OrdersListViewController.swift)
7 UIKit 0x189049f7c -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 356
8 UIKit 0x189049de4 -[UIStoryboardSegueTemplate _perform:] + 92
9 UIKit 0x188c79b08 -[UIViewController performSegueWithIdentifier:sender:] + 108
10 Zilingo Sellers 0x10025df94 specialized OrdersListViewController.tableView(OrdersListViewController) -> (UITableView, didSelectRowAtIndexPath : NSIndexPath) -> () (OrdersListViewController.swift:151)
11 Zilingo Sellers 0x10025cf30 #objc OrdersListViewController.tableView(OrdersListViewController) -> (UITableView, didSelectRowAtIndexPath : NSIndexPath) -> () (OrdersListViewController.swift)
12 UIKit 0x188a37c5c -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1316
13 UIKit 0x188af577c -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 376
14 UIKit 0x188bb2fd8 _runAfterCACommitDeferredBlocks + 292
15 UIKit 0x188bc0990 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92
16 UIKit 0x1888f24a4 _afterCACommitHandler + 96
17 CoreFoundation 0x18376c7b0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
18 CoreFoundation 0x18376a554 __CFRunLoopDoObservers + 372
19 CoreFoundation 0x18376a984 __CFRunLoopRun + 928
20 CoreFoundation 0x183694d10 CFRunLoopRunSpecific + 384
21 GraphicsServices 0x184f7c088 GSEventRunModal + 180
22 UIKit 0x188969f70 UIApplicationMain + 204
23 Zilingo Sellers 0x1001728a0 main (AppDelegate.swift:17)
24 libdispatch.dylib 0x1832328b8 (Missing)
I have a simple class func for adding SKEmitterNode on many different occasions.
I cannot reproduce steps when the exception occurs. It happens rarely and quite randomly. I can call this method 500 times without an error or in some cases error can happen after 1 or 2 call, etc.
The problem/exception line is:
root?.addChild(sparks)
Below is the method and stack trace. I have no idea how to debug this. I've tried many different things but without success.
Any ideas ?
class func setSimpleSparksEffect(root:SKNode?, color:UIColor, position:CGPoint)
{
if CGPointEqualToPoint(position, CGPointZero)
{
return
}
let sparks = SKEmitterNode(fileNamed: "SimpleSparks")
sparks.alpha = GameObjectsDefaultAlpha
sparks.particleColorSequence = nil
sparks.particleColorBlendFactor = 1.0
sparks.particleColor = color
sparks.position = position
sparks.zPosition = SparksElementsZPosition
root?.addChild(sparks)
sparks.runAction(SKAction.waitForDuration(NSTimeInterval(EmmiterSimpleShortDuration)), completion: { () -> Void in
sparks.runAction(SKAction.fadeOutWithDuration(NSTimeInterval(FactorSparksFadeOutDuration)), completion: { () -> Void in
sparks.removeAllActions()
sparks.removeAllChildren()
sparks.removeFromParent()
})
})
}
And stack trace:
Thread : Crashed: com.apple.main-thread
0 libc++abi.dylib 0x0000000199944ce4 __dynamic_cast + 52
1 SpriteKit 0x000000018ab63f58 __15-[SKNode scene]_block_invoke + 60
2 SpriteKit 0x000000018ab63f58 __15-[SKNode scene]_block_invoke + 60
3 SpriteKit 0x000000018ab28038 SKCNode::walkUp(void (SKCNode*, bool*) block_pointer, bool) + 76
4 SpriteKit 0x000000018ab63eac -[SKNode scene] + 132
5 SpriteKit 0x000000018ab643ac -[SKNode insertChild:atIndex:] + 356
6 SpriteKit 0x000000018ab64224 -[SKNode addChild:] + 76
7 DodgeMaster 0x00000001000f1d80 static DodgieCommon.setSimpleSparksEffect(SKNode?, color : UIColor, position : CGPoint) -> () (DodgieCommon.swift:275)
8 DodgeMaster 0x00000001000d2bc4 GameLevel.(gameLogicGoalerHitmeContact(GameLevel) -> (NSNotification) -> ()).(closure #1) (GameLevel.swift:502)
9 DodgeMaster 0x0000000100125018 static Helper.(runAsyncOnMain(Helper.Type) -> (() -> ()) -> ()).(closure #1) (Helper.swift:270)
10 DodgeMaster 0x00000001000b41c4 thunk (Pointoser.swift)
11 libdispatch.dylib 0x000000019aa917b0 _dispatch_call_block_and_release + 24
12 libdispatch.dylib 0x000000019aa91770 _dispatch_client_callout + 16
13 libdispatch.dylib 0x000000019aa96e20 _dispatch_main_queue_callback_4CF + 1844
14 CoreFoundation 0x000000018574c258 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
15 CoreFoundation 0x000000018574a0c0 __CFRunLoopRun + 1628
16 CoreFoundation 0x0000000185678dc0 CFRunLoopRunSpecific + 384
17 GraphicsServices 0x00000001907cc088 GSEventRunModal + 180
18 UIKit 0x000000018ad52f60 UIApplicationMain + 204
19 DodgeMaster 0x000000010011de24 main (AppDelegate.swift:22)
20 libdyld.dylib 0x000000019aac28b8 start + 4
Another person on here had a similar problem which I think you may encountering too... I've tailored my response on that post for yours.
let sparksFile: String = NSBundle.mainBundle().pathForResource("SimpleSparks", ofType: "sks")!
let sparks = NSKeyedUnarchiver.unarchiveObjectWithFile(explosionFile) as! SKEmitterNode
sparks.alpha = GameObjectsDefaultAlpha
sparks.particleColorSequence = nil
sparks.particleColorBlendFactor = 1.0
sparks.particleColor = color
sparks.position = position
sparks.zPosition = SparksElementsZPosition
self.root?.addChild(sparks)