Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Crashlytics Crash Report (partial apply)

Having trouble understanding a crash report in Crashlytics. I do not have much experience in analyzing crash report. Appreciate your help.

This is the crash log:

Crashed: com.apple.main-thread
    0  My App                    0x100f77180 specialized closure #1 in closure #1 in ConfirmItemCheckInViewController.doneButtonPressed() (ConfirmItemCheckInViewController.swift:175)
    1  My App                    0x100f77c94 partial apply for closure #1 in closure #1 in ConfirmItemCheckInViewController.doneButtonPressed() (ConfirmItemCheckInViewController.swift)
    2  My App                    0x100f95650 thunk for @callee_owned (@owned UIAlertAction) -> () (SettingsViewController.swift)
    3  UIKit                          0x18e4f5cf4 -[UIAlertController _invokeHandlersForAction:] + 108
    4  UIKit                          0x18e4f66ec __103-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:dismissCompletion:]_block_invoke.459 + 28
    5  UIKit                          0x18e33b030 -[UIPresentationController transitionDidFinish:] + 1320
    6  UIKit                          0x18e33ea20 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 188
    7  UIKit                          0x18e10a9d8 -[_UIViewControllerTransitionContext completeTransition:] + 116
    8  UIKit                          0x18e02fd7c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 764
    9  UIKit                          0x18e02f70c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
    10 UIKit                          0x18e02f418 -[UIViewAnimationState animationDidStop:finished:] + 296
    11 UIKit                          0x18e02f4b8 -[UIViewAnimationState animationDidStop:finished:] + 456
    12 QuartzCore                     0x188bd3d6c CA::Layer::run_animation_callbacks(void*) + 284
    13 libdispatch.dylib              0x18456d048 _dispatch_client_callout + 16
    14 libdispatch.dylib              0x184579b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016
    15 CoreFoundation                 0x184b8ff20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
    16 CoreFoundation                 0x184b8dafc __CFRunLoopRun + 2012
    17 CoreFoundation                 0x184aae2d8 CFRunLoopRunSpecific + 436
    18 GraphicsServices               0x18693ff84 GSEventRunModal + 100
    19 UIKit                          0x18e05b880 UIApplicationMain + 208
    20 My App                    0x100f4f924 main (AppDelegate.swift:15)
    21 libdyld.dylib                  0x1845d256c start + 4

Update: Added the code for doneButtonPressed. I do not make any changes to this part recently. This scene do not have any crash for 1.5 years since it is released.

 func doneButtonPressed() {
        if let signImage = signatureImage {
            if let scheduleID = scheduleID {
                if let driverID = driverID {
                    if let customerID = customerID {
                        let progressHUD = MBProgressHUD.showAdded(to: self.view, animated: true)
                        progressHUD.label.text = "Checking Item In"
                        NetworkLoader.sharedLoader.confirmCheckIn(signImage, shipmentID: scheduleID, customerID: customerID, driverID: driverID, items: items, valueAddedItems: self.valueAddedItemsList, completion: { (networkStatus, status) in
                            progressHUD.hide(animated: true)
                            if status {
                                // Remove saved signature
                                var index = SignatureData.sharedSignatureData.getSignatureIndex(scheduleID)
                                if index != -1 {
                                    SignatureData.sharedSignatureData.sharedSignatureItems.remove(at: index)
                                }
                                // Remove saved item
                                index = PickupItemData.sharedPickupItemData.getPickupItemIndex(scheduleID)
                                if index != -1 {
                                    PickupItemData.sharedPickupItemData.sharedPickupItems.remove(at: index)
                                }

                                let alert = UIAlertController(title: "Checked In", message: "", preferredStyle: UIAlertControllerStyle.alert)
                                let alertAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (_) in
                                    let myScheduleNC :UINavigationController = self.storyboard?.instantiateViewController(withIdentifier: "MyScheduleNavController") as! UINavigationController
                                    self.revealViewController().pushFrontViewController(myScheduleNC, animated: true) // LINE 175 IS HERE 

                                })
                                alert.addAction(alertAction)
                                self.present(alert, animated: true, completion: nil)
                            } else {
                                print(networkStatus.networkLoaderErrorDescription)
                                let alert = UIAlertController(title: networkStatus.networkLoaderErrorTitle, message: networkStatus.networkLoaderErrorDescription, preferredStyle: UIAlertControllerStyle.alert)
                                let alertAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil)
                                alert.addAction(alertAction)
                                self.present(alert, animated: true, completion: nil)
                            }
                        })
                    }

                }
            }
        }
    }
like image 654
Clive Teow Avatar asked Dec 10 '22 09:12

Clive Teow


2 Answers

Adding [weak self] in the closure's completion block solves this.
You just stumbled upon a rare situation when self was released and was nil before the completion block was called, making the use of self. crash the application.

like image 67
Bogdan Razvan Avatar answered Dec 30 '22 01:12

Bogdan Razvan


It seems that somethings went wrong in your ConfirmItemCheckInViewController class. And more precisely, this error is in the doneButtonPressed() method at the line 175.

It would be helpful to have the corresponding code.

like image 32
Adrien Avatar answered Dec 30 '22 00:12

Adrien