Does RLMRealm.isEmpty lie sometimes?


#1

I’m using Standard Realm Platform Cloud with the Objective C SDK in a mixed Objective C+Swift project. When I do an asyncOpen, on a few occasions the sync Realm returned in the completion handler says it is empty when I know it isn’t. This is confirmed by using Realm Studio. If the sync Realm is empty I want to copy a local Realm to the sync Realm. I certainly don’t want to do a copy if the Realm isn’t really empty. Has anyone else seen this behavior? Here is the gist of my code:

        let config = RLMSyncUser.current?.configuration(realmURL: RealmConstants.realmURL, fullSynchronization: true)        
        RLMRealm.asyncOpen(with: config!, callbackQueue: DispatchQueue.main) { (syncRealm, error) in
          if let error = error {
            let message = "The database could not be synced: \(error.localizedDescription)"
            print(message)
          } else if syncRealm != nil && syncRealm!.isEmpty {
	        // Copy local realm to sync realm
          } else {
	        // Do something else
          }
        }