如何从 TestFlight 获取的 CrashLog 判断错误的确切位置

How to Determine the Exact Location of Error from CrashLog Obtained from TestFlight

我从 testflight 获得了崩溃日志。

crashlog.crash

Incident Identifier: F9255190-FC14-48E9-8C02-A54D5A410CBE
Beta Identifier:     F6E379C0-91F6-4A43-9CD1-C922ACA4126E
Hardware Model:      iPhone10,2
Process:             ARMail [22660]
Path:                /private/var/containers/Bundle/Application/225B1C6F-91C7-4B8A-B1A8-5ABE9211EE1F/ARMail.app/ARMail
Identifier:          com.BradleyFrench.ARMail
Version:             15 (1.0)
AppStoreTools:       11C29
AppVariant:          1:iPhone10,2:13
Beta:                YES
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.BradleyFrench.ARMail [4315]


Date/Time:           2020-03-02 16:42:42.7223 -0500
Launch Time:         2020-03-02 16:24:16.7464 -0500
OS Version:          iPhone OS 13.3.1 (17D50)
Release Type:        User
Baseband Version:    5.30.01
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001c3d03aa4
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [22660]
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libswiftCore.dylib              0x00000001c3d03aa4 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtFTf4xxnnn_n + 440 (AssertCommon.swift:132)
1   libswiftCore.dylib              0x00000001c3d03aa4 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtFTf4xxnnn_n + 440 (AssertCommon.swift:132)
2   libswiftCore.dylib              0x00000001c3b2071c $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 32 (<compiler-generated>:0)
3   DepthCamera                     0x00000001017e911c AVCaptureDevice.selectDepthFormat() + 3488 (AVCaptureDevice+Extension.swift:0)
4   DepthCamera                     0x00000001017fe010 VideoCapture.setupCaptureVideoDevice(with:) + 476 (VideoCapture.swift:186)
5   DepthCamera                     0x00000001017ff858 specialized VideoCapture.init(cameraMode:cameraType:preferredSpec:previewContainer:) + 2020 (VideoCapture.swift:100)
6   DepthCamera                     0x00000001017ebe04 RealtimeDepthMaskViewController.viewDidLoad() + 472 (RealTimeDepthViewController.swift:0)
7   DepthCamera                     0x00000001017ece28 @objc RealtimeDepthMaskViewController.viewDidLoad() + 28 (<compiler-generated>:0)
8   UIKitCore                       0x00000001ba2ad448 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 100 (UIViewController.m:2283)
9   UIKitCore                       0x00000001ba2b1f58 -[UIViewController loadViewIfRequired] + 936 (UIViewController.m:3382)
10  UIKitCore                       0x00000001ba2b2360 -[UIViewController view] + 28 (UIViewController.m:3404)
11  UIKitCore                       0x00000001ba1dca24 -[_UIFullscreenPresentationController _setPresentedViewController:] + 80 (_UIFullscreenPresentationController.m:227)
12  UIKitCore                       0x00000001ba1d0434 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 188 (UIPresentationController.m:200)
13  UIKitCore                       0x00000001ba2c1bf8 -[UIViewController _presentViewController:withAnimationController:completion:] + 2528 (UIViewController.m:7283)
14  UIKitCore                       0x00000001ba2c4794 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 104 (UIViewController.m:7731)
15  UIKitCore                       0x00000001ba2c4c90 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508 (UIViewController.m:7832)
16  UIKitCore                       0x00000001ba2c46e4 -[UIViewController _presentViewController:animated:completion:] + 196 (UIViewController.m:7738)
17  UIKitCore                       0x00000001ba2c494c -[UIViewController presentViewController:animated:completion:] + 160 (UIViewController.m:7776)
18  ARMail                          0x0000000101019508 ObtainVideoViewController.takePicture() + 292 (ObtainVideoViewController.swift:333)
19  ARMail                          0x00000001010297e0 closure #2 in MyImageView.pressedButton() + 216 (MyImageView.swift:115)
20  ARMail                          0x0000000101013c44 thunk for @escaping @callee_guaranteed (@guaranteed UIAlertAction) -> () + 48 (<compiler-generated>:0)
21  UIKitCore                       0x00000001b9f1eed0 -[UIAlertController _invokeHandlersForAction:] + 108 (UIAlertController.m:1075)
22  UIKitCore                       0x00000001b9f1f82c __103-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:dismissC... + 28 (UIAlertController.m:1240)
23  UIKitCore                       0x00000001ba1d0fe0 -[UIPresentationController transitionDidFinish:] + 952 (UIPresentationController.m:462)
24  UIKitCore                       0x00000001ba1d576c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.503 + 208 (UIPresentationController.m:1086)
25  UIKitCore                       0x00000001ba2d95a8 -[_UIViewControllerTransitionContext completeTransition:] + 100 (UIViewControllerTransitioning.m:285)
26  UIKitCore                       0x00000001bad55d90 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 588 (UIView.m:14023)
27  UIKitCore                       0x00000001bad29c70 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 244 (UIView.m:0)
28  UIKitCore                       0x00000001bad2a178 -[UIViewAnimationState animationDidStop:finished:] + 240 (UIView.m:2219)
29  UIKitCore                       0x00000001bad2a2c8 -[UIViewAnimationState animationDidStop:finished:] + 576 (UIView.m:2238)
30  QuartzCore                      0x00000001bd2dbdac CA::Layer::run_animation_callbacks(void*) + 276 (CALayer.mm:6832)
31  libdispatch.dylib               0x00000001b6513184 _dispatch_client_callout + 16 (object.m:495)
32  libdispatch.dylib               0x00000001b64f634c _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 996 (inline_internal.h:2484)
33  CoreFoundation                  0x00000001b67c45e4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1749)
34  CoreFoundation                  0x00000001b67bf5d8 __CFRunLoopRun + 2004 (CFRunLoop.c:3069)
35  CoreFoundation                  0x00000001b67beadc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
36  GraphicsServices                0x00000001c075f328 GSEventRunModal + 104 (GSEvent.c:2246)
37  UIKitCore                       0x00000001ba8cc63c UIApplicationMain + 1936 (UIApplication.m:4773)
38  ARMail                          0x0000000100ffec90 main + 68 (ViewController.swift:13)
39  libdyld.dylib                   0x00000001b6648360 start + 4

由于space限制,我只提供了相关的崩溃信息。

这个日志是给我的,我可以双击它并把它插入XCode。从那里,我能够看到错误的确切位置。但是,在这种情况下,我无法确定确切的问题。注意 thread 0 我们可以看到最后一个错误发生在 3 DepthCamera 0x00000001017e911c AVCaptureDevice.selectDepthFormat() + 3488 (AVCaptureDevice+Extension.swift:0)

selectDepthFormat() 是 class 类型 AVCaptureDevice 的扩展。此外,从 Apple Docs 中,我们知道 assertionFailure() 源于一个可选的 nil 值。现在,我知道如何实现这一点,而不关心最佳编程实践。我想知道如何确定方法.selectDepthDFormat()中的确切位置以及为什么错误只显示调用方法的错误,而不是方法的确切问题。

例如,当我将 crashlog.crash 插入 XCode 时,我收到

当我觉得我应该在此处某处的方法中收到错误时

注意:我将代码作为图像提供,以指示崩溃日志中的错误显示错误的位置,并且该错误似乎应该在方法中而不是在调用开始处。

崩溃是由于 fatalError

之一

这个

或这个

缺少 available/supported 格式是正常情况,您必须为最终用户优雅地处理它,显示一些反馈,如警报、图标等。但不要崩溃。

实际上,我根本不建议在部署构建中保留 fatalError() - 它没有用,只会让用户不高兴 - 没有人喜欢崩溃的应用程序。