NSUrlSessionTaskDelegate DidSendBodyData totalBytesSent seems to indicate that upload progress is being reported out of order.
I created a simple test with a single upload, and logged the value of totalBytesSent every time it was called.
For example,
totalBytesSent 3571712
totalBytesSent 3637248
totalBytesSent 3604480
totalBytesSent 3670016
I am seeing this happen around 1-3 times for a 5 MB file. I was wondering if anyone else could confirm this is a known issue, and I cannot rely on these being in the correct order.
Delegate:
// For use with NSUrlSession that is configured for HttpMaximumConnectionsPerHost = 1
public class TestUploadDelegate : NSUrlSessionTaskDelegate
{
public override void DidSendBodyData(NSUrlSession session, NSUrlSessionTask task, long bytesSent, long totalBytesSent, long totalBytesExpectedToSend)
{
Console.WriteLine($"totalBytesSent {totalBytesSent}");
}
}
NSUrlSession creation:
public NSUrlSession GetFileHostUrlSession()
{
if (this.fileHostUrlSession == null)
{
using var configuration = NSUrlSessionConfiguration.CreateBackgroundSessionConfiguration(FileHostSessionIdentifier);
configuration.AllowsCellularAccess = true;
configuration.WaitsForConnectivity = true;
configuration.ShouldUseExtendedBackgroundIdleMode = true;
configuration.SessionSendsLaunchEvents = true;
configuration.Discretionary = false;
configuration.HttpMaximumConnectionsPerHost = 1; // Set to 1 for testing
this.fileHostUrlSession = NSUrlSession.FromConfiguration(configuration, new TestUploadDelegate() as INSUrlSessionDelegate, new NSOperationQueue());
}
return this.fileHostUrlSession;
}