I am observing progress of a download in the totally normal way …
let task = URLSession.shared.dataTask(with: req) { (_,_,_) in
...
}
___obs = task.progress.observe(.fractionCompleted) { prog, _ in
print("frac ", prog.fractionCompleted)
}
task.resume()
In doing any large download (say 500mb, ten seconds) the output is useless,
data start arriving, 0 seconds
>>>>>> ... 0.950
>>>>>> ... 0.951
>>>>>> ... 0.951
>>>>>> ... 0.952
>>>>>> ... 0.952
>>>>>> ... 0.953
>>>>>> ... 1.000 .. we're now about 0.5 seconds later!
500mb completes about 10 seconds later
-
the observation is only called a few times, during the first (say) 20-30mb, first half second or so
-
it quickly runs up to “1” and stops
-
the remaining 470mb download then comes in the next ~9 seconds
-
note there is some dispute which order the two lines or code observe/resume should appear, I tried both extensively, no difference. Yes, ___obs is of course retained.
-
this is iOS17. I’ve never previously noticed
task.progress
being “totally useless” but of course it could just be I didn’t notice -
could (IDK) this be due to some server issue (headers, something?)
-
one point, has anyone actually observed (pun) the
fractionCompleted
actually working well on a real world large file? That would be a good data point.
Total mystery to me I’ve fiddled with for an hour.