CI :: GLContext :: init()崩溃EXC_BAD_ACCESS KERN_INVALID_ADDRESS

时间:2018-06-06 20:03:33

标签: ios swift uiimage xcode9 dangling-pointer

在我们使用 XCode 9 构建之后,开始在Crashlytics上看到此崩溃,并且所有崩溃都发生在iOS 11设备上(尽管它可能只是大多数人今天在iOS 11上)

Crashed: com.apple.main-thread
0  CoreImage                      0x186ff417c CI::GLContext::init() + 276
1  CoreImage                      0x186ff4158 CI::GLContext::init() + 240
2  CoreImage                      0x186ff4514 CI::GLContext::GLContext(CI::GLContext::ShareContextInfo, CGColorSpace*, CGColorSpace*, CI::PixelFormat, bool, unsigned long, bool, bool) + 416
3  CoreImage                      0x186ff4544 CI::GLContext::GLContext(CI::GLContext::ShareContextInfo, CGColorSpace*, CGColorSpace*, CI::PixelFormat, bool, unsigned long, bool, bool) + 24
4  CoreImage                      0x186fba50c +[CIContext(Internal) internalContextWithEAGLContext:options:] + 756
5  CoreImage                      0x186fb6514 -[CIContext initWithOptions:] + 820
6  CoreImage                      0x186fb61bc +[CIContext contextWithOptions:] + 52
7  UIKit                          0x18b9759ac -[UIImage drawInRect:blendMode:alpha:] + 1072
8  UIKit                          0x18be6fad4 -[UIImageView drawRect:] + 116
9  UIKit                          0x18b9e3fdc -[UIView(CALayerDelegate) drawLayer:inContext:] + 536
10 QuartzCore                     0x185f34e18 -[CALayer drawInContext:] + 296
11 QuartzCore                     0x185f3455c -[CALayer _display] + 936
12 QuartzCore                     0x185ea5b64 CA::Context::commit_transaction(CA::Transaction*) + 516
13 QuartzCore                     0x185ecd5d0 CA::Transaction::commit() + 580
14 UIKit                          0x18bc515cc _afterCACommitHandler + 256
15 CoreFoundation                 0x181d66910 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
16 CoreFoundation                 0x181d64238 __CFRunLoopDoObservers + 412
17 CoreFoundation                 0x181d64884 __CFRunLoopRun + 1436
18 CoreFoundation                 0x181c84da8 CFRunLoopRunSpecific + 552
19 GraphicsServices               0x183c67020 GSEventRunModal + 100
20 UIKit                          0x18bc6578c UIApplicationMain + 236

一些可能导致此次崩溃的代码段:

public extension UIImage {
@objc public convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
    let ciImage = CoreImage.CIImage(color: CIColor(cgColor: color.cgColor))
                    .cropping(to: CGRect(origin: CGPoint.zero, size: size))
    self.init(ciImage: ciImage)
}
}


extension UIImage {
class func imageWithColor(color: UIColor, size: CGSize) -> UIImage {
    let rect: CGRect = CGRect(x:0, y:0, width:size.width, height:size.height)
    UIGraphicsBeginImageContextWithOptions(size, false, 0)
    color.setFill()
    UIRectFill(rect)
    let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
    UIGraphicsEndImageContext()
    return image
}
}

任何关于发生了什么或调试技巧的想法都会非常感激!

0 个答案:

没有答案
相关问题