I'm receiving error messages in log:
CFNetwork internal error 0xc01a:/SourceCache/CFNetwork/CFNetwork-711.1.16/Connection/URLConnectionLoader.cpp:1321)
The problem is something to deal with cancellation of NSURLSessionDataTask
objects under extreme pressure (tasks are created and cancelled very fast). The error doesn't occur when tasks aren't cancelled. And it's also doesn't occur when tasks are cancelled with a delay:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[_task cancel];
});
Apple has stopped providing a CFNetwork source a long time ago. How someone go about debugging this kind of error?
There is a simple solution to this problem - you should rate limit the requests. https://en.wikipedia.org/wiki/Token_bucket URLSession
just isn't designed to be used like that.