Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ICloud: handiling of NSPersistentStoreDidImportUbiquitousContentChangesNotification done on main thread, locks up UI #398

Closed
firemuzzy opened this Issue · 4 comments

2 participants

@firemuzzy

The MR_mergeChangesFromiCloud in NSManagedObjectContext+MagicalObserving.m preforms the merging on the main thread. A large update from iCloud locks up UI.

@firemuzzy

I did not understand Core Data and MagicalRecord enough, and after looking at it again my culprit is NSFetchedResultsController. Large updates to my NSFetchedResultsController sitting over an iCloud store keeps locking up the UI, so I am doing stupid.

@firemuzzy firemuzzy closed this
@casademora
Owner

So, while you might have made an error in your code, would you mind explaining your scenario a bit more? I feel that though this isn't a bug per se, but in fact is more like an API bug. That is, it seems that the MagicalRecord API isn't as clear as it should be in order to achieve the intended results (ie. not running a merge on the main thread)

@firemuzzy

Sure.

Set up:

  • 2 separate controllers, 1 that doing the adding and 1 doing the displaying.
  • The 'adding' controller gets modally (but full screen) displayed over the 'displaying' controller.
  • The 'displaying' controller has an NSFetchedResultsController that observes the changes to a CoreData table that is synced with iCloud

Problem causing:

  • 'Adding' controller adds a lot of things to the context and saves it
  • The 'displaying' controller is still alive under the 'adding' controller
  • its NSFetchedResultsController notices the changes to the context
  • starts updating the table view (although the table view is really not visible because its covered up)
  • This big update of that table view locks up the UI (happens right after the NSPersistentStoreDidImportUbiquitousContentChangesNotification gets processed hence my confusion)

Have done so far to deal with it (but seems hackish):

  • On viewWillDisappear in the 'displaying' controller set the NSFetchedResultsController delegate to nil so it does not update
  • On viewDidAppear in the 'displaying' set the NSFetchedResultsController delegate back to what it was and reload the table view
@casademora
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.