WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

SOLVED: Creating a single Task causes my UI to hang

Forums > SwiftUI

I am writing a SwiftUI app that uses a single Task(priority: .low) to do lots of HTTP requests as a low priority whose results are displayed in a table.

There's several GBs of data being aggregated to display totals, averages etc.

Thing is, I am only creating one Task, but this is causing my UI to hang. Why is this? I think I must have a fundamental misunderstanding about how tasks are created and how they relate to processes and threads.

I am using Mongo's Realm to store the data having become frustrated with Core Data.

There is far too much code to post, but all the HTTP requests are being made using URLSession's async methods. In any case, I certainly wouldn't expect this to cause the UI to hang! What might be going on?

I know it's tough to triage without code, but as I say there is a lot of it.

   

Well, aren't you in luck!

@twoStraws has noted in some older videos that Apple had so many full featured technologies for him to learn (and teach) that he has no desires to extend to other packages and libraries. [cit. needed].

However, other SwiftUI content providers sometimes fill this need. In fact, Stewart Lynch is just kicking off a series where he builds a ToDo application using Realm. He has two videos already published, with more to come. (reference date: 24 Mar 2022).

If you have questions about background tasks and Realm, perhaps you'll find answers there?

See--> Realm and SwiftUI

   

Awesome, I'll take a look.

   

Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Fernando's book will guide you in fixing bugs in three real, open-source, downloadable apps from the App Store. Learn applied programming fundamentals by refactoring real code from published apps. Hacking with Swift readers get a $10 discount!

Read the book

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.