I have configured a URLSession to fetch data from network & have set a delegate queue so that all subsequent operations happen within my queue. However, when using breakpoints to view the Debug navigator, Xcode shows the completion block of URLSession is invoked on arbitrary threads.
The URLSession is setup as follows -
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
self.urlSession = [NSURLSession sessionWithConfiguration:configuration delegate:nil delegateQueue:[MyManager sharedInstance].queue];
...
[self.urlSession dataTaskWithRequest:urlRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
/... operations expected to be executed on WEGQueue .../
}] resume];
Below is screen capture of processes on my serial queue named WEGQueue
before URLSession has started.
Now I expect the completion block operations to be invoked on the specified delegate queue of URLSession i.e. WEGQueue here. However, using a breakpoint to view the Debug Navigator shows that block is being processed on an arbitrary queue. Attached pic below.
Below is Debug Navigator in "View Process by Queue" filter.
This is really weird!
I'm not sure why URLSession is not invoking completion blocks on the specified delegate queue.
And that's not all.
It gets weirder due to the fact that when I do a po
, lldb
says that the completion block is (as expected) on the WEGQueue. See pic below.
It's confusing that Xcode's Debug Navigator
says URLSession's completion block is being executed on an arbitrary thread while lldb
says it is executed as expected on the delegate queue WEGQueue
.
Did anyone face a similar scenario? Is this just an Xcode GUI bug? Or something is really amiss over here?