realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Error: Missing Realm constructor. When New Architecture is enabled #5032

Closed SuperBigBang closed 1 year ago

SuperBigBang commented 1 year ago

How frequently does the bug occur?

All the time

Description

Error: Missing Realm constructor. Did you run "pod install" on react-native run-android. I try to build app on MacMini. Everything works fine if Hermes is enabled and New Architecture is disabled. But, as soon as I turn on the new architecture, the application crashes after launch with such an error. The app is built from the newest Reactnative example.

my package: "react": "18.1.0", "react-native": "0.70.3", "realm": "11.0.0",

I also tried to clear the build folder, put different versions of ream-11-rc-2 and so on

Stacktrace & log output

ERROR  Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting, js engine: hermes
 LOG  Running "test-project" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":41}

Can you reproduce the bug?

Yes, always

Reproduction Steps

  1. Init latest React-native 70 fabric example (NO expo)
  2. Add latest realm package to project (11.0.0)
  3. Hermes ON (now by default), New Architecture ON
  4. react-native run-android

    Successfully build x Crush on startup app

Version

v11.0.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android 10

Build environment

All from React-native 0.70.3 newest template. Ruby 2.7.6

Cocoapods version

No response

kneth commented 1 year ago

@SuperBigBang Thank you for reporting. Your issue has some similarities with https://github.com/facebook/react-native/issues/34684. Can you share the log before the app throws the error so we can see if your issue is related?

SuperBigBang commented 1 year ago

@SuperBigBang Thank you for reporting. Your issue has some similarities with facebook/react-native#34684. Can you share the log before the app throws the error so we can see if your issue is related?

`2022-10-28 21:57:12.085 32541-32541/? E/Zygote: isWhitelistProcess - Process is Whitelisted 2022-10-28 21:57:12.086 32541-32541/? E/Zygote: accessInfo : 1 2022-10-28 21:57:12.128 32541-32541/? E/com.grkb_app: Unknown bits set in runtime_flags: 0x8000 2022-10-28 21:57:12.671 32541-32541/com.grkb_app E/SoLoader: couldn't find DSO to load: libjscexecutor.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.grkb_app/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/com.grkb_app-2KlB6A2yWb0Ntt9e1x02XQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] Native lib dir: /data/app/com.grkb_app-2KlB6A2yWb0Ntt9e1x02XQ==/lib/arm64 result: 0 2022-10-28 21:57:13.118 32541-32541/com.grkb_app E/DecorView: mWindow.mActivityCurrentConfig is null 2022-10-28 21:57:13.148 32541-32541/com.grkb_app E/unknown:ReactRootView: Unable to update root layout specs for ReactRootView: no rootViewTag set yet 2022-10-28 21:57:14.323 32541-4413/com.grkb_app E/KeyStore: generateKeyInternal failed on request -68 2022-10-28 21:57:17.170 32541-4415/com.grkb_app E/ReactNativeJS: Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting, js engine: hermes 2022-10-28 21:57:17.249 32541-4415/com.grkb_app E/ReactNativeJNI: getModule of AppRegistry is not an object 2022-10-28 21:57:17.249 32541-4415/com.grkb_app E/ReactNative: /Users/admin/IdeaProjects/grkb_app3/node_modules/react-native/ReactCommon/react/renderer/uimanager/bindingUtils.cpp:29: function getModule: assertion failed (moduleAsValue.isObject()) 2022-10-28 21:57:17.249 32541-4415/com.grkb_app A/ReactNative: /Users/admin/IdeaProjects/grkb_app3/node_modules/react-native/ReactCommon/react/renderer/uimanager/bindingUtils.cpp:29: function getModule: assertion failed (moduleAsValue.isObject())

--------- beginning of crash

2022-10-28 21:57:17.249 32541-4415/com.grkb_app A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 4415 (mqt_js), pid 32541 (com.grkb_app) `

kneth commented 1 year ago

@SuperBigBang

The follow line could indicate it is the same issue as https://github.com/facebook/react-native/issues/34684

2022-10-28 21:57:12.671 32541-32541/com.grkb_app E/SoLoader: couldn't find DSO to load: libjscexecutor.so

Out of curiosity: you do observe the crash if you disable "new architecture"?

SuperBigBang commented 1 year ago

Out of curiosity: you do observe the crash if you disable "new architecture"?

Everything works fine if Hermes is enabled and New Architecture is disabled

kneth commented 1 year ago

@SuperBigBang Thank you for the update. It indicates we need to investigate why it doesn't work for New Architecture.

mMarcos208 commented 1 year ago

I'm testing libraries in newArch. I created a new project and added realm only.

I have the same issue, see on my GitHUB

"realm": "^11.2.0"

Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting, js engine: hermes

mattveraldi commented 1 year ago

I have the same issue using Expo (latest version, new project created today).

    "expo": "~47.0.8",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-native": "0.70.5",
    "realm": "^11.3.0"
nmateo commented 1 year ago

Same issue. "dependencies": { "@realm/react": "^0.4.1", "expo": "~47.0.8", "expo-status-bar": "~1.4.2", "react": "18.1.0", "react-native": "0.70.5", "realm": "^11.3.0", "swr": "^1.3.0", "unfetch": "^4.2.0" },

l4n2k1 commented 1 year ago

same issue on IOS.

dependencies: {
   "react-native": "0.67.2",
   "realm": "11.3.0",
}
kneth commented 1 year ago

@Zoelanpham You need to upgrade to RN 0.70.

l4n2k1 commented 1 year ago

@kneth I don't think that's a good idea, because upgrading the version to 0.70 is a new architecture that will occur many other problems.

samknp commented 1 year ago

Same issue on "dependencies": { "expo": "~47.0.9", "react-native": "0.70.6", "realm": "^11.3.1" },

How can I use realm on window without mac os ?

poonamdhomane commented 1 year ago

Is there any solution or workaround for this, as this issue is coming only in debugging mode , if we disable the chrome/step debugger issue is not coming But it leads to difficulty in tracking other bugs. I need step debugging enabled, and help me on this, spent a lot of time on this. Even the flipper Hermes debugger not showing up the files

takameyer commented 1 year ago

@poonamdhomane That's a different issue. The chrome debugger is not compatible with realm. If you want step debugging, use Hermes and flipper. You can add debugger; to any line of code and flipper will pick it up and break on that line.
Unfortunately, the file viewer in flipper does not seem to be working. I have also tried to get that to show something, but never had success. This seems to be an issue with Flipper itself.

takameyer commented 1 year ago

@Zoelanpham React Native v70 contains a new architecture, but it is not active by default. You can safely upgrade without opting into it.

poonamdhomane commented 1 year ago

@takameyer but getting below error on console of vs code debug terminal, and app not even starting only in case debugging otherwise app is working proper

Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting node_modules/react-native/Libraries/Core/ExceptionsManager.js:151 Running application DemoApp ({ initialProps = { }; rootTag = 11; }) node_modules/react-native/Libraries/Utilities/RCTLog.js:47 Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

I tried this disabling the Hermes and instead of flipper, I am using vs code step debugger

takameyer commented 1 year ago

@poonamdhomane Can you create a new issue and write out what you are trying to accomplish and how it is failing? We can discuss further there, as what you are experiences is different than this issue.

poonamdhomane commented 1 year ago

@takameyer
I guess because of Realm constuctor issue, am not able to debug. Can run the application only if debugging is disabled.

As if I started debugging then only I am getting the same issue of the Realm constructor

Sharing screenshot of my debug terminal for your reference Screenshot 2023-01-13 at 4 59 35 PM

takameyer commented 1 year ago

@takameyer Enabling debugging (which in turn enables chrome debugging) is not compatible with Realm. It will throw this issue when active. Please follow my instructions above if you want step debugging (does not require enabling debugging in the app)

poonamdhomane commented 1 year ago

@takameyer created new bug #5257

cherylli commented 1 year ago

started a new project and still getting this error, tried many things to fix it even downgrading realm and react native, nothing worked (using EXPO)

How do you enable Hermes and disable the new architecture?

"Everything works fine if Hermes is enabled and New Architecture is disabled

"@realm/react": "^0.4.3",    
"expo": "~48.0.4",
"react-native": "0.71.3",    
"realm": "^11.5.1",
ArindamRayMukherjee commented 1 year ago

Hi,

I am getting the same at the following with the new architecture enabled on trying to run the app for android.

    "react": "18.2.0",
    "react-native": "0.71.2",
    "realm": "^11.4.0",

Why does it ask for a pod install of any kind for android install in the first place? Disabling new architecture is not an option for me as I need it and am intentionally trying to move to it.

kneth commented 1 year ago

@ArindamRayMukherjee

Disabling new architecture is not an option

Our support of the new architecture isn't so well-developed yet so for now enabling it will make it hard to get Realm to work.

ArindamRayMukherjee commented 1 year ago

@kneth Understood. Any timelines on when this will get looked at? Is this a major architectural shift for realm or is this smaller than that? Also curious that this is problem for android alone. We need the react-native new architecture because our app needs to access C++ turbomodules, its not something we can disable meaningfully in the long run.

zabutok commented 1 year ago

Hey @kneth please consider this solution https://github.com/realm/realm-js/pull/5683

kraenhansen commented 1 year ago

@zabutok I wanted to chime in on this issue as well. We're now done with the majority of work on the new v12 SDK and we want to tackle issues like this, next. We would like to retain support for building with the new architecture disabled and I was considering implementering a multi sourceset approach as outlined in this tutorial: https://github.com/react-native-community/RNNewArchitectureLibraries/tree/feat/back-turbomodule#android-sourceset

mboldrini commented 1 year ago

Are you still having this problem? I tried everything and I couldn't solve it in my app "react": "18.1.0", "react-native": "0.70.8", "realm": "^11.8.0",

kneth commented 1 year ago

@mboldrini You probably have to upgrade to RN 0.71.

kraenhansen commented 1 year ago

@mboldrini please also try upgrading to v12.0.0-alpha.2 as that's the release with support for the new architecture.

jayaprakash-official-dev commented 1 year ago

same error getting any solution ?

"react-native": "0.71.4", "realm": "^11.9.0",

Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting, js engine: hermes

kneth commented 1 year ago

@jayaprakash-official-dev You need to upgrade to v12.0.0-alpha.2. We don't plan to backport the fix to v11.

kriit24 commented 11 months ago

with 11.9.0 i had same issue with v12.0.0-alpha.2 i have issue: TypeError: Cannot read property 'Helpers_get_table' of undefined, js engine: hermes

... its really piece of shit

youbek commented 10 months ago

Yes, upgrading to v12.0.0-alpha.2 is giving error TypeError: Cannot read property 'Helpers_get_table' of undefined, js engine: hermes error.

I have react native 7.44.3

Here's active open issue for the above error: https://github.com/realm/realm-js/issues/5829

is there other way around to fix this in the v11?

youbek commented 10 months ago

For me this error is not happening when running using expo run:ios. It is happening when running expo start

kraenhansen commented 10 months ago

@youbek you're most likely hitting https://github.com/realm/realm-js/issues/5981