Я пытаюсь изменить изображение на черно-белое, эти изображения поступают из сервисной службы, и как только я получаю изображение, я применяю фильтр noir, чтобы изменить их на черно-белое. Я получаю это исключение висящего указателя только на iOS 13, другие версии iOS не имеют этой проблемы.
Это код:
extension UIImage {
var noir: UIImage? {
let context = CIContext(options: nil)
guard let currentFilter = CIFilter(name: "CIPhotoEffectNoir") else {
return nil
}
currentFilter.setValue(CIImage(image: self), forKey: kCIInputImageKey)
if let output = currentFilter.outputImage,
let cgImage = context.createCGImage(output, from: output.extent) {
return UIImage(cgImage: cgImage, scale: scale, orientation: imageOrientation)
}
return nil
}
}
Вариант использования:
var member: Faculty? {
didSet {
guard let lecturer = self.member else {
return
}
FacultyService.image(
atPath: lecturer.thumbnailPath,
process: { (image: UIImage) -> UIImage in
if lecturer.Id != nil {
return image.noir!.withRenderingMode(.alwaysOriginal)
} else {
return image.withRenderingMode(.alwaysOriginal)
}
},
success: { [weak self] (path: String, image: UIImage) -> Void in
guard let strongSelf = self else { return }
if path == strongSelf.member?.imagePath {
self.imageButton.setImage(image, for: .normal)
self.imageButton.layer.animate()
}
},
failure: { () -> Void in
})
}
}
Трассировка стека:
Crashed: com.imas.MNT.HTTPSessionSharedCompletionQueue
0 CoreImage 0x19e748aa4 CI::GLContext::init() + 88
1 CoreImage 0x19e748a80 CI::GLContext::init() + 52
2 CoreImage 0x19e748df0 CI::GLContext::GLContext(CI::GLContext::ShareContextInfo, CGColorSpace*, CGColorSpace*, CI::PixelFormat, bool, unsigned long, bool, bool) + 416
3 CoreImage 0x19e748e2c CI::GLContext::GLContext(CI::GLContext::ShareContextInfo, CGColorSpace*, CGColorSpace*, CI::PixelFormat, bool, unsigned long, bool, bool) + 24
4 CoreImage 0x19e5cc988 +[CIContext(Internal) internalContextWithEAGLContext:options:] + 716
5 CoreImage 0x19e5c9d88 -[CIContext initWithOptions:] + 484
6 GetHornet-AppStore 0x1049bf5f8 UIImage.noir.getter + 4330436088 (<compiler-generated>:4330436088)
7 GetHornet-AppStore 0x104d2d2b8 closure #2 in FacultyMemberCell.member.didset + 75 (FacultyMemberCell.swift:75)
8 GetHornet-AppStore 0x104ad7e24 thunk for @escaping @callee_guaranteed (@guaranteed UIImage) -> (@owned UIImage) + 4331585060 (<compiler-generated>:4331585060)
9 GetHornet-AppStore 0x104954a94 __80-[FacultyService imageAtPath:progress:process:success:failure:]_block_invoke + 125 (FacultyService.m:125)
10 AFNetworking 0x105cb4900 __116-[AFHTTPSessionManager dataTaskWithHTTPMethod:URLString:parameters:uploadProgress:downloadProgress:success:failure:]_block_invoke_2 + 301 (AFHTTPSessionManager.m:301)
11 AFNetworking 0x105cc6640 __72-[AFURLSessionManagerTaskDelegate URLSession:task:didCompleteWithError:]_block_invoke_2.102 + 248 (AFURLSessionManager.m:248)
12 libdispatch.dylib 0x19ca3e610 _dispatch_call_block_and_release + 24
13 libdispatch.dylib 0x19ca3f184 _dispatch_client_callout + 16
14 libdispatch.dylib 0x19ca1c85c _dispatch_lane_serial_drain$VARIANT$armv81 + 896
15 libdispatch.dylib 0x19ca1d128 _dispatch_lane_invoke$VARIANT$armv81 + 400
16 libdispatch.dylib 0x19ca2643c _dispatch_workloop_worker_thread + 576
17 libsystem_pthread.dylib 0x19ca8eb88 _pthread_wqthread + 276
18 libsystem_pthread.dylib 0x19ca91760 start_wqthread + 8
Изучая Crashlytics в Firebase, я заметил следующую строку в разделе ключей:
CoreUI: освобождение _CUIInternalLinkRendition 205 / System /Library/CoreServices/CoreGlyphs.bundle/Assets.car