Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-2063

React native UI is stuck / freezes when adding more than 200 listeners on a same collection and inserting objects (tested on ios, could also happen on android)

      How frequently does the bug occur?

      All the time

      Description

      I have a collection with a lot of objects in it with around 10 properties.
      I have a component representing this object in the UI and add a listener connected to realm query on each UI element. (meaning if I am displaying 200 elements, there will be 200 listeners).
      When inserting a new object in the collection, I always write three times to Realm. Once for the initial object with an isLocal flag of true, once on db update callback with isLocal flag false and once more on a listener set on my server with isLocal flag undefined.

      My issue is that, in my application it happens that the user will do this action of inserting a new item many times in a row, and I have noticed that when that happens, the UI becomes unresponsive because of the listeners. Whenever I remove the listeners, the app is as responsive as ever.

      I have tried to make the listeners empty anonymous functions (e.g.: () => {}) but it doesn't help..
      Only removing the listeners fixes the issue.

      Stacktrace & log output

      No response

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      You may clone this repo.
      1) Install using yarn && cd ./ios && pod install && cd ..
      2) run the app using npx react-native run-ios
      3) Tap "Add task" many times in a row

      Result:
      The UI kind of freezes in between adding of tasks

      Expected:
      You UI will be just as responsive with 200 listeners as with none

      Version

      ^0.66.3

      What SDK flavour are you using?

      Local Database only

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      iOS 16.1

      Build environment

      Which debugger for React Native: ..

      Cocoapods version

      1.11.2

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: