I have two nested sheets in my app which has been working great. However, when I tried to set the background of one of the sheets the app suddenly starts eating memory and crashes within a few seconds. This happens on iOS 17.0 through 17.5 when using nested sheets with both presentationBackground
and presentationBackgroundInteraction
. If either of these are removed the app works find. Is there something wrong with the following approach or is this a bug in SwiftUI?
// Crashes after a few seconds
struct CrashingView: View {
var body: some View {
Text("-")
.sheet(isPresented: .constant(true)) {
Text("-")
.presentationBackground(.thickMaterial)
.presentationBackgroundInteraction(.enabled(upThrough: .large))
.sheet(isPresented: .constant(false)) {
Text("-")
}
}
}
}
// Works fine
struct NonCrashingView: View {
var body: some View {
Text("-")
.sheet(isPresented: .constant(true)) {
Text("-")
.presentationBackground(.thickMaterial)
// .presentationBackgroundInteraction(.enabled(upThrough: .large))
.sheet(isPresented: .constant(false)) {
Text("-")
}
}
}
}
The same error occurs when using presentationDetents
.