Ancestors

Written by Duncan Babbage on 2024-10-24 at 04:09

So... I’ve traced my performance issue down to the way I’m updating my main SwiftUI lists in response to incoming NSPersistentStoreRemoteChange #CoreData notifications from iCloud. I was processing them on a background context, then sending notifications observed by lists. If they displayed types that were updated they’d refresh.

Clearly I was not doing this well because the view-side-subscription-and-refresh part could cause multi-second UI pauses. Obv not great.

Advice welcome. #iOSDev

=> More informations about this toot | More toots from babbage@iosdev.space

Written by Duncan Babbage on 2024-10-25 at 09:01

Ah awesome, it looks like I have solved this. Turned out, essentially, that I was just doing far more work that I needed to. I realise now how this happened. Because originally I hadn’t found the mechanism to ensure my SwiftUI list was updated when there were additional objects in the viewContext, I’d thought from research I had to do a heavy:

`try? viewContext.setQueryGenerationFrom(.current)

viewContext.refreshAllObjects()`

…once I’d finished background processing. 1/3

=> More informations about this toot | More toots from babbage@iosdev.space

Toot

Written by Duncan Babbage on 2024-10-25 at 09:03

It transpires this was completely superfluous, it appears, and highly problematic performance-wise.

I already had viewContext.automaticallyMergesChangesFromParent = true in my setup, so the context was being updated automatically.

All I had to do was prod my list with a stick, setting a new UUID on my refetchTrigger I passed to the view. That correctly causes the list to refetch when relevant objects have been imported. And since it turns out they were already in the viewContext, sorted!

=> More informations about this toot | More toots from babbage@iosdev.space

Descendants

Written by Duncan Babbage on 2024-10-25 at 09:06

I simply ended up in this situation because I hadn't originally had the refetchTrigger in place, and so failed to learn that the earlier step of pinning the query generation and refreshingAllObjects() was both completely unnecessary and additionally was indeed the cause of my performance problems.

There’s nothing like the satisfaction, joy even, of solving a significant performance issue. 🎉

=> More informations about this toot | More toots from babbage@iosdev.space

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113367255204350015
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
265.144799 milliseconds
Gemini-to-HTML Time
2.654452 milliseconds

This content has been proxied by September (3851b).