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

[iOS] Extra instances of RCTBridge don't get instantiated when Realm is used

      Goals

      I'm trying to create an extra RCTBridge instance in React Native to offload CPU-intensive tasks to a separate React Native instance. It works well, see this example I made.

      Then I do yarn add realm && npx pod-install, which adds Realm to the project, and rebuild the app.

      Expected Results

      Both the main React Native bridge and my separate new RCTBridge for the sync process are instantiated and work well.

      Actual Results

      All of a sudden only the first RCTBridge instance gets instantiated. The second one either never gets created or halts in a deadlock?

      Steps to Reproduce

      1. Clone https://github.com/backmeupplz/react-native-ios-threading-example
      2. Install dependencies — yarn && npx pod-install
      3. Launch Reactotron
      4. Launch the app, observe both the React Native main thread and the separate Sync thread to start logging to Reactotron
      5. Install Realm — yarn add realm && npx pod-install
      6. Launch the app, observe only the React Native main thread to log to Reactotron, and Sync thread not being launched at all
      7. You can then switch the order or RCTBridge instantiations in the AppDelegate.m to verify that only the first instance of RCTBridge gets instantiated

      Code Sample

      https://github.com/backmeupplz/react-native-ios-threading-example

      Version of Realm and Tooling

      • Realm JS SDK Version: tested the issue on 6.1.5 and 10.1.3, both have this issue
      • Node or React Native: tested the issue on 0.63.3 and 0.63.4, both have the issue
      • Client OS & Version: iOS 14.2, simulator, React Native dev mode
      • Which debugger for React Native: I use Reactotron to keep track of multiple RCTBridge instances' logs

      Extra info

      In my particular case, I use React Native as the app that the user uses and a separate RCTBridge handles the synchronization logic between local Realm storage and my backend. But the example here is simplified to just show you the reproducible issue.

      From what it seems like, Realm also creates its own RCTBridge instances and modifies the built-in RCTBridge logic?

      Looks like this is an iOS-only issue, hence I only tested the above example on iOS.

            Assignee:
            kraen.hansen@mongodb.com Kræn Hansen
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: