Skip to content

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

@knlshh

Description

@knlshh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions