Reputation: 867
The didSendBodyData
method of URLSession delegate with uploadTask
running is called with a wrong totalBytesExpectedToSend
value. It seems to be about double of what it should be but not exactly.
The URLSessionTask parameter contains field task.countOfBytesExpectedToSend
which is also wrong. The task.progress
also only ever goes up to about 0.5
The bytesSent
value goes up to the correct amount which is about the size of the file uploaded.
my code:
func urlSession(_ session: URLSession, task: URLSessionTask, didSendBodyData bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) {
NSLog("did send body data %ld %ld %f", totalBytesSent, totalBytesExpectedToSend, task.progress.fractionCompleted);
progress.setProgress(Float(totalBytesSent)/Float(totalBytesExpectedToSend), animated: true)
}
Note: this only happens in the mac catalyst version. The same code running on iOS reports correct values.
Upvotes: 0
Views: 468