Posts

Post marked as solved
10 Replies
1.4k Views
I have a performance issue with a Mac SwiftUI app. Using instruments I see hangs reported. When I zero in on a hang I see that the time profiler reports most of the hang -- in one example 658 out of 687 ms -- being in 'static AppName.$main() [inlined]'. I think that is saying my app is busy, but busy doing what? The "hangs" are related to SwiftUI table processing. User experience is something like this: select an item, see the view changes based upon selection show up a second or two later. The duration of the hang increases with the number of items in the table. I'm testing with 100 ~ 1200 table entries.
Posted
by marchyman.
Last updated
.
Post marked as solved
5 Replies
735 Views
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.
Posted
by marchyman.
Last updated
.
Post not yet marked as solved
0 Replies
166 Views
SwiftUI Table on macOS with two columns. In some test code the items being sorted are: @Observable final class Item: Identifiable { let id: Int var displayId: String { String(id) } let description: String init(_ id: Int) { self.id = id self.description = UUID().uuidString } } The table columns are displayId and description. The Tables initial sort order is defined by this descriptor: var sortOrder = [KeyPathComparator(\Item.description)] The strangeness is this: the sorted description order is very strange. "0B5..." sorts before "0B0..." ? Or if I reverse the sort order I get this: "AA..." before "FF..." What am I missing? Sorting the first column does what I'd consider to be the right thing, showing the column in numerical order even though I'm using the String representation of id.
Posted
by marchyman.
Last updated
.
Post marked as solved
1 Replies
809 Views
In the initial Xcode 15/iOS 17 Beta selecting a Marker would give a visible indication that the marker was selected without setting the selection. This is the code I used. struct ContentView: View { let location = CLLocationCoordinate2D(latitude: 37.0, longitude: -122.0) @State private var position: MapCameraPosition = .automatic @State private var selectedItem: MKMapItem? var body: some View { VStack { Text(selectedItem == nil ? "Nothing Selected" : selectedItem?.name == nil ? "No name" : selectedItem!.name!) .bold() .padding() Map(position: $position, selection: $selectedItem) { Marker("Marker", coordinate: location) .tag(1) .tint(.red) } } .padding() } } I submitted feedback and things changed in Beta 3. Now I can not select the Marker. That's not the direction I'd hoped to see. Am I doing something wrong or is there no way to select a Marker placed on a map?
Posted
by marchyman.
Last updated
.
Post not yet marked as solved
0 Replies
631 Views
Is there a SwiftUI TableView equivalent to the NSTableViewDelegate method tableView(_: TableView, selectionIndexesForProposedSelection: IndexSet) -> IndexSet method? I've a table of items but some of the items should not be selectable.
Posted
by marchyman.
Last updated
.
Post not yet marked as solved
0 Replies
488 Views
A UI test opens program preferences and clicks on a path item. That results in an open dialog box. So far so good. I used to be able to simulate shift-command-G which gave me a sheet I could use to enter a known test path. That stopped working, either with Xcode 13 or with macOS Monterey. Or perhaps earlier. Shift-command-G opens something. It isn't a sheet or it is some new kind of sheet. The problem is I can not see any matching UI element in the Application tree of elements. Recording a test doesn't work, either. Interaction with the element is not recorded. What is this element? Can it be manipulated with XCode UI tests?
Posted
by marchyman.
Last updated
.