question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Realm lock threads with two bundle applications

See original GitHub issue

I have two bundles running simultaneously in the react-native, having the following structure:

  • RCTRootView
    • UIView
      • RCTRootView

When this view structure is applied, realm starts the new thread successfully in the first RCTRootView. When the second thread will start with the second RCTRootView, the code that checks if the thread is finished goes into loops, locking the main thread and blocking the bundle loading.

It has been verified that the code that is causing this problem is in the class: From issue #1065 implementation. RealmReact.mm - 275 until 285 - below:

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: 1.10.0
  • React Nattive: 0.41.2
  • Client OS & Version: Mac OS 10.12.6

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:5
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
oximercommented, Aug 24, 2017

@kneth I also want to support this thread. Without it, it’s impossible difficult to use realm on my app. We have multiples react native bundle on my app. Many guys that are not creating an app from scratch are on the same scenario.

2reactions
jpsslinkcommented, Aug 21, 2017

Same problem here. Do you know the last version which this problem doesn’t occur? This is blocking our development and we can’t rollback to versions before 1.9.0 cause we need the backlink feature too. Thanks in advance.

Realm JS SDK Version: 1.10.0
React Native: 0.44.0
Client OS & Version: Mac OS 10.12.4
Read more comments on GitHub >

github_iconTop Results From Across the Web

Threading - Java SDK — Realm - MongoDB
Live objects, collections, and realms are thread-confined. If you need to work with the same data across multiple threads, you should open the...
Read more >
Crash in background on iOS 15 EXC_CRASH (SIGKILL)
Hello, Since the first iOS 15 beta and even with all the next public releases, we have a very weird crash each time...
Read more >
Create reactive mobile apps in a fraction of the time - Realm
You can also bundle prebuilt Realm files in your app. ... and will block the thread they are made on if multiple writes...
Read more >
Where should I place my default.realm database file? : r/swift
Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=2"Unable to open a realm at path ...
Read more >
Realm Custom Configuration and Encryption (RealmSwift Part ...
There is a better way and we will discuss it shortly. Figure 2. Pre Bundle Realm File. You can ship pre bundle data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found