Hello!
Our team have been using a NSFetchedResultsController
with viewContext
for list UI.
But we found some UI Hang logs, and I'm guessing that it happens because of Faulting in viewContext
.
The main thread call stacks in the logs look like below.
0 libsystem_kernel.dylib 0x00000001f378dbcc kevent_id + 8
1 libdispatch.dylib 0x00000001b4047b0f _dispatch_kq_poll + 227
2 libdispatch.dylib 0x00000001b40484df _dispatch_event_loop_wait_for_ownership + 435
3 libdispatch.dylib 0x00000001b4034983 __DISPATCH_WAIT_FOR_QUEUE__ + 339
4 libdispatch.dylib 0x00000001b403454b _dispatch_sync_f_slow + 147
5 CoreData 0x00000001b42859b3 _perform + 203
6 CoreData 0x00000001b4372767 -[NSManagedObjectContext+ 1275751 (_NestedContextSupport) newValuesForObjectWithID:withContext:error:] + 163
7 CoreData 0x00000001b424cf87 _PFFaultHandlerLookupRow + 275
8 CoreData 0x00000001b424cbbf _PF_FulfillDeferredFault + 191
9 CoreData 0x00000001b424cab7 _pvfk_header + 167
10 CoreData 0x00000001b424c9d7 _sharedIMPL_pvfk_core + 31
11 Works 0x000000010445517b closure #1 in static MailUIMailFactory.make(mail:needFolderName:) + 26530171 (MailUIMailFactory.swift:109)
...
0 libsystem_kernel.dylib 0x00000001dbd4254c kevent_id + 8
1 libdispatch.dylib 0x000000019b7057d3 _dispatch_kq_poll + 227
2 libdispatch.dylib 0x000000019b7061bb _dispatch_event_loop_wait_for_ownership + 435
3 libdispatch.dylib 0x000000019b6f2593 __DISPATCH_WAIT_FOR_QUEUE__ + 339
4 libdispatch.dylib 0x000000019b6f215b _dispatch_sync_f_slow + 147
5 CoreData 0x000000019b94f24b _perform + 203
6 CoreData 0x000000019ba3c41b -[NSManagedObjectContext+ 1274907 (_NestedContextSupport) newValueForRelationship:forObjectWithID:withContext:error:] + 167
7 CoreData 0x000000019b914387 -[NSFaultHandler retainedFulfillAggregateFaultForObject:andRelationship:withContext:] + 391
8 CoreData 0x000000019b9118bf -[_NSFaultingMutableSet willReadWithContents:] + 391
9 CoreData 0x000000019b91e663 -[_NSFaultingMutableSet count] + 23
10 Foundation 0x0000000192dbeb3f -[NSSet+ 7609151 (NSKeyValueSorting) sortedArrayUsingDescriptors:] + 55
11 Works 0x000000010249ec1f specialized static MailUIMailFactory.make(mail:needFolderName:) + 27470879 (MailUIMailFactory.swift:102)
...
We just use NSFetchedResultsController
's fetchedObjects
in table view's cellForRowAt
method, and make a new model by MailUIMailFactory.make
.
So we're thinking that we need to initialize NSFetchedResultsController
with bg Context.
What you guys think?
Do I avoid using viewContext
in heavy UI?