CIFilter 导致 iPhone 11 和 XR 崩溃

CIFilter causes a crash on iPhone 11 and XR

CIFilter 的所有初始化导致某些设备崩溃 iPhone 11 和 iPhone XR。 iOS 版本 13.3.1、13.4.1。

我尝试导入:

import CoreImage
import CoreImage.CIFilter
import CoreImage.CIFilterBuiltins

但是它不起作用! 我使用 xCode 11.4.1 & xCode 11.5

我试过几种方法:

        if let filter = CIFilter(name: "CIQRCodeGenerator") {

        filter.setValue(data, forKey: "inputMessage")
        let transform = CGAffineTransform(scaleX: 5, y: 5)

        if let output = filter.outputImage?.transformed(by: transform) {
            return UIImage(ciImage: output)
        }
    }

或者这个:

let filter = CIFilter.qrCodeGenerator()

我也尝试在目标设置中明确地link到CoreImage.framework

崩溃日志:

Crashed: com.apple.main-thread
0  CocoaDebug                     0x1023a0adc perform_rebinding_with_section + 332
1  CocoaDebug                     0x1023a087c rebind_symbols_for_image + 416
2  libdyld.dylib                  0x1999c3f4c invocation function for block in dyld3::AllImages::runImageCallbacks(dyld3::Array<dyld3::LoadedImage> const&) + 244
3  libdyld.dylib                  0x1999c3768 dyld3::AllImages::runImageCallbacks(dyld3::Array<dyld3::LoadedImage> const&) + 160
4  libdyld.dylib                  0x1999c8dd8 dyld3::AllImages::loadImage(Diagnostics&, unsigned int, dyld3::closure::DlopenClosure const*, bool, bool, bool, bool) + 580
5  libdyld.dylib                  0x1999c89ec dyld3::AllImages::dlopen(Diagnostics&, char const*, bool, bool, bool, bool, bool, void const*) + 868
6  libdyld.dylib                  0x1999ca434 dyld3::dlopen_internal(char const*, int, void*) + 364
7  libdyld.dylib                  0x1999bd6c0 dlopen + 116
8  CoreFoundation                 0x199bcf5c8 _CFBundleDlfcnLoadBundle + 156
9  CoreFoundation                 0x199af1eac _CFBundleLoadExecutableAndReturnError + 372
10 Foundation                     0x199ec27a8 -[NSBundle loadAndReturnError:] + 316
11 CoreImage                      0x19b479bcc invocation function for block in register_more_builtins(void (NSString*) block_pointer) + 804
12 libdispatch.dylib              0x19986833c _dispatch_client_callout + 20
13 libdispatch.dylib              0x199869a68 _dispatch_once_callout + 32
14 CoreImage                      0x19b476318 register_more_builtins(void (NSString*) block_pointer) + 304
15 CoreImage                      0x19b476b40 classNameIsSystemFilter(NSString*) + 112
16 CoreImage                      0x19b476dbc +[CIFilter(CIFilterRegistryPrivate) filterWithName:setDefaults:] + 396
17 MYApp                          0x100656598 QRCodeViewController.generateQRCode(from:) + 4370490776 (<compiler-generated>:4370490776)
18 MYApp                          0x1006563a4 QRCodeViewController.viewDidLoad() + 28 (QRCodeViewController.swift:28)
19 MYApp                          0x10065642c @objc QRCodeViewController.viewDidLoad() + 4370490412 (<compiler-generated>:4370490412)
20 UIKitCore                      0x19d6a236c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
21 UIKitCore                      0x19d6a6f20 -[UIViewController loadViewIfRequired] + 952
22 UIKitCore                      0x19d6a730c -[UIViewController view] + 32
23 UIKitCore                      0x19d602fa4 -[UINavigationController _startCustomTransition:] + 1148
24 UIKitCore                      0x19d617478 -[UINavigationController _startDeferredTransitionIfNeeded:] + 692
25 UIKitCore                      0x19d618818 -[UINavigationController __viewWillLayoutSubviews] + 176
26 UIKitCore                      0x19d5fb4fc -[UILayoutContainerView layoutSubviews] + 228
27 UIKitCore                      0x19e1de6a0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2168
28 QuartzCore                     0x1a08314a0 -[CALayer layoutSublayers] + 292
29 QuartzCore                     0x1a08318e0 CA::Layer::layout_if_needed(CA::Transaction*) + 472
30 QuartzCore                     0x1a0843dc4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144
31 QuartzCore                     0x1a0788884 CA::Context::commit_transaction(CA::Transaction*, double) + 304
32 QuartzCore                     0x1a07b33d0 CA::Transaction::commit() + 656
33 QuartzCore                     0x1a07b3fc8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 96
34 CoreFoundation                 0x199b42c54 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
35 CoreFoundation                 0x199b3d8e4 __CFRunLoopDoObservers + 420
36 CoreFoundation                 0x199b3dd84 __CFRunLoopRun + 1020
37 CoreFoundation                 0x199b3d660 CFRunLoopRunSpecific + 480
38 GraphicsServices               0x1a3f4e604 GSEventRunModal + 164
39 UIKitCore                      0x19dd1215c UIApplicationMain + 1944
40 MYApp                          0x100518e54 main + 4369190484 (<compiler-generated>:4369190484)
41 libdyld.dylib                  0x1999b91ec start + 4

使用模拟器效果很好。

有人会知道吗? 谢谢

我想出了解决方法。 问题出在第三方 CocoaDebug ! 我移除了 pod,我没有再崩溃了! 谢谢!