One frequent but hard to reproduce bug in SwiftUI is being unable to dismiss a basic Alert. I think I've managed to reproduce the issue here. If there is even a little congestion in the main thread, here in the form of a counter the updates every 0.1 seconds, the Alert will fail to dismiss 90% of the time. This level of activity should be nothing remarkable. It will dismiss sometimes but usually does not. See attached project.
Feedback case: https://feedbackassistant.apple.com/feedback/14719229For this sample project just move out the counter Text to standalone View and pass Binding:
struct CounterView: View {
@Binding var counter: Int
var body: some View {
Text("Counter: \(counter)")
.font(.caption)
}
}
Then replace this:
Text("Counter: \(counter)")
.font(.caption)
With:
CounterView(counter: $counter)
P.S. To understand the problem, add in the body
:
var body: some View {
let _ = Self._printChanges()
...