gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.44k stars 298 forks source link

Severe hang when rendering a short markdown string with 6-level nested bullet points #310

Open hsinlei opened 5 months ago

hsinlei commented 5 months ago

Thank you for contributing to MarkdownUI!

Before you submit an issue, please complete the report with all the relevant details for your bug and go through every item in the checklist.

Describe the bug Severe hang (1-2s) when rendering a relatively short markdown string (~hundreds of characters) with nested bullet points (6 levels).

Checklist

Steps to reproduce Explanation of how to reproduce the incorrect behavior. This could include an attached project, a link to code, or a Markdown-formatted text exhibiting the issue.

  1. Clone this minimal demo project
  2. Build and run it, tap the "Go" navigation link, and observe a 1-2s UI freezing before the view transition
  3. Profile and record the run using XCode Instruments Timing Profiling tool, tap the "Go" navigation link, and observe "Severe Hang" and 100% CPU usage

Expected behavior Ideally no hang from rendering such a short markdown string. If heavy computation can't be easily optimized out, move the computation off of the main UI thread to avoid hangs.

Screenshots

Screenshot 2024-04-20 at 10 54 23 AM

Version information

Additional context

gonzalezreal commented 5 months ago

Thanks for reporting. I will take a look as soon as I have some spare time.