Realm lock threads with two bundle applications
See original GitHub issueI have two bundles running simultaneously in the react-native, having the following structure:
- RCTRootView
- UIView
- RCTRootView
- UIView
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:
- Created 6 years ago
- Reactions:5
- Comments:14 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@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.
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.