Has anyone else created a macOS SwiftUI app that uses a Table with a largish (~1000) number of entries? My app works OK at about 100 entries, but slows down as the number of entries increase. How slow? An instrumented test with 1219 entries shows a Hang of over 13 seconds from simply clicking/selecting an item in the table.
Instruments says the time is mostly spent in _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION. Digging deeper I see AG::Subgraph::update(unsigned int) and descendants account for about half of the hang time.
My app is using @Observable on macOS 14 and is being tested on an M2 Max Studio.
There are other reported hangs. All seem to be in Swift/SwiftUI code.
Well, that was interesting.
I started a new version of my project, bringing code over bit-by-bit and doing performance testing after every change. It boils down to this
Table(...) {
} rows: {
ForEach(someArray) { item in
TableRow(item)
}
}
That worked fine. But I don't want to show every item. So I added this:
ForEach(someArray) { item in
if item.isValid {
TableRow(item)
}
}
Checking the item when building the row breaks things badly. Now to figure out a workaround.