hello,
i found something peculiar: the very first http/https network load in the app even when done on a background queue affects the main thread significantly. have a look at the screen recording of the app:
http shorturl.at/nxAE4
and how non linear the scrolling performance is:
http shorturl.at/uADY2
there i scroll a list of simple items and when it hit item 30 it loads it on a background queue. result (in this case error) is delivered on another background queue and ignored. the second load of this or a different URL doesn't cause such delay.
what exactly is system doing on the main thread here and can it not do it elsewhere?
what is the best way to figure what extra code is executed on main thread? i tried instruments with various tools in it but can't make heads or tails of it to figure out what exactly is going on here.
the sample code that used for url loading:
i found something peculiar: the very first http/https network load in the app even when done on a background queue affects the main thread significantly. have a look at the screen recording of the app:
http shorturl.at/nxAE4
and how non linear the scrolling performance is:
http shorturl.at/uADY2
there i scroll a list of simple items and when it hit item 30 it loads it on a background queue. result (in this case error) is delivered on another background queue and ignored. the second load of this or a different URL doesn't cause such delay.
what exactly is system doing on the main thread here and can it not do it elsewhere?
what is the best way to figure what extra code is executed on main thread? i tried instruments with various tools in it but can't make heads or tails of it to figure out what exactly is going on here.
the sample code that used for url loading:
Code Block let someQueue = DispatchQueue(label: "someQueue") let otherQueue = DispatchQueue(label: "otherQueue") var someOpQueue: OperationQueue = { let q = OperationQueue() q.underlyingQueue = someQueue q.name = "someOpQueue" return q }() var session = URLSession(configuration: .default, delegate: nil, delegateQueue: someOpQueue) func loadUrl(_ url: URL) { otherQueue.async { let task = session.dataTask(with: url) { d, r, e in /* ignore */ } task.resume() } }