I filed this bug as FB24738372 back with the iOS 27.0 GM. I noticed it’s still not fixed in iOS 27.1 beta 1, so I thought I’d do a post here instead.
This bug can be especially bad because:
- It’s easy to trigger: the crash happens when the window is resized on iPad, if all conditions are met:
- There are 6 or more items, in total, in the
TabView; - There is at least 1
TabSection; and - You use the
.sidebarAdaptabletab view style.
- There are 6 or more items, in total, in the
- It’s not a problem in iOS 26.x: I imagine many folks may get blindsided by the new bug, especially when iOS 27 is branded as the bug-fixing release.1
- If Apple doesn’t fix it before iPhone Duo goes on sale, the crash might get rampant, since apps on the Duo constantly switch between Compact and Regular layouts. Worse, if an iPad app crashes during window resizing, the app relaunches with the new size, so many users may not realize the app crashed at all. On iPhone Duo, I presume the app simply closes upon crash, and that gets noticed.
Here’s the SwiftUI code that triggers it on iOS 27, but runs fine on iOS 26:
struct ContentView: View {
enum TabValue: Hashable {
case circle
case square
case star
case triangle
case oval
case seal
}
@State var tabValue: TabValue = .circle
var body: some View {
TabView(selection: $tabValue) {
Tab("Circle", systemImage: "circle", value: .circle) {
NavigationStack { Text("Circle") }
}
Tab("Square", systemImage: "square", value: .square) {
NavigationStack { Text("Square") }
}
Tab("Star", systemImage: "star", value: .star) {
NavigationStack { Text("Star") }
}
Tab("Triangle", systemImage: "triangle", value: .triangle) {
NavigationStack { Text("Triangle") }
}
// MARK: #1
Tab("Oval", systemImage: "oval", value: .oval) {
NavigationStack { Text("Oval") }
}
// MARK: #2
Tab("Seal", systemImage: "seal", value: .seal) {
NavigationStack { Text("Seal") }
}
// MARK: #3
// TabSection {
// Tab("Seal", systemImage: "seal", value: TabValue.seal) {
// NavigationStack { Text("Seal") }
// }
// }
}
.tabViewStyle(.sidebarAdaptable)
.defaultAdaptableTabBarPlacement(.tabBar)
}
}
#Preview {
ContentView()
}
The code above, as is, does not cause a crash.
If you comment out #2 and un-comment #3, the app crashes, because there are 6 items and there is at least 1 section.
From there, if you comment out #1, the crash goes away.
Hope this is a beacon that saves some fellow developers a lot of headaches. Cheers!
-
I’ll note that a bug-fixing release year actually makes serious bugs like this one more likely, because of all the low-level rewrites. So it’s not really a surprise, depending on how you look at it. ↩