gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI
MIT License
2.53k stars 318 forks source link

Using MarkdownUI with Splash causes a crash on a long-ish markdown on app launch #231

Closed knlshh closed 1 year ago

knlshh commented 1 year 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 A clear and concise description of what the bug is. Using MarkdownUI with Splash causes a crash on a long-ish markdown on app launch.

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. Run the attached app on a physical device and the app will crash on startup.
  2. The stacktrace that Xcode shows for the crash points to @main in MarkdownScrollViewCrashApp, but I've narrowed it down to Builder's build method.

Expected behavior A clear and concise description of what you expected to happen.

  1. App should not crash on startup and markdown should render.

Screenshots If applicable, add screenshots to help explain your problem.

Version information

Additional context Add any other context about the problem here.

If you reduce the size of the sample text, the markdown renders correctly. From my debugging, I've found that accumulatedText.reduce(Text(""), +) in TextOutputFormat is the culprit. I suspect that the memory of the underlying text storage is being released leading to a bad access.

Sample project - MarkdownScrollViewCrash.zip

gonzalezreal commented 1 year ago

Hi @knlshh,

If the problem does not stem from MarkdownUI and is instead related to the TextOutputFormat sample code or Splash, I recommend posting about it in a discussion and closing this issue. What do you think?

gonzalezreal commented 1 year ago

Closing as the described issue does not stem from MarkdownUI. Feel free to create a discussion on better integrating Splash with MarkdownUI.