johnxnguyen / Down

Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark.
Other
2.24k stars 320 forks source link

Blink issue after call update method #229

Closed AndresLeonardoMartinez closed 3 years ago

AndresLeonardoMartinez commented 3 years ago

Please help prevent duplicate issues before submitting a new one:

Report

I have a blink issue after call update method on iOS 13

What did you do?

let body: DownView? = try? DownView(frame: .zero, markdownString: "", templateBundle: Bundle.main)
try? body?.update(markdownString: text)

What did you expect to happen?

It should show the DownView with the text without blink effect

What happened instead?

Every time update is called there is a blink effect after show the DownView with the markdown text. This effect shows a white screen for an instant and disappears showing the markdown text

iwasrobbed-ks commented 3 years ago

Hi @AndresLeonardoMartinez 👋

DownView is just a WKWebView under the hood so it will have a lot of limitations on rendering; you might be better off using the attributed string APIs which are bundled into DownTextView

Unfortunately there's not much we can do about the web view rendering / re-rendering, so I'm closing this issue.

Feel free to let us know if the text view fixes the issue for you.

AndresLeonardoMartinez commented 3 years ago

I was able to make it works using a UITextView Down(markdownString: text).toAttributedString(stylesheet: stylesheet)

thanks!

iwasrobbed-ks commented 3 years ago

Glad to hear it @AndresLeonardoMartinez 👍

As a follow-up, please keep in mind the toAttributedString(stylesheet is not background thread safe and might be slow since it uses an old web view API to do the rendering to HTML. DownTextView is recommended to be used in parallel with this attributed string API https://github.com/iwasrobbed/Down/blob/master/Source/Renderers/DownAttributedStringRenderable.swift#L48

You can setup custom styling, render on background threads, etc with that. Hope it helps