On iOS 11 only, the Contacts framework will frequently hang when calling the "enumerateContactsWithFetchRequest" method. It seems to happen more often when fetching a large number of contacts. The log reads "Error: service connection to com.apple.contactsd was interrupted." See attached call stack from the main thread.
If you're noticing the same behavior, please let Apple know so they make it a priority to get it fixed. I've reported the issue using Bug Reporter: https://bugreport.apple.com/web/?problemID=34671273
Many users are reporting that iOS 11 is slow, and this may be part of the issue. Apple apparently rewrote much of the Contacts Framework for iOS 11, and clearly there are bugs. Most operations are significantly slower than iOS 10.
The relevant callstack on the main thread is shown below:
#0 0x000000018569cbc4 in mach_msg_trap ()
#1 0x000000018569ca3c in mach_msg ()
#2 0x0000000104bce7e8 in _dispatch_mach_send_and_wait_for_reply ()
#3 0x0000000104bcec90 in dispatch_mach_send_with_result_and_wait_for_reply ()
#4 0x000000018580b9cc in xpc_connection_send_message_with_reply_sync ()
#5 0x00000001866ba3a8 in __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ ()
#6 0x00000001866b9b30 in -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] ()
#7 0x00000001866b8ae0 in -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:] ()
#8 0x00000001866c5ef8 in _NSXPCDistantObjectSimpleMessageSend2 ()
#9 0x000000019078cd3c in -[CNXPCDataMapper fetchEncodedContactsForFetchRequest:error:cancelationToken:batchHandler:] ()
#10 0x000000019078c950 in -[CNXPCDataMapper fetchAndDecodeEncodedContactsForFetchRequest:error:cancelationToken:batchHandler:] ()
#11 0x000000019078c2bc in __52-[CNXPCDataMapper contactObservableForFetchRequest:]_block_invoke ()
#12 0x000000018d833f60 in __26-[CNObservable doOnError:]_block_invoke ()
#13 0x000000018d833ba0 in __31-[CNObservable doOnCompletion:]_block_invoke ()
#14 0x000000018d833ba0 in __31-[CNObservable doOnCompletion:]_block_invoke ()
#15 0x000000018d833f60 in __26-[CNObservable doOnError:]_block_invoke ()
#16 0x000000018d833744 in __27-[CNObservable doOnCancel:]_block_invoke ()
#17 0x000000018d834d18 in -[CNObservable enumerateObjectsUsingBlock:] ()
#18 0x00000001907dc99c in __91-[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:]_block_invoke ()
#19 0x00000001857ecfac in os_activity_apply_f ()
#20 0x0000000190831bf0 in -[_CNContactsLogger fetchingContacts:] ()
#21 0x00000001907dc6b0 in -[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:] ()
#22 0x00000001907b568c in -[CNContactStore enumerateContactsWithFetchRequest:error:usingBlock:] ()