gonzalezreal / swift-markdown-ui

Display and customize Markdown text in SwiftUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

knlshh opened this issue · comments

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

  • [ ✅] I can reproduce this issue with a vanilla SwiftUI project.
  • [ ✅ ] I can reproduce this issue using the main branch of this package.
  • [ ✅] 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.

  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

  • MarkdownUI: 2.1.0
  • OS: iOS 16.4 (running on a physical device, not a simulator)
  • Xcode: 14.3

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

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?

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