Open motaionx opened 5 years ago
In order to reproduce the issue I may need of code. Can you extract your operation outside the project to replicate it?
@malcommac This problem is not necessarily present, but the probability of occurrence is a bit high.
we use texture(AsyncDisplayKit)
let textNode = ASTextNode().then {
$0.maximumNumberOfLines = 2
$0.placeholderColor = .textureDefault
$0.truncationMode = .byTruncatingTail
}
init(item: HomeServiceItem) {
super.init()
automaticallyManagesSubnodes = true
let name: String
if item.name.isEmpty {
name = HomeLocale.allServices.current
} else {
name = item.name
}
textNode.attributedText = name.set(style: Attributes.textStyle)
if let u = URL(string: item.indexImage) {
imageNode.url = u
}
discountButtonNode.isHidden = item.discount == 0
discountButtonNode.setAttributedTitle("-\(item.discount)%".set(style: Attributes.discountTextStyle), for: .normal)
redNode.isHidden = !(discountButtonNode.isHidden && item.red)
}
struct Attributes {
static var textStyle = Style {
$0.font = Font.systemFont(ofSize: 12.autoFont())
$0.alignment = .center
$0.lineBreakMode = .byWordWrapping
$0.color = UIColor(Hex: 0x666666)
}
static var discountTextStyle = Style{
$0.font = Font.boldSystemFont(ofSize: 10)
$0.alignment = .center
$0.color = Color.discount
}
}
@malcommac
Just to confirm - we're getting the same crash (quite rare). We're also using texture, so I presume it's related to the code not being called on the main thread. Would be great to get a fix tho.
Just chasing this up @malcommac, as still seeing the same crash / it's the primary cause of crashes in our app at the moment (around a 0.4% rate of occurrence based on crash logs).
@malcommac / @motaionx - either of you guys manage to figure out a fix / workaround for this?
Xcode version : 10.0 (10A255) Swift version: 4.2.0 SwiftRichString version:3.0.0