AVCapturePhotoOutput崩溃

时间:2018-05-08 01:20:40

标签: ios swift avcapturesession avcapturephotooutput

我的应用因崩溃而被拒绝。我无法在本地重现崩溃,但由于Apple提供的崩溃日志,我能够将违规代码缩小到这个范围:

func capturePhoto() {
    let photoOutputSettings = AVCapturePhotoSettings()
    photoOutputSettings.flashMode = Settings.shared.flash
    photoOutputSettings.isAutoStillImageStabilizationEnabled = true
    photoOutputSettings.isHighResolutionPhotoEnabled = true

    self.photoOutput.capturePhoto(with: photoOutputSettings, delegate: self) //crash
}

此外,评论者提到他们正在测试运行iOS 11.3.1的iPad。以下是崩溃日志的相关部分:

{"app_name":"xxxxx","timestamp":"2018-05-07 15:19:10.13 -0700","app_version":"1.0","slice_uuid":"059c64b6-ea13-3bca-97c0-e05dd5eed102","adam_id":1341531999,"build_version":"7","bundleID":"xxxxx","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 11.3.1 (15E302)","incident_id":"4B4E6531-6F8E-4F2A-B262-94685C5FF287","name":"xxxxx"}
Incident Identifier: 4B4E6531-6F8E-4F2A-B262-94685C5FF287
CrashReporter Key:   357841d912f2df927b24861ec18fb870765ae9bd
Hardware Model:      xxx1
Process:             xxxxx [1938]
Path:                /private/var/containers/Bundle/Application/40DDE031-CEDC-4197-989C-C3DEA953492F/xxxxx.app/xxxxx
Identifier:          xxxxx
Version:             7 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           xxxxx [1139]


Date/Time:           2018-05-07 15:19:09.9972 -0700
Launch Time:         2018-05-07 15:19:07.3874 -0700
OS Version:          iPhone OS 11.3.1 (15E302)
Baseband Version:    n/a
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Application Specific Information:
abort() called

Filtered syslog:
None found

Last Exception Backtrace:
0   CoreFoundation                  0x183d42d8c __exceptionPreprocess + 228
1   libobjc.A.dylib                 0x182efc5ec objc_exception_throw + 55
2   AVFoundation                    0x1898cadc4 -[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] + 811
3   QuickRecord                     0x10498e4b0 specialized MainViewController.capturePhotoButtonTapped(_:) + 74928 (MainViewController.swift:210)
4   QuickRecord                     0x10498be34 @objc MainViewController.capturePhotoButtonTapped(_:) + 65076 (MainViewController.swift:187)
5   UIKit                           0x18da726c8 -[UIApplication sendAction:to:from:forEvent:] + 95
6   UIKit                           0x18db938a4 -[UIControl sendAction:to:forEvent:] + 79
7   UIKit                           0x18da7877c -[UIControl _sendActionsForEvents:withEvent:] + 439
8   UIKit                           0x18dbae1dc -[UIControl touchesEnded:withEvent:] + 571
9   QuickRecord                     0x104989c28 specialized TouchAnimationButton.touchesEnded(_:with:) + 56360 (TouchAnimationButton.swift:64)
10  QuickRecord                     0x104988c7c @objc TouchAnimationButton.touchesBegan+ 52348 (_:with:) + 139
11  UIKit                           0x18daf5a48 -[UIWindow _sendTouchesForEvent:] + 2427
12  UIKit                           0x18daea8f8 -[UIWindow sendEvent:] + 3159
13  UIKit                           0x18dae9238 -[UIApplication sendEvent:] + 339
14  UIKit                           0x18e2cac0c __dispatchPreprocessedEventFromEventQueue + 2339
15  UIKit                           0x18e2cd1b8 __handleEventQueueInternal + 4743
16  UIKit                           0x18e2c6258 __handleHIDEventFetcherDrain + 151
17  CoreFoundation                  0x183ceb404 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 23
18  CoreFoundation                  0x183ceac2c __CFRunLoopDoSources0 + 275
19  CoreFoundation                  0x183ce879c __CFRunLoopRun + 1203
20  CoreFoundation                  0x183c08da8 CFRunLoopRunSpecific + 551
21  GraphicsServices                0x185beb020 GSEventRunModal + 99
22  UIKit                           0x18dbe978c UIApplicationMain + 235
23  QuickRecord                     0x104982de0 main + 28128 (PermissionsViewController.swift:14)
24  libdyld.dylib                   0x183699fc0 start + 3


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001837c92ec __pthread_kill + 8
1   libsystem_pthread.dylib         0x000000018396a288 pthread_kill$VARIANT$mp + 376
2   libsystem_c.dylib               0x0000000183737d0c abort + 140
3   libc++abi.dylib                 0x0000000182ed22c8 __cxa_bad_cast + 0
4   libc++abi.dylib                 0x0000000182ed2470 default_unexpected_handler+ 5232 () + 0
5   libobjc.A.dylib                 0x0000000182efc8d4 _objc_terminate+ 35028 () + 124
6   libc++abi.dylib                 0x0000000182eec37c std::__terminate(void (*)+ 111484 ()) + 16
7   libc++abi.dylib                 0x0000000182eebf78 __cxa_rethrow + 144
8   libobjc.A.dylib                 0x0000000182efc7ac objc_exception_rethrow + 44
9   CoreFoundation                  0x0000000183c08e18 CFRunLoopRunSpecific + 664
10  GraphicsServices                0x0000000185beb020 GSEventRunModal + 100
11  UIKit                           0x000000018dbe978c UIApplicationMain + 236
12  QuickRecord                     0x0000000104982de0 main + 28128 (PermissionsViewController.swift:14)
13  libdyld.dylib                   0x0000000183699fc0 start + 4

知道可能导致此次崩溃的原因是什么?在iPad上如何处理flashMode有什么问题吗?如果是这样,为什么崩溃报告没有提到闪存是其他SO帖子中的问题?任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

这绝对是闪光模式。如果您使用的相机不带闪光灯(例如iPad相机),则当您调用capturePhoto并将闪光模式的参数.off传递给AVCaptureDevice.hasFlash时,您的应用将崩溃。

要检查相机是否具有闪光灯,请使用该相机上的elasticsearch-1: image: elasticsearch container_name: elasticsearch-1 ports: - "9200:9200" - "9300:9300" volumes: - ./data/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml command: elasticsearch kibana-frontend: image: kibana:latest container_name: kibana-frontend ports: - "5601:5601" links: - elasticsearch-1:elasticsearch 属性。