1 Reply
      Latest reply on Sep 21, 2016 2:17 AM by eskimo
      nhulsch Level 1 Level 1 (0 points)



        i'm uploading data (mostly about 1MB files) with a uploadTaskWithStreamedRequest.


        To give the user feedback about the upload progress i'm using didSendBodyData-delegate:

        - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSendBodyData:(int64_t)bytesSent totalBytesSent:(int64_t)totalBytesSent totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
            if (task == uploadTask) {
                double progress = (double)totalBytesSent / (double)totalBytesExpectedToSend;
                dispatch_async(dispatch_get_main_queue(), ^{
                    hud.progress = progress;


        Before iOS 10 the progressbar smoothly growed, since iOS10 the delegate seems to be just called twice, once at the beginning and last on nearly finished upload process. If i run it on the simulator against iOS 9.3 its smooth again.


        Did I miss any change?


        Best regards,


        • Re: NSURLSession didSendBodyData less called on iOS10
          eskimo Apple Staff Apple Staff (13,895 points)

          This delegate method is called as data is passed from user space to the kernel.  Modern systems can have very large buffers within the kernel, which reduces the utility of this callback when uploading small files because the entire file fits into the kernel socket buffer.  If you switch to a much bigger file, say 100 MB, what do you see?

          [Which isn’t to say that you should switch to 100 MB files in your real app; this is just a diagnostic test.]

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"