Closed hugo53 closed 1 year ago
I'm facing this problem during this package development too. I'll try to fix that.
MacBook Pro M1. Not sure whether my understanding is correct. This is a scrollview with 120 MarkdownView inside. Each one has a line of text or a code block.
But can't reproduce your crash. But I know this crash exist, so can you offer your code block content or your source code that can reproduce this crash?
Check out my code here:
https://github.com/LiYanan2004/MarkdownView/assets/37542129/c28090e4-596a-4fc6-a2b4-e907e284f29e
@LiYanan2004 Please check below code and video. I was able to reproduce the issue after 2 tries. Hope this help something.
import SwiftUI
import MarkdownView
struct ContentView: View {
let text = """
```java
public class Factorial {
public static void main(String[] args) {
int number = 5;
int factorial = calculateFactorial(number);
System.out.println("The factorial of " + number + " is: " + factorial);
}
public static int calculateFactorial(int num) {
if (num == 0) {
return 1;
} else {
return num * calculateFactorial(num - 1);
}
}
}
"""
var body: some View {
ScrollView {
LazyVStack {
ForEach(0..<150, id: \.self) { i in
MarkdownView(text: text)
}
}
}
}
}
struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
https://github.com/LiYanan2004/MarkdownView/assets/1033299/572009e9-7d75-402c-9645-fc0c27f9dae5
@hugo53 Please switch to the branch called fix-double-free-memory-crash
and try it again. I may have fixed this issue.😁
Thank you for quick fix @LiYanan2004 . Seems it's better now but let me monitor for a while to confirm this on my side.
OK. Glad to hear that. Don't forget to give me some feedbacks
@LiYanan2004 I tested many times with your fix and confirmed that it's working fine now. No crash anymore. Thank you again for the great fix.
Okay. I’ll merge the fix. Thanks.
1.4.0 released. I will delete that fix branch.
It's working fine now, I don't see the issue again. Thank you for great work!
Describe the bug Hello @LiYanan2004,
Thank you for the excellent package, I really appreciate it. I gave it a try and it seems quite impressive. However, I came across a problem as mentioned below:
Please see attached image for more details. Can you please help to check this problem? Thank you!
To Reproduce Steps to reproduce the behavior:
Expected behavior No crash when scroll.
Screenshots
Environment: