Post

Replies

Boosts

Views

Activity

Frequent Crash on Table Content Change
One of my apps has been crashing on multiple Sequoia betas, something that never happened on prior macOS versions, and I’ve finally narrowed it down to a smaller reproducible case which I've attached to bug report #FB14473269. The narrowed case is fairly trivial. A table containing data is filtered by typing into a text field which narrows the bound content by finding only text with matching substrings. It's a single basic view the source for which is included in its entirety below. To reproduce the crash: Compile and run Type “five” in the search text If this doesn’t immediately crash it with the first keystroke (there seems to be some kind of race condition so it may vary on different hardware configurations), delete a character at a time and repeat as necessary. Typing “one” on my system doesn’t crash the app, but deleting backwards to just “o” immediately crashes. The backtrace is entirely within SwiftUI. This works flawlessly on Sonoma which is where I've been building and testing the app where this problem was first discovered, and it's completely unusable up through beta 5 of Sequoia. It's hard to believe nobody else is encountering this. Any suggestions? import SwiftUI class Item: Identifiable { var id: String init(_ id: String) { self.id = id } } struct ContentView: View { @State var allItems = [ Item("One"), Item("Two"), Item("Three"), Item("Four"), Item("Five"), Item("Six"), Item("Seven"), Item("Eight"), Item("Nine"), Item("Ten") ] @State var filteredItems = [Item]() @State var selectedItems = Set<Item.ID>() @State var text: String = "" func filter() { if text == "" { filteredItems = allItems } else { filteredItems = allItems.filter { $0.id.localizedCaseInsensitiveContains(text) } } } var body: some View { VStack { TextField("Search:", text: $text) .padding() .onChange(of: text) { filter() } .onAppear { filter() } Table($filteredItems, selection: $selectedItems) { TableColumn("Name") { item in Text(item.id) } } } } } #Preview { ContentView() }
8
1
731
Aug ’24