Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22514

What causes task.progress.observe(\.fractionCompleted) to behave very poorly, throwing only two fractions, one at the start and one at the end?

$
0
0

For a completely normal call getting a large file from the net,

let task = URLSession.shared.dataTask(with: request) { [weak self] (data, response, error) in

In the past I've always added progress simply like this,

task.resume()obs = task.progress.observe(\.fractionCompleted) { progress, _ in    print("frac ", progress.fractionCompleted)}

And it has always worked great.

However these days no matter what I try, I just get

enter image description here

You get a ridiculous report at about 1%,

and a ridiculous report at about 95%,

and that's it, nothing in between.

Same happens if 100kb, 1mb or 200mb download.

You get the 1% report when it starts, nothing happens for minutes, or an hour, then it tells you "95% !" and then it is done.

If you use a timer to inspect .progress the result is the same, it is just stuck on basically 0 until the end, then 100.

How to get regular progress reports??


Viewing all articles
Browse latest Browse all 22514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>