Closed Strider-Alex closed 1 year ago
I think that's a bug of SwiftUI. It occurs randomly.
I noticed this bug may be related to markdown Tables. Can you share your Table used in this Markdown?
@LiYanan2004 In my case there's no table. Only text, ordered list and url links.
@Strider-Alex Can you provide a minimum, reproducible snippet of code?
Sure. After some experiment I'm able to reproduce in the following view:
struct TestView: View {
@State var text = "1. [test](test.com)\n 1. [test](test.com)\n 1. [test](test.com)"
var body: some View {
ScrollView { // this scroll view seems to be the issue
MarkdownView(text: $text)
.textSelection(.enabled)
}
}
}
@Strider-Alex One more question. Is this crash happens on simulators or physical devices, and have you tried on iOS 16.4? I have tried on my side with Xcode 14.3 and 16.4 simulator. Works fine (also tried open and close the app).
@Strider-Alex Xcode 14.3.1 released. You can try to update your Xcode to see if the bug resolved.
The crashes happened on physical devices and occurred for multiple iOS versions. Can you wrap the TestView
inside a NavigationLink and try to open & close it multiple times? That's how I reproduce the issue.
Gotcha. Reproduced. I will investigate this bug.
Hello @Strider-Alex
I'm happy to tell you I may have resolved your issue. I improve the implementation of ._task
which can back-deployed to older OS. Seems like the === AttributeGraph: cycle detected through attribute xxxxxx ===
bug resolved and I have run an automation to open & close the navigation link for 5 minutes with no crashes and no AttributeGraph cycle
warnings.
You can check it out at fix-graph-cycle branch.
If you are building an package, update your Package.swift
with
.package(url: "https://github.com/LiYanan2004/MarkdownView.git", .branch("fix-graph-cycle"))
to check it out.
Don't forget to reply me whether the bug is fixed or not. Thanks for this great issue.
Hey @LiYanan2004, this is awesome. I don't have chance to test for myself recently, but I'm total okay if the issue is fixed in your automation.
OK I'll merge the fix and if the bug still happens on your side after updating to the latest version, you can reopen the issue.
Xcode version: 14.3 Platform: iOS 16.3.1
Problem:
MarkdownView
sometimes crashes. Seems to be some timing issue. I need to open and close the view that hasMarkdownView
back and forth to reproduce the issue. Seems to occur more often you move the app from background to foreground.When debugging on device, the code crashes here:
Debug console prints a lot of warnings:
=== AttributeGraph: cycle detected through attribute xxxxxx ===