因此,大约1%的用户会话在所有iOS版本和设备上都出现以下错误:
1 libswiftCore.dylib specialized _assertionFailure(_:_:file:line:flags:)
2 libswiftCore.dylib swift_unexpectedError
3 PCC2 closure #2 in onLoad() //this is the line that's highlighted
4 PCC2 specialized closure #1 in backgroundThread(_:background:completion:)
5 PCC2 closure #1 in backgroundThread(_:background:completion:)
6 PCC2 thunk for @calee_owned () -> ()
导致此错误的代码是:
backgroundThread(background: {
let _ = try! NSAttributedString( // this is the line that the highlighted line leads to
data: "<b>bold!</b>".data(using: String.Encoding.unicode, allowLossyConversion: true)!,
options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue],
documentAttributes: nil)
}, completion: {
attributedStringsReady = true
})
backgroundThread
如下:
func backgroundThread(_ delay: Double = 0.0, background: (() -> Void)? = nil, completion: (() -> Void)? = nil) {
DispatchQueue.global(qos: .userInitiated).async {
if(background != nil){ background!(); }
let popTime = DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
// the above line is what Crashlytics points to
DispatchQueue.main.asyncAfter(deadline: popTime) {
if(completion != nil){ completion!(); }
}
}
}
不知道如何重现这一点。我甚至不知道如何从管理器中复制痕迹,我不得不重新输入整个内容。