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

How to sync data in widget? #176

Open
Mr-ZNN opened this issue Mar 2, 2022 · 5 comments
Open

How to sync data in widget? #176

Mr-ZNN opened this issue Mar 2, 2022 · 5 comments

Comments

@Mr-ZNN
Copy link

Mr-ZNN commented Mar 2, 2022

My project has added widget. Without the need to open the app, the data needs to be updated synchronously when the widget is updated, so I created a synchronizer in both the app and the widget, or created a synchronizer in a singleton class to give app and widget use. However, after the widget is synchronized, opening the app and synchronizing the realm in the app will report the following error:
*** Terminating app due to uncaught exception 'RLMException', reason: 'Attempting to create an object of type 'GroupMessage' with an existing primary key value 'D2CB7AB4-D505-4568-83D1-CBA8EB28408B'.'

@aehlke
Copy link

aehlke commented Aug 16, 2022

did you figure it out? this is worrisome

@mentrena
Copy link
Owner

Hey, would need more information to possibly look into this. Things like snippets, a description of your flow, a description of how many Realms you're using and where you're storing...
Generally it's a bad idea to create more than one synchronizer in your app for the same Realm store –still, not sure if that's what you're even doing.

@aehlke
Copy link

aehlke commented Sep 2, 2022

I also just ran into this with a UUID PK. I'm looking into it.

@aehlke
Copy link

aehlke commented Sep 2, 2022

First off I see that IceCream treats insertions and modifications to the realm db the same: https://github.com/caiyue1993/IceCream/blob/0b6b24a4eddc331361f3123eab48ef116b123161/IceCream/Classes/SyncObject.swift#L136-L149 whereas SyncKit treats them specially. I think this may be a mistake and source of a race condition or similar issue

@aehlke
Copy link

aehlke commented Sep 2, 2022

I've fixed it with defensive coding in my fork, BigSyncKit: lake-of-fire/BigSyncKit@c2d9e18

I collapsed .new and .changed into .newOrChanged and then allowed the realm.add to update an existing object at the site of the crash.

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

3 participants