SyncKit icon indicating copy to clipboard operation
SyncKit copied to clipboard

synchronisation before sharing - is it necessary?

Open BlixLT opened this issue 5 years ago • 0 comments

  1. I noticed that the sample project performs synchronisation before sharing a company and if synchronisation fails, then nothing happens. Is it a must by framework? (I mean to perform synchronisation each time right before sharing an object). If it is, then it is really not user friendly. This additional step (synchronisation) may take some time before user sees UI's response to his action (after clicking the share button). Or even he can see no response to his share action at all. (I mean, if synchronisation is already in progress (because there were a lot changes for example), the user clicks share, synchronisation immediately fails with an already syncing error and nothing happens). Most users prefer that data would be synchronised without a need every time clicking a button, thats how I tried to implement synchronisation in our app - some sync manager observes modelAdapterHasChangesNotification and start synchronisation then. So, when user decides to share an object, it is likely that no extra synchronisation step is needed. I expected that calling synchronizer.share() would be enough. But unfortunately I experiencing freezes (deadlocks) very often. If synchronisation process is still in progress, some privateContext.performAndWait somewhere is being called. And synchronizer.share() also calls privateContext.performAndWait on its new thread. Two threads calls performAndWait on the same managedObjectContext == deadlock.
  2. I noticed that there are actually a lot performAndWait in the framework files. Are they all really necessary? Wouldn't it be possible to refactor code, that it would use perform instead. For example where records to upload are being fetched, you can add completion to that method, fetch objects in privateContext.perform and at the end call completion block with fetched objects as one of parameters. I suppose all performAndWait could be avoided similarly. Maybe code would become more difficult to read, but because of possible deadlocks I try to avoid performAndWait as much as possible. Well, unless there are known sync/share issues, that only performAndWait can solve.

BlixLT avatar Oct 23 '19 15:10 BlixLT