UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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.

2      

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

2      

Awesome, I'll take a look.

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.