Hello!
On visionOS, after an app with multiple scenes defined crashes and is re-launched, two windows are opened with identical contents.
Please see below for a minimal example:
struct SecondaryWindowTag: Codable, Hashable {}
enum WindowTag {
static let secondaryWindow = SecondaryWindowTag()
}
@main
struct SwiftUIExampleApp: App {
@Environment(\.openWindow) private var openWindow
var body: some Scene {
WindowGroup {
Button {
openWindow(value: WindowTag.secondaryWindow)
} label: {
Text("Open Window")
}
.buttonStyle(.bordered)
}
WindowGroup(for: SecondaryWindowTag.self) { _ in
Button {
fatalError("Test crash")
} label: {
Text("Crash")
}
}
}
}
Here is a screenshot taken after re-launching following a crash. You can see there are two windows both having the "Open Window" button of the first WindowScene
defined above.
Is this a known issue? Are there any workarounds I could try?
Thank you!
Hey @ikimol,
This sounds like a bug. I'd greatly appreciate it if you could open a bug report, include the information you provided here and post the FB number here once you do.
Bug Reporting: How and Why? has tips on creating your bug report.
Thanks!
Michael