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

RealmJS works compatiably with Realm Cocoa in one project

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: Q3-24FY
    • Component/s: None

      Bugs:

      In our hybrid project react native part uses RealmJS as database SDK and now we also want use realm cocoa in our native part. We find that in RealmJS initialization will clear all caches and this makes our native realm object all becoming invalid. Once we try to access these invalid object again, it causes a crash noted "Object has been deleted or invalidated.".

      Expected Results

      RealmJS works compatiably with Realm Cocoa in one project.

      Actual Results

      Open react native module using RealmJS clears all realm cache and makes native realm object not available which results in crash.

      Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'
      

      Code Sample

      void _initializeOnJSThread(JSContextRefExtractor jsContextExtractor) {
          // Make sure the previous JS thread is completely finished before continuing.
          static __weak NSThread *s_currentJSThread;
          while (s_currentJSThread && !s_currentJSThread.finished) {
              [NSThread sleepForTimeInterval:0.1];
          }
          s_currentJSThread = [NSThread currentThread];
      
          // Close all cached Realms from the previous JS thread.
          realm::_impl::RealmCoordinator::clear_all_caches();
      
          RJSInitializeInContext(jsContextExtractor());
      }
      

      Version of Realm and Tooling

      • Realm JS SDK Version: 6.1.2
      • Realm Cocoa SDK Version: 5.4.1
      • Node or React Native: node v14.12.0, react native cli 2.0.1
      • Client OS & Version: macOS 10.15.6

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

              Created:
              Updated: