I am getting a crash reported in crashlytics about partial apply in closure. I have tried other answers that mainly focus on using [weak self] but that didn't help. However, i am not getting a crash on my device.
According to the report the crash is somewhere in the function where i show my dropDown here is the code
func showDropDown(_ names: [String], forResult result: SearchPatientResultResponnse) {
guard let vc = viewController
else { return }
self.searchedPatientNames = result.data?.patientSearchSuggestions
Helpers.showSearchDropdown(anchorView: vc.searchBar.searchTextField, dataSource: names, scrollToTop: true, completion: { [weak self] (i, item) in
guard let self = self else {
return
}
vc.searchBar.text = item
vc.dismissKeyboard()
self.selectedSearchPatient = self.searchedPatientNames?[i]
if let d = self.searchedPatientNames?[i].dob {
vc.dobTF.text = DateTimeFormatters.userUIDateFormatterInUTC.string(from: d)
}
self.search(self.selectedSearchFilter)
}, fetchPaginationData: { [weak self] in
guard let self = self, !self.isNameSearchLastPage, self.page != -1 else {
return
}
vc.searchBar.isLoadingWithoutSearchIcon = true
self.fetchPatientNameNextPage()
}, cancel: { [weak self] in
self?.resetPaginationParams()
})
}
This is the function from where i am calling this showDropDown function
func getQueryPatientResponse() {
guard let vc = viewController else {
return
}
SocketIOManager.shared.queryResponseForPatient = { [weak self] result in
var names: [String] = []
self?.isNameSearchLastPage = result.data?.isLastPage ?? true
self?.page = result.data?.pageNumber ?? -1
for data in result.data?.patientSearchSuggestions ?? [] {
var name = ""
if !data.middleName.isEmpty {
name = data.firstName + " " + data.middleName + " " + data.lastName
} else {
name = data.firstName + " " + (data.lastName)
}
names.append(name)
}
vc.searchBar.isLoadingWithoutSearchIcon = false
self?.page == 1 ? self?.showDropDown(names, forResult: result) : self?.updateDropDown(names, forResult: result)
}
}
This is the crash report from crashlytics:-
Crashed: com.apple.main-thread
0 Ovada CM - PT 0x639b0 closure #1 in VisitStatusViewModel.showDropDown(_:forResult:)
+ 4340890032 (<compiler-generated>:4340890032)
1 Ovada CM - PT 0x3f328 partial apply for closure #1 in static Helpers.showSearchDropdown(anchorView:dataSource:scrollToTop:completion:fetchPaginationData:cancel:)
+ 121 (Helpers.swift:121)
2 Ovada CM - PT 0x15604c DropDown.tableView(_:didSelectRowAt:)
+ 4341882956 (<compiler-generated>:4341882956)
3 Ovada CM - PT 0x156548 #objc DropDown.tableView(_:didSelectRowAt:)
+ 4341884232 (<compiler-generated>:4341884232)
4 UIKitCore 0xfe36d0 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:isCellMultiSelect:deselectPrevious:]
+ 1640
5 UIKitCore 0xfe3050 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
+ 112
6 UIKitCore 0xfe394c -[UITableView _userSelectRowAtPendingSelectionIndexPath:]
+ 316
7 UIKitCore 0x30c240 -[_UIAfterCACommitBlock run] + 64
8 UIKitCore 0x227770 -[_UIAfterCACommitQueue flush] + 200
9 UIKitCore 0x155eb0 _runAfterCACommitDeferredBlocks + 640
10 UIKitCore 0x15657c _cleanUpAfterCAFlushAndRunDeferredBlocks + 128
11 UIKitCore 0x156748 _afterCACommitHandler + 56
12 CoreFoundation 0x3e83c _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION_ + 32
13 CoreFoundation 0xfa74 __CFRunLoopDoObservers + 616
14 CoreFoundation 0xaffc __CFRunLoopRun + 1012
15 CoreFoundation 0x1e250 CFRunLoopRunSpecific + 572
16 GraphicsServices 0x1988 GSEventRunModal + 160
17 UIKitCore 0x4e5a94 -[UIApplication _run] + 1080
18 UIKitCore 0x27efd4 UIApplicationMain + 336
19 Ovada CM - PT 0x6070 main + 14 (AppDelegate.swift:14)
20 ??? 0x1029dc4d0 (Missing)
Related
During few days I am seeing a firebase crash analytic issue (given below) in my console. I am surfing a log but didn't get any solution. I am not sure the crush Mocking line-1 and line-2 (inside the self.addTransferOperation() function). If it is 'addOperation' related issue (line-2), what will its solution then. How it is possible to become the operation (transferOperation) nil. Advance thanks for your help.
line-1:
_ = self.addTransferOperation(device: device, deviceIndex:index, dataTransferCategory:OMVitalDataTransferCategory.bloodPressure)
Line-2:
func addTransferOperation(device: ConnectedDevice, deviceIndex:Int, dataTransferCategory:OMVitalDataTransferCategory = OMVitalDataTransferCategory.all) -> ConnectivityTransferOperation {
let transferOperation = ConnectivityTransferOperation()
// transferOperation.isUserNotify = device == sortedDeviceList.last ? notifyUser : false
let connectedDevice = ConnectedDevice(value : device)
transferOperation.device = ConnectedDevice(value : device)
transferOperation.transferDataType = dataTransferCategory
transferOperation.completionBlock = {
LogManager.shared.addLog(logString: "completion of transfer operation",localName: connectedDevice.deviceLocalName, uuid: connectedDevice.uuid)
// Remove first item
if !self.pendingOperations.syncInProgress.isEmpty {
self.pendingOperations.syncInProgress.removeAll(where: {$0 == transferOperation})
}
// Empty queue
if self.pendingOperations.syncInProgress.isEmpty {
// update autosync timer if Manual sync
if (self.isManualSync) {
self.updateSyncTimer()
}
}
// Reset bluetooth state
self.resetBluetoothState()
DispatchQueue.main.async {
// Set error from transfer operation and set flag to check if it happened in transfer operation
let transferOperationDetails: [String : Any] = [ConnectivityConfiguration.error: transferOperation.error,
ConnectivityConfiguration.isTransferOperation:true]
// post notification for stop data transfer with transfer error operation object
NotificationCenter.default.post(name: .dataTransferStop,
object: transferOperationDetails)
}
}
LogManager.shared.addLog(logString: "Add transfer operation for device \(device.displayName)",localName: connectedDevice.deviceLocalName, uuid: connectedDevice.uuid)
// Add operation and start
self.pendingOperations.syncInProgress.append(transferOperation)
if deviceIndex > 0 {
// add dependency
transferOperation.addDependency(self.pendingOperations.syncInProgress[deviceIndex-1])
}
self.pendingOperations.syncQueue.addOperation(transferOperation)
return transferOperation
}
Crash:
Crashed: com.apple.main-thread
0 Foundation 0x114ea8 ____addOperations_block_invoke.567 + 680
1 Foundation 0x113858 __addOperations + 1288
2 GrandApp 0x7bd3d8 ConnectivityManager.addTransferOperation(device:deviceIndex:dataTransferCategory:) + 2411 (ConnectivityManager.swift:2411)
3 GrandApp 0x7bc3f0 ConnectivityManager.transferOperation(withDevices:notifyUser:isManualSync:) + 4313269232 (<compiler-generated>:4313269232)
4 GrandApp 0x7a6770 ConnectivityManager.startTransferOperation(notifyUser:device:syncAllData:isBeaconFlow:) + 4313180016 (<compiler-generated>:4313180016)
5 GrandApp 0x6c4aa4 closure #1 in DashboardViewController.refreshAction() + 1096 (DashboardViewController.swift:1096)
6 GrandApp 0x7cc37c specialized ConnectivityManager.isSyncing(withStop:completion:) + 4313334652 (<compiler-generated>:4313334652)
7 GrandApp 0x6c4218 DashboardViewController.refreshAction() + 4312252952 (<compiler-generated>:4312252952)
8 GrandApp 0x6c4aec #objc DashboardViewController.refreshAction() + 4312255212 (<compiler-generated>:4312255212)
9 UIKitCore 0x8be300 -[UIApplication sendAction:to:from:forEvent:] + 96
10 UIKitCore 0x367424 -[UIControl sendAction:to:forEvent:] + 80
11 UIKitCore 0x367744 -[UIControl _sendActionsForEvents:withEvent:] + 440
12 UIKitCore 0x3667b0 -[UIControl touchesEnded:withEvent:] + 568
13 UIKitCore 0x8f55c4 -[UIWindow _sendTouchesForEvent:] + 2108
14 UIKitCore 0x8f67ec -[UIWindow sendEvent:] + 3140
15 UIKitCore 0x8d685c -[UIApplication sendEvent:] + 340
16 UIKitCore 0x99c9d4 __dispatchPreprocessedEventFromEventQueue + 1768
17 UIKitCore 0x99f100 __handleEventQueueInternal + 4828
18 UIKitCore 0x998330 __handleHIDEventFetcherDrain + 15
19 CoreFoundation 0xaaf1c CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24
20 CoreFoundation 0xaae9c __CFRunLoopDoSource0 + 88
21 CoreFoundation 0xaa784 __CFRunLoopDoSources0 + 176
22 CoreFoundation 0xa56c0 __CFRunLoopRun + 1004
23 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436
24 GraphicsServices 0xa79c GSEventRunModal + 104
25 UIKitCore 0x8bcc38 UIApplicationMain + 212
26 GrandApp 0x1db0c main + 19 (AppDelegate.swift:19)
27 libdyld.dylib 0x18e0 start + 4
ConnectivityTransferOperation.swift
import UIKit
import OMConnectivityLibrary
/// Transfer operation for connectivity
class ConnectivityTransferOperation : ConnectivityOperation {
override func main() {
guard isCancelled == false else {
finish(true)
return
}
self.executing(true)
}
override func end() {
// Super call
super.end()
}
}
ConnectivityOperation.swift
import UIKit
import OMConnectivityLibrary
class ConnectivityOperation: Operation {
/// Making operation queue async
override var isAsynchronous: Bool {
get {
return true
}
}
private var _executing = false {
willSet {
willChangeValue(forKey: "isExecuting")
}
didSet {
didChangeValue(forKey: "isExecuting")
}
}
private var _finished = false {
willSet {
willChangeValue(forKey: "isFinished")
}
didSet {
didChangeValue(forKey: "isFinished")
}
}
override var isExecuting: Bool {
return _executing
}
override var isFinished: Bool {
return _finished
}
func executing(_ executing: Bool) {
_executing = executing
}
func finish(_ finished: Bool) {
_finished = finished
}
func end() {
self.finish(true)
self.executing(false)
}
}
General information
IGListKit version: 3.4.0
iOS version(s): 12
CocoaPods/Carthage version: 1.5.3
Xcode version: 10.1
Devices/Simulators affected: All
Reproducible in the demo project? (Yes/No): No demo project
Hello.
I have this issue with IGList kit.
So in my project i have a "Loading more" functionality about images downloaded from my API, paginated.
So there is a class which holds the images
class ProfileImages: ListDiffable {
var nextMaxID: String?
var images: [Images]?
init(nextMaxID: String? = nil, images: [Images]? = []) {
self.images = images
self.nextMaxID = nextMaxID
}
func diffIdentifier() -> NSObjectProtocol {
return (nextMaxID ?? "ProfileImages") as NSObjectProtocol
}
func isEqual(toDiffableObject object: ListDiffable?) -> Bool {
guard self !== object else { return true }
guard let object = object as? ProfileImages else { return false }
return nextMaxID == object.nextMaxID
}
}
In my viewModel i have this function which gives me the above class but with the newest images array without the previous ones, since its paginated.
func updateUserImages(with userID: Int?, and nextMaxID: String, onSuccess: #escaping (ProfileImages) -> Void) {
userService.getUserImages(with: userID, nextMaxId: nextMaxID) { (feedResponse) in
let newProfileImages = ProfileImages(nextMaxID: feedResponse.nextMaxId, images: feedResponse.items)
onSuccess(newProfileImages)
}
}
And in my View Controller, in the scroll delegate of adapter, I have your paradigm from LoadMoreSectionController
extension ProfileViewController: UIScrollViewDelegate {
func scrollViewWillEndDragging(_ scrollView: UIScrollView,
withVelocity velocity: CGPoint,
targetContentOffset: UnsafeMutablePointer<CGPoint>) {
guard let object = self.profileViewModel.viewData.value[1] as? ProfileImages,
let nextMaxID = object.nextMaxID,
var oldImages = object.images else { return }
let distance = scrollView.contentSize.height - (targetContentOffset.pointee.y + scrollView.bounds.height)
if !loading && distance < 200 {
loading = true
adapter.performUpdates(animated: true, completion: nil)
DispatchQueue.global(qos: .default).async {
DispatchQueue.main.async {
self.profileViewModel.updateUserImages(with: self.userService.user.pk, and: nextMaxID, onSuccess: { profileImages in
self.loading = false
oldImages.append(contentsOf: profileImages.images ?? []) // here i update the previews array by appending the new arrays
object.images = oldImages // and here i replace the previews array with the new one which has all the images.
object.nextMaxID = profileImages.nextMaxID
self.adapter.performUpdates(animated: true, completion: nil) // Although if i use `self.adapter.reloadData()` its not crashing although i read on the docs that it's not a proper way to reload stuff.
})
}
}
}
}
}
And when i scroll down it crashes.
2019-02-03 15:31:00.520794+0200 ProjectName [20694:7628667] *** Assertion failure in -[IGListAdapter _visibleSectionControllersFromLayoutAttributes](), /Users/trypow-mac/Desktop/ProjectName/Pods/IGListKit/Source/IGListAdapter.m:515
2019-02-03 15:31:00.527576+0200 ProjectName[20694:7628667] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Section controller nil for cell in section 1'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a3161bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x00000001098b4735 objc_exception_throw + 48
2 CoreFoundation 0x000000010a315f42 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000104fdf940 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4 IGListKit 0x000000010568eb99 -[IGListAdapter _visibleSectionControllersFromLayoutAttributes] + 1273
5 IGListKit 0x000000010568e67c -[IGListAdapter visibleSectionControllers] + 540
6 IGListKit 0x00000001056935a4 -[IGListAdapter scrollViewDidScroll:] + 196
7 UIKitCore 0x000000011333ba5b -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 66
8 UIKitCore 0x00000001133220ef -[UIScrollView setContentOffset:] + 1007
9 UIKitCore 0x00000001133337e5 -[UIScrollView _smoothScrollWithUpdateTime:] + 2967
10 UIKitCore 0x0000000113333bb6 -[UIScrollView _smoothScrollDisplayLink:] + 379
11 QuartzCore 0x00000001063300a2 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 818
12 QuartzCore 0x00000001063fcbb9 _ZL22display_timer_callbackP12__CFMachPortPvlS1_ + 297
13 CoreFoundation 0x000000010a24f5a6 __CFMachPortPerform + 150
14 CoreFoundation 0x000000010a27bf69 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
15 CoreFoundation 0x000000010a27b5bb __CFRunLoopDoSource1 + 459
16 CoreFoundation 0x000000010a275b2e __CFRunLoopRun + 2526
17 CoreFoundation 0x000000010a274e11 CFRunLoopRunSpecific + 625
18 GraphicsServices 0x000000010cef51dd GSEventRunModal + 62
19 UIKitCore 0x0000000112ec181d UIApplicationMain + 140
20 ProjectName 0x0000000102022424 main + 68
21 libdyld.dylib 0x000000010b3ee575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Am I missing something ?
I am getting an exception when I filter and try to delete records from Realm DB. It appears that the records are being deleted. The do / catch however is not responding as I expected. What am I doing wrong?
func deleteRecords (module: String, version:String, workorder: String) {
let realm = try! Realm()
let predicate = NSPredicate(format: "module = %# && version = %# && workorder = %#" , module, version, workorder)
let results = realm.objects(NewRecord.self).filter(predicate)
print("FILTERED: \(results.count) \(results)")
do {
try? realm.write {
for result in results {
print("DELETING: \(result)")
realm.delete(result)
}
}
} catch {
// Catch anything that the above catches didn't catch
print("ERROR THROWN DELETONG")
}
}
The output looks like so:
FILTERED: 2 Results<NewRecord> <0x7f9cb1d27950> (
[0] NewRecord {
id = eaAerator008quantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = quantity;
measure = None;
valueString = 200;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
},
[1] NewRecord {
id = eaAerator008installedQuantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = installedQuantity;
measure = None;
valueString = 150;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
}
)
DELETING: NewRecord {
id = eaAerator008quantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = quantity;
measure = None;
valueString = 200;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
}
DELETING: NewRecord {
id = eaAerator008installedQuantityWRK-000001;
module = eaAerator;
workorder = WRK-000001;
version = 008;
field = installedQuantity;
measure = None;
valueString = 150;
valueData = < — 0 total bytes>;
diStatus = INSTALLED;
}
2017-08-13 23:05:07.982 DSMTracker[925:147376108] *** Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107bbab0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000106d03141 objc_exception_throw + 48
2 Realm 0x00000001055eccf3 _ZL17RLMVerifyAttachedP13RLMObjectBase + 83
3 Realm 0x00000001055ee94c _ZN12_GLOBAL__N_18getBoxedIN5realm10StringDataEEEP11objc_objectP13RLMObjectBasem + 28
4 Realm 0x00000001055ee927 ___ZN12_GLOBAL__N_115makeBoxedGetterIN5realm10StringDataEEEP11objc_objectm_block_invoke + 39
5 DSMTracker 0x00000001044bdfb9 _TFC10DSMTracker23DirectInstallController9tableViewfTCSo11UITableView6commitOSC27UITableViewCellEditingStyle8forRowAtV10Foundation9IndexPath_T_ + 841
6 DSMTracker 0x00000001044be0af _TToFC10DSMTracker23DirectInstallController9tableViewfTCSo11UITableView6commitOSC27UITableViewCellEditingStyle8forRowAtV10Foundation9IndexPath_T_ + 95
7 UIKit 0x000000010942ec8c -[UITableView _animateDeletionOfRowWithCell:] + 172
8 UIKit 0x0000000109404289 __52-[UITableView _swipeActionButtonsForRowAtIndexPath:]_block_invoke + 84
9 UIKit 0x0000000109430334 -[UITableView _actionButton:pushedInCell:] + 212
10 UIKit 0x0000000109690d75 -[UITableViewCell _actionButtonPushed:] + 82
11 UIKit 0x00000001092c1d22 -[UIApplication sendAction:to:from:forEvent:] + 83
12 UIKit 0x000000010944625c -[UIControl sendAction:to:forEvent:] + 67
13 UIKit 0x0000000109446577 -[UIControl _sendActionsForEvents:withEvent:] + 450
14 UIKit 0x00000001094454b2 -[UIControl touchesEnded:withEvent:] + 618
15 UIKit 0x00000001097eaea9 _UIGestureEnvironmentSortAndSendDelayedTouches + 5553
16 UIKit 0x00000001097e5ec0 _UIGestureEnvironmentUpdate + 1409
17 UIKit 0x00000001097e58f3 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
18 UIKit 0x00000001097e4aba -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
19 UIKit 0x0000000109330b9a -[UIWindow sendEvent:] + 4092
20 UIKit 0x00000001092dd7b0 -[UIApplication sendEvent:] + 352
21 UIKit 0x0000000109ac0adc __dispatchPreprocessedEventFromEventQueue + 2926
22 UIKit 0x0000000109ab8a3a __handleEventQueue + 1122
23 CoreFoundation 0x0000000107b60c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x0000000107b460cf __CFRunLoopDoSources0 + 527
25 CoreFoundation 0x0000000107b455ff __CFRunLoopRun + 911
26 CoreFoundation 0x0000000107b45016 CFRunLoopRunSpecific + 406
27 GraphicsServices 0x0000000110337a24 GSEventRunModal + 62
28 UIKit 0x00000001092c00d4 UIApplicationMain + 159
29 DSMTracker 0x00000001048cad27 main + 55
30 libdyld.dylib 0x000000010ca6d65d start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I am using JavaScriptCore with multiple threads on iOS 9.3. One JSContext is shared by all the threads. The app crashes sometimes. Does anybody knows what is going on ?
func callFunction(function:String, date:NSDate, dataConfiguration:CDTimePeriodConfiguration, viz:CDViz, didFinish:((response:[String:AnyObject]?, error:NSError?) -> Void)?){
guard let jsonString = self.jsonString(self.apiOptions(date, dataConfiguration: dataConfiguration, viz: viz)) else{
let error = Error.errorWithCode(.ParametersMissing, failureReason: "Cannot create Rocket APIOptions")
didFinish?(response: nil, error: error)
return
}
let randomCallBackFunctionName = "callBackFromJS\(Int64(NSDate().timeIntervalSince1970 * 1000))\(random() % 100000)"
let callBackClosure: #convention(block) (response: [String:AnyObject]?, error: String?) -> Void = {
[weak self]
(response: [String:AnyObject]?, error: String?) -> Void in
var errorMessage:String? = error
if error == "null"{
errorMessage = nil
}
dispatch_async(dispatch_get_main_queue()) {
if let response = response where errorMessage == nil{
didFinish?(response: response, error: nil)
}
else{
if errorMessage == nil && response == nil{
errorMessage = "No reponse from Rocket"
}
let error = Error.errorWithCode(.RocketError, failureReason: errorMessage ?? "Rocket failed for unknown reason")
didFinish?(response: response, error: error)
self?.context.setObject(nil, forKeyedSubscript: randomCallBackFunctionName)
}
}
}
context.setObject(unsafeBitCast(callBackClosure, AnyObject.self), forKeyedSubscript: randomCallBackFunctionName)
let js = "var options = \(jsonString) ; Rocket.\(function)(options).then(function(res) { \(randomCallBackFunctionName)(res, null); }).catch(function(err) { \(randomCallBackFunctionName)(null, err); })"
self.context.evaluateScript(js)
}
0 JavaScriptCore 0x000000018533f3d0 JSC::JSLock::lock(long) + 28
1 JavaScriptCore 0x00000001850453f4 JSC::JSLockHolder::JSLockHolder(JSC::VM&) + 48
2 WebCore 0x0000000185e079a0 WebCore::JSGlobalObjectCallback::call() + 64
3 WebCore 0x0000000185aa3dd8 std::__1::__function::__func<WebCore::Document::postTask(WebCore::ScriptExecutionContext::Task)::$_0, std::__1::allocator<WebCore::Document::postTask(WebCore::ScriptExecutionContext::Task)::$_0>, void ()>::operator()() + 116
4 JavaScriptCore 0x0000000184f35540 WTF::callFunctionObject(void*) + 28
5 JavaScriptCore 0x0000000184f354c0 WTF::dispatchFunctionsFromMainThread() + 240
6 Foundation 0x00000001826a7e20 __NSThreadPerformPerform + 336
7 CoreFoundation 0x0000000181c9cefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
8 CoreFoundation 0x0000000181c9c990 __CFRunLoopDoSources0 + 536
9 CoreFoundation 0x0000000181c9a690 __CFRunLoopRun + 720
10 CoreFoundation 0x0000000181bc9680 CFRunLoopRunSpecific + 380
11 WebCore 0x0000000185779998 RunWebThread(void*) + 452
12 libsystem_pthread.dylib 0x000000018194fb28 _pthread_body + 152
13 libsystem_pthread.dylib 0x000000018194fa8c _pthread_start + 152
14 libsystem_pthread.dylib 0x000000018194d028 thread_start + 0
Try to call every JSContext related method and functions in one thread:
Create dispatch_queue:
my_queue = dispatch_queue_create("com.example.subsystem.taskXYZ", NULL);
Call methods and functions:
...
// Sync call
dispatch_sync(my_queue) {
...
}
// Async call
dispatch_async(my_queue) {
....
}
I am getting this crash report from my users. I am not able to reproduce it so only few devices are having this issue.
Thread : Crashed: com.apple.main-thread
0 MY_PROJECT 0x00089fb8 static MY_PROJECT.GCHelper.rematch (MY_PROJECT.GCHelper.Type)(Swift.ImplicitlyUnwrappedOptional) -> () (GCHelper.swift:156)
1 libobjc.A.dylib 0x37624a37 objc_object::sidetable_retain() + 82
2 MY_PROJECT 0x000403f0 MY_PROJECT.GameScene.ButtonFunction (MY_PROJECT.GameScene)() -> () (GameScene.swift:727)
3 MY_PROJECT 0x00052ae0 function signature specialization of MY_PROJECT.GameScene.touchesEnded (MY_PROJECT.GameScene)(Swift.Set, withEvent : ObjectiveC.UIEvent) -> () (GameScene.swift:355)
4 MY_PROJECT 0x0003d7ac #objc MY_PROJECT.GameScene.touchesEnded (MY_PROJECT.GameScene)(Swift.Set, withEvent : ObjectiveC.UIEvent) -> () (GameScene.swift)
5 SpriteKit 0x2c668755 -[SKView touchesEnded:withEvent:] + 896
6 UIKit 0x2c7fc133 -[UIWindow _sendTouchesForEvent:] + 522
7 UIKit 0x2c7f5a41 -[UIWindow sendEvent:] + 540
8 UIKit 0x2c7cbc05 -[UIApplication sendEvent:] + 196
9 UIKit 0x2ca4231f _UIApplicationHandleEventFromQueueEvent + 14538
10 UIKit 0x2c7ca607 _UIApplicationHandleEventQueue + 1350
11 CoreFoundation 0x2915722f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
12 CoreFoundation 0x29156643 __CFRunLoopDoSources0 + 222
13 CoreFoundation 0x29154cc1 __CFRunLoopRun + 768
14 CoreFoundation 0x290a09a1 CFRunLoopRunSpecific + 476
15 CoreFoundation 0x290a07b3 CFRunLoopRunInMode + 106
16 GraphicsServices 0x3085f1a9 GSEventRunModal + 136
17 UIKit 0x2c82b695 UIApplicationMain + 1440
18 MY_PROJECT 0x00086790 main (AppDelegate.swift:16)
19 libdyld.dylib 0x37bb2aaf start + 2
Below is my rematch function from GCHelper class.
class func rematch(match:GKTurnBasedMatch!){
GCHelper.sharedInstance.rematch(match)
}
func rematch(match:GKTurnBasedMatch!){
match.rematchWithCompletionHandler({ (mMatch:GKTurnBasedMatch!, error:NSError!) -> Void in
if(error != nil){
println("\(error.description)")
} else{
println("rematch")
for var i = 0; i < mMatch.participants.count; i++ {
let participants = mMatch.participants as NSArray
let part = participants.objectAtIndex(i) as! GKTurnBasedParticipant
println("part \(i) \(part.description)")
if let playerID = part.playerID {
if(part.playerID != GKLocalPlayer.localPlayer().playerID){
self.opponentName = part.player.displayName
}
} else{
self.opponentName = "Opponent"
}
// println("participant name is \(part.playerID.)")
}
println("participant name is \(self.opponentName)")
self.delegate?.enterRematch(match,opponentName: self.opponentName)
}
})
}
And this is how I call rematch in my GameScene class.
GCHelper.rematch(self.currentTurnBasedMatch)
I don't even know at which line exactly the crash is happening. Anyone have any ideas?