swift-markdown-ui
swift-markdown-ui copied to clipboard
Severe hang when rendering a short markdown string with 6-level nested bullet points
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
- [x] I can reproduce this issue with a vanilla SwiftUI project.
- [x] I can reproduce this issue using the
mainbranch of this package. - [x] This bug hasn't been addressed in an existing GitHub issue.
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.
- Clone this minimal demo project
- Build and run it, tap the "Go" navigation link, and observe a 1-2s UI freezing before the view transition
- 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
Version information
- MarkdownUI: 2.3.0
- OS: iOS 17.4.1
- Xcode: 15.2
Additional context
- Looks like it has to do with the deeply nested bullet points (i.e. 6 levels)
- Un-nesting the deepest level of bullets (i.e. moving them to become siblings of their original parent bullets) mitigates the Severe Hang into just Hang
- Further un-nesting (i.e. reducing from 5 levels to 4 levels nested bullets) results in no Hang at all
Thanks for reporting. I will take a look as soon as I have some spare time.