Using if statement in .overlay causes app to freeze when using withAnimation

I have an issue where a very specific configuration of .overlay, withAnimation, and a bindable state can freeze the app when the state changes.

I've isolated the problematic source code into a sample project can be found here that demonstrates the issue: https://github.com/katagaki/IcyOverlay

Steps to Reproduce

To reproduce the issue, tap the 'Simulate Content Load' button. Once the progress bar has completed, a switch is toggled to hide the progress view, which causes the overlay to disappear, and the app to freeze.

Any help and/or advice will be appreciated!

Development Environment

  • Xcode Version 16.2 (16C5032a), macOS 15.2(24C101)
  • iOS SDK: 18.2 (22C146), Simulator: 18.2 (22C150)
Answered by Fat Xu in 818846022
    func hide() {
        title = ""
        message = ""
        percentage = 0
        withAnimation {
            isShowing = false
        }
    }
Accepted Answer
    func hide() {
        title = ""
        message = ""
        percentage = 0
        withAnimation {
            isShowing = false
        }
    }
Using if statement in .overlay causes app to freeze when using withAnimation
 
 
Q