Texture
Texture copied to clipboard
UI Hanging Issue while using html string
UI Hanging Issue while using html string
DispatchQueue.global(qos : .background).async {
guard let data = htmlTemplate.data(using: .utf8) else {
return nil
}
guard let attributedString = try? NSMutableAttributedString(
data: data,
options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue],
documentAttributes: nil
) else {
return nil
}
DispatchQueue.main.async {
self.textNode.attributedText = attributedString
}
}
don't put anything related with html on background thread and async process , html need lot of time to load and it on some case it will cause crash or dirty issue on NSMutableAttributedString