Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange merging error #280

Open
timbuchwaldt opened this issue Sep 29, 2018 · 7 comments
Open

Strange merging error #280

timbuchwaldt opened this issue Sep 29, 2018 · 7 comments

Comments

@timbuchwaldt
Copy link

During development I see a very strange error: When I insert data into core data it's synced perfectly fine. If I update some part of the object (the title) on my Mac though I sometimes see fields becoming nil - but only specific ones. For me that is the two binary fields I have. Even stranger: At times I see data from other CoreData objects appearing instead of nil - and in a consistent manner - so it's the preview + actual binary data from the same wrong document appearing under the title I just changed.

All of this strangeness resolves if I remove the app on my phone and re-install it.

General logic is the following: I subscribe to CDEMonitoredManagedObjectContextDidSave and sync on my Mac. On the iOS side I react to CDEICloudFileSystemDidDownloadFiles, then trigger the usual merge on the main thread.
I also implement didSaveMergeChangesWith to update my main context from the delegate callback, which I also do in the main thread. Logging the notification received shows data not being nil or anything.

@drewmccormack
Copy link
Owner

drewmccormack commented Sep 29, 2018 via email

@timbuchwaldt
Copy link
Author

More testing revealed: 99.999% my error in implementing globalIdentifiersForManagedObjects in a slighly dumb way (by using a value that might not actually exist on all types I support to be synced).

Thanks again for the swift replies @drewmccormack - looking forward to licensing v2 if the project I'm building ever makes any money :)

@timbuchwaldt
Copy link
Author

Okay.. more tests revealed a flaw in my testing:
It seems like I only did a full re-setup after disabling "allow external storage" on my CoreData Entities.

Switching that back on and setting up again leads to exactly the errors described. Cleaning, setting up again with "allow external storage" disabled -> 0 issues.

FYI: I'm using NSPersistentContainer, don't know if that changes anything but I guess it really shouldn't.

@timbuchwaldt timbuchwaldt reopened this Sep 29, 2018
@drewmccormack
Copy link
Owner

drewmccormack commented Sep 29, 2018 via email

@timbuchwaldt
Copy link
Author

Status:
If I enable external storage of my binary fields altering the containing objects on one device destroys the other devices state by either making the fields become nil or contain other objects binary data.
In case it shows other objects data it shows both fields from the same other object.

Please note I don't alter the binary data in any way. It's set on the first insert to the app and from there on is meant to remain stable.

Between tries I clear the cloud data as well as all local data, so there should be no trace left. Currently this is pre-alpha development, so I just rm -rf ~/Library/Mobile Documents/iCloud/$appid

@drewmccormack
Copy link
Owner

drewmccormack commented Sep 29, 2018 via email

@timbuchwaldt
Copy link
Author

timbuchwaldt commented Sep 29, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants