3

我收到了来自生产的崩溃日志,无法理解如何重现它。根据我掌握的信息,它只在装有 iOS 9.3 的 iPad 上发生过一次。

这次崩溃发生在我的最新版本之后,我使用 VIPER 方法来表达我的一些观点。我已经搜索了互联网,并认为我的问题可能是由 Leo Natan 在他的评论中描述的类似问题引起。但我不确定并且想知道如何重现和解决这个问题。我什至不明白正在呈现什么弹出框。

这是我的崩溃日志(已删除二进制图像):

Incident Identifier: 9476D9A8-1468-4A68-8F71-DA8B7F083172
CrashReporter Key:   21204b1ae5f574c63137a73b5a4a50aeb35fe287
Hardware Model:      iPad2,5
Process:             CafeManager [24058]
Path:                /private/var/containers/Bundle/Application/FF4319BD-9D3B-4178-B5FB-0B4641CB9D6E/CafeManager.app/CafeManager
Identifier:          iGlock.CafeManager.com
Version:             1 (1.2.5)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2018-08-27 03:16:59.59 +0300
Launch Time:         2018-08-27 03:04:59.59 +0300
OS Version:          iOS 9.3.5 (13G36)
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                  0x210df916 __exceptionPreprocess + 122 (NSException.m:162)
1   libobjc.A.dylib                 0x2087ae12 objc_exception_throw + 34 (objc-exception.mm:531)
2   UIKit                           0x25f4b480 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3336 (UIPopoverPresentationController.m:1201)
3   UIKit                           0x259abe8e __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1794 (UIPresentationController.m:1137)
4   UIKit                           0x259a9dae __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 378 (UIPresentationController.m:705)
5   UIKit                           0x259034c4 _runAfterCACommitDeferredBlocks + 264 (UIApplication.m:2386)
6   UIKit                           0x2590f7d6 _cleanUpAfterCAFlushAndRunDeferredBlocks + 86 (UIApplication.m:2365)
7   UIKit                           0x2564db18 _afterCACommitHandler + 80 (UIApplication.m:2416)
8   CoreFoundation                  0x210a16c4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16 (CFRunLoop.c:1620)
9   CoreFoundation                  0x2109f9c8 __CFRunLoopDoObservers + 276 (CFRunLoop.c:1716)
10  CoreFoundation                  0x2109fdfa __CFRunLoopRun + 954 (CFRunLoop.c:2558)
11  CoreFoundation                  0x20fef224 CFRunLoopRunSpecific + 516 (CFRunLoop.c:2814)
12  CoreFoundation                  0x20fef010 CFRunLoopRunInMode + 104 (CFRunLoop.c:2844)
13  GraphicsServices                0x225dfac4 GSEventRunModal + 156 (GSEvent.c:2245)
14  UIKit                           0x256c3184 UIApplicationMain + 140 (UIApplication.m:3772)
15  CafeManager                     0x9973c main + 48 (AppDelegate.swift:20)
16  libdyld.dylib                   0x20c9786e tlv_get_addr + 42 (threadLocalHelpers.s:311)

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x20d6ac5c __pthread_kill + 8
1   libsystem_pthread.dylib         0x20e14732 pthread_kill + 62 (pthread.c:1247)
2   libsystem_c.dylib               0x20cff0ac abort + 108 (abort.c:91)
3   libc++abi.dylib                 0x20856ae4 abort_message + 108 (abort_message.cpp:47)
4   libc++abi.dylib                 0x2086f69e default_terminate_handler() + 266 (cxa_default_handlers.cpp:67)
5   libobjc.A.dylib                 0x2087b0b0 _objc_terminate() + 192 (objc-exception.mm:678)
6   libc++abi.dylib                 0x2086ce16 std::__terminate(void (*)()) + 78 (cxa_handlers.cpp:67)
7   libc++abi.dylib                 0x2086c8f8 __cxa_rethrow + 100 (cxa_exception.cpp:480)
8   libobjc.A.dylib                 0x2087af5e objc_exception_rethrow + 42 (objc-exception.mm:581)
9   CoreFoundation                  0x20fef2ae CFRunLoopRunSpecific + 654 (CFRunLoop.c:2827)
10  CoreFoundation                  0x20fef014 CFRunLoopRunInMode + 108 (CFRunLoop.c:2844)
11  GraphicsServices                0x225dfac8 GSEventRunModal + 160 (GSEvent.c:2245)
12  UIKit                           0x256c3188 UIApplicationMain + 144 (UIApplication.m:3772)
13  CafeManager                     0x00099740 main + 52 (AppDelegate.swift:20)
14  libdyld.dylib                   0x20c97872 start + 2 (start_glue.s:64)

Thread 1 name:
Thread 1:
0   libsystem_kernel.dylib          0x20d6c2f8 kevent_qos + 24
1   libdispatch.dylib               0x20c61d60 _dispatch_mgr_invoke + 256 (source.c:2542)
2   libdispatch.dylib               0x20c61abe _dispatch_mgr_thread$VARIANT$mp + 38 (source.c:2573)

Thread 2:
0   libsystem_kernel.dylib          0x20d6b864 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x20e11b34 _pthread_wqthread + 1036 (pthread.c:1999)
2   libsystem_pthread.dylib         0x20e11718 start_wqthread + 8 (pthread_asm.s:147)

Thread 3:
0   libsystem_kernel.dylib          0x20d6b864 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x20e11b34 _pthread_wqthread + 1036 (pthread.c:1999)
2   libsystem_pthread.dylib         0x20e11718 start_wqthread + 8 (pthread_asm.s:147)

Thread 4:
0   libsystem_kernel.dylib          0x20d6b864 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x20e11b34 _pthread_wqthread + 1036 (pthread.c:1999)
2   libsystem_pthread.dylib         0x20e11718 start_wqthread + 8 (pthread_asm.s:147)

Thread 5:
0   libsystem_kernel.dylib          0x20d6b864 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x20e11b34 _pthread_wqthread + 1036 (pthread.c:1999)
2   libsystem_pthread.dylib         0x20e11718 start_wqthread + 8 (pthread_asm.s:147)

Thread 6:
0   libsystem_kernel.dylib          0x20d6b864 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x20e11b34 _pthread_wqthread + 1036 (pthread.c:1999)
2   libsystem_pthread.dylib         0x20e11718 start_wqthread + 8 (pthread_asm.s:147)

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x00000000    r1: 0x00000000      r2: 0x00000000      r3: 0x20cf1b1d
    r4: 0x00000006    r5: 0x38084000      r6: 0x372c2304      r7: 0x002b44e8
    r8: 0x1778f4e0    r9: 0x208708fd     r10: 0x398938a5     r11: 0x1778f504
    ip: 0x00000148    sp: 0x002b44dc      lr: 0x20e14733      pc: 0x20d6ac5c
  cpsr: 0x00000010

Binary Images:

我有一种感觉,当我的一个 VIPER 模块被调用时,可能会发生这种崩溃。它应该以这种方式工作:

当前视图控制器 (MVC) 通过调用此方法组装模块:

class PeriodPickerAssembly: NSObject {
    static func assembleModule() -> PeriodPickerRouter {
        let router = PeriodPickerRouter()
        let presenter = PeriodPickerPresenter()
        let viewController = UIStoryboard.init(name: "PeriodPicker", bundle: nil).instantiateViewController(withIdentifier: "PeriodPickerViewController") as! PeriodPickerViewController

        viewController.periodPickerPresenter = presenter

        presenter.view = viewController
        presenter.router = router

        router.presenter = presenter
        router.view = viewController

        return router
    }
}

然后方法 choosePeriodWithParams 将视图显示为弹出框:

    class PeriodPickerRouter: NSObject, PeriodPickerRouterInterface, PeriodPickerInterface {

    weak var presenter: PeriodPickerPresenter!
    weak var delegate: PeriodPickerDelegate!
    weak var view : UIViewController!

    // Ingoing
    func choosePeriodWithParams(startDateLimit: Date?, endDateLimit: Date?, currentStartDate: Date?, currentEndDate: Date?) {
        view.modalPresentationStyle = .popover
        view.popoverPresentationController?.sourceView = UIApplication.topViewController()?.view
        appDelegate.window?.rootViewController?.present(view!, animated: true, completion: nil)

        presenter.configureDatePickers(startDateLimit: startDateLimit, endDateLimit: endDateLimit, currentStartDate: currentStartDate, currentEndDate: currentEndDate)
    }

    // Outgoing
    func dismissPeriodPicker() {
        view.dismiss(animated: true, completion: nil)
    }

    func periodPickerDidChoosePeriod(startDate: Date, endDate: Date) {
        delegate.periodPickerDidChoosePeriod(startDate: startDate, endDate: endDate)
        view.dismiss(animated: true, completion: nil)
    }}

我认为这两行可能与问题有关。但不确定如何证明:

view.popoverPresentationController?.sourceView = UIApplication.topViewController()?.view
        appDelegate.window?.rootViewController?.present(view!, animated: true, completion: nil)
4

1 回答 1

2

最后我在测试过程中发现了这个问题。这是一个愚蠢且众所周知的问题(真遗憾,我忘了在 iPad 上正确测试我的应用程序)。但我仍然不明白如何分析该崩溃报告。

错误具有相同的文本,但行号除外(没关系,因为代码已更改,并且我在不同的弹出窗口中遇到了这个问题)。

2018-09-27 22:37:53.952 CafeManager[5235:253337] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x7fd2a0335c90>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.  If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001099a6d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000109094deb objc_exception_throw + 48
    2   UIKit                               0x000000010ae3d396 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3407
    3   UIKit                               0x000000010a5d3f44 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2035
    4   UIKit                               0x000000010a5d1b76 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 309
    5   UIKit                               0x000000010a46ff62 _runAfterCACommitDeferredBlocks + 317
    6   UIKit                               0x000000010a483e4c _cleanUpAfterCAFlushAndRunDeferredBlocks + 95
    7   UIKit                               0x000000010a490147 _afterCACommitHandler + 90
    8   CoreFoundation                      0x00000001098cbc37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    9   CoreFoundation                      0x00000001098cbba7 __CFRunLoopDoObservers + 391
    10  CoreFoundation                      0x00000001098c17fb __CFRunLoopRun + 1147
    11  CoreFoundation                      0x00000001098c10f8 CFRunLoopRunSpecific + 488
    12  GraphicsServices                    0x000000010f54cad2 GSEventRunModal + 161
    13  UIKit                               0x000000010a463f09 UIApplicationMain + 171
    14  CafeManager                         0x0000000108227134 main + 68
    15  libdyld.dylib                       0x000000010dd0992d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

升级版:

2018-09-27 22:37:53.952 CafeManager [5235:253337] *** 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“您的应用程序已呈现 UIAlertController () 样式的 UIAlertControllerStyleActionSheet。具有此样式的 UIAlertController 的 modalPresentationStyle 是 UIModalPresentationPopover。您必须通过警报控制器的 popoverPresentationController 提供此弹出窗口的位置信息。您必须提供 sourceView 和 sourceRect 或 barButtonItem。如果在您呈现警报控制器时不知道此信息,您可以在 UIPopoverPresentationControllerDelegate 方法 -prepareForPopoverPresentation 中提供它。

使用 iOS 8 在 iPad 上正确呈现 UIAlertController

我希望它会帮助某人。

于 2018-09-27T21:12:36.910 回答