Realm Swift Excessive Sync Requests

Everytime I run the app on the xcode simulator there’s about a 100 extra requests every minute on my realm application dashboard. Is this normal? This is how it looks in the console.

That doesn’t look crazy abnormal, and the changes size is 0 so I suspect there’s activity in the app triggering this. Have you isolated it to any code you can share.

If not, whatever you’re doing with the app starts, don’t do that as a test and see if you see the same activity. If not, slowly reintroduce code until you spot it again and then share that code with us.

Hello Again,

I’ve tried to just isolate it but i cant really pinpoint it to any specific code.

The logs just show “changing query from existing query to new query”.

The whole log history is filled with these sync requests happening every second. I’ve compiled the app multiple times and left it idle and even without any activity it keeps updating the query multiple times a second. I’ve cross checked the queries as well but they’re absolutely identical.

The syncmanager loglevel is set to debug but hasnt been very helpful. The changesets have still been 0 but the requests dont stop. How can i fix this? It hasnt affected device sync speed or function but the requests are only free until the first Million so it doesnt seem efficient to just let this
issue be.

This is how the logs look

Does you app have any observers? If so, what happens if those are disabled.

Do you call any server functions? How about authenticating users or is this a single user - standalone app?

No i dont have any observers anywhere. I dont use any server functions except for an aggregation pipeline thats only triggered when searching. Its a single user app. Authentication happens only once on the login screen.

well, looking at the logs I would say there’s either a query that’s being called/updated, or data written to realm that falls within the query parameters. Just a guess.

Are you by chance using the SwiftUI property wrappers @AsyncOpen or @AutoOpen? If so, they open up a brand new connection every time the view that they are a part of is rendered. You can see why that view is getting rendered with let _ = Self._printChanges() in your view body.

In my opinion these property wrappers aren’t really usable outside a tutorial because of this issue. I’m having more success using the normal Swift SDK and @ObservableObject environment objects to accomplish something similar.