Texture icon indicating copy to clipboard operation
Texture copied to clipboard

UI Hanging Issue while using html string

Open abbasnaqvi200 opened this issue 1 year ago • 1 comments

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
}

}

abbasnaqvi200 avatar Oct 09 '23 07:10 abbasnaqvi200

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

cendolinside123 avatar Feb 15 '24 04:02 cendolinside123