GCD’s Main Queue vs. Main Thread
Technically I think this is a MapKit / VektorKit bug, Apple’s UI frameworks typically guarantee to work correctly when being called from the main thread, no part of the documentation mentions that code needs to be executed on the main queue.
[…]
By combining GCD and Cocoa’s
NSThread
API we are drilling through the abstraction that GCD should provide in the first place. APIs that fully rely on GCD and ignore the presence of the underlying threads can run into problems if you call them on the main thread but not the main queue. This means, especially when calling into other frameworks, we should prefer usingdispatch_queue_set_specific
anddispatch_get_specific
to check if our code is running on the main queue over usingNSThread.isMainThread()
.
It’s hard to get this right because of reentrancy, though.