0

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.

jab11
  • 867
  • 1
  • 8
  • 15
  • File a bug. NSURLSession should be identical on macOS, iOS, and Catalyst, with the exception of behavior of requests made while in the background and relaunching of apps for handling background session activity. – dgatwood Oct 11 '22 at 23:31
  • @dgatwood upgrade to monterey solved it so it was probably a big sur issue. – jab11 Oct 13 '22 at 00:10

0 Answers0