Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm Crashes on App Startup [React-Native] #5026

Closed
marcfrankel opened this issue Oct 21, 2022 · 22 comments
Closed

Realm Crashes on App Startup [React-Native] #5026

marcfrankel opened this issue Oct 21, 2022 · 22 comments

Comments

@marcfrankel
Copy link

marcfrankel commented Oct 21, 2022

How frequently does the bug occur?

All the time

Description

I have a rather strange bug. It only appears when creating a release build of the ios app. Realm will crash the app right away. I'm using RealmJS version 11.0.0-rc.1 which should be the proper version according to the compatibility matrix. I am on Expo version 46.0.16 and using Hermes.

Local builds work fine, but when I build for release the app crashes instantly on startup. Sadly I produce my release builds through EAS, so getting dsym for the crash log is a little tricky. However, after much fiddling around, I believe the crash is related to building the app with Static Frameworks turned on.

Sadly, I really need this setting enabled as our app also uses React-Native Firebase and enabling Static Frameworks is a requirement for their more recent versions.

Perhaps the compatibility matrix needs updating or I would love to know if you have some sort of workaround or patch I can perform

Stacktrace & log output

Sadly this is non-symbolicated:
Thread 12 Crashed:
0   libsystem_kernel.dylib        	       0x1ddbfa200 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x1ede371ac pthread_kill + 268
2   libsystem_c.dylib             	       0x1a8a493f4 __abort + 128
3   libsystem_c.dylib             	       0x1a89f1cac abort + 192
4   libc++abi.dylib               	       0x1edd79b8c abort_message + 132
5   libc++abi.dylib               	       0x1edd69a80 demangling_terminate_handler() + 336
6   libobjc.A.dylib               	       0x19a8d9eec _objc_terminate() + 144
7   SaidThatDEV                   	       0x104aa75d4 0x104474000 + 6501844
8   libc++abi.dylib               	       0x1edd78f28 std::__terminate(void (*)()) + 20
9   libc++abi.dylib               	       0x1edd7becc __cxa_rethrow + 148
10  libobjc.A.dylib               	       0x19a8d5854 objc_exception_rethrow + 44
11  CoreFoundation                	       0x1a15892a8 CFRunLoopRunSpecific + 808
12  SaidThatDEV                   	       0x104f58d10 0x104474000 + 11422992
13  Foundation                    	       0x19b9a6ce8 __NSThread__start__ + 716
14  libsystem_pthread.dylib       	       0x1ede316cc _pthread_start + 148
15  libsystem_pthread.dylib       	       0x1ede30ba4 thread_start + 8

Can you reproduce the bug?

Yes, always

Reproduction Steps

Create a release build of the app on EAS 46.0.16, with realm version 11.0.0-rc.1 and static frameworks turned on using the 'expo-build-properties' package. The app will build successfully, but crash on launch.

Version

11.0.0-rc.1

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

ios 15.2

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

@kneth
Copy link
Contributor

kneth commented Oct 24, 2022

@marcfrankel It looks like it is similar to #4735. Unfortunately we haven't found a solution yet but you mention "related to building the app with Static Frameworks turned on" which is interesting.

@kneth
Copy link
Contributor

kneth commented Oct 24, 2022

Do you see the crash if you use the debug build instead?

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Oct 24, 2022
@marcfrankel
Copy link
Author

@kneth As you can see I commented on that thread, I definitely think they are related. Apologies if I caused a duplicate issue.

To answer your question no I do not see the issue with the debug build. Works fine on the simulator. Pretty sure it worked on a debug build for my physical phone too, but I can check again.

I believe I've isolated it to working with Static Frameworks off even in release, but I'll also kick off a build rn and re-confirm

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Oct 24, 2022
@marcfrankel
Copy link
Author

Okay created a couple of builds. Can confirm that toggling Static Frameworks on and off for me seems to control whether or not it fails.

So to summarize, having Static Frameworks turned on causes RealmJS V 11.0.0-rc.1 to crash my app running Expo 46.0.16 and Hermes. However, the crash only occurs on release builds. In debug mode, it works for simulators and physical devices.

@kneth
Copy link
Contributor

kneth commented Oct 25, 2022

@marcfrankel Could be related to expo/expo#19517?

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels Oct 25, 2022
@marcfrankel
Copy link
Author

It very well could be. I was never able to test just static frameworks without Realm Js and the main reason I thought realm was the culprit was that it appeared in the crash logs. However, maybe that's just due to how early realm starts up in the app startup sequence. I'll follow along on these issues. But my guess from looking at those bug reports it likely goes all the way to the top (meaning React Native itself). Not expo. So this fix might be a while.

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Oct 25, 2022
@kneth
Copy link
Contributor

kneth commented Oct 31, 2022

I'll leave the issue open, and if either you or we see any updates, we can share them.

@sync-by-unito sync-by-unito bot added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels Oct 31, 2022
@thecoorum
Copy link

thecoorum commented Nov 2, 2022

Experiencing the same issue on production iOS build after installing app and crashlytics packages from @react-native-firebase. The issue output mentions missing Realm constructor

Fatal Exception: RCTFatalException: Unhandled JS Exception: Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting
Unhandled JS Exception: Error: Missing Realm constructor. Did you run "pod install"? Please see https://docs.mongodb.com/realm/sdk/react-native/install/ for troubleshooting, stack: <unknown>@1268:500 h@2:1707 <unknown>@1267:35 h@2:1707 <unknown>@1266:259 h@2:1707 <unknown>@1265:155 h@2:1707 <unknown>@1261:138 h@2:1707 <unknown>@1257:210 h@2:1707 <unknown>@1133:189 h@2:1707 <unknown>@1132:175 h@2:1707 <unknown>@1131:111 h@2:1707 <unknown>@1078:230 h@2:1707 <unknown>@1077:190 h@2:1707 <unknown>@1019:220 h@2:1707 <unknown>@446:224 h@2:1707 <unknown>@6:57 h@2:1707 d@2:1080 global code@2052:3

@kneth
Copy link
Contributor

kneth commented Nov 4, 2022

Experiencing the same issue on production iOS build after installing app and crashlytics

And it works if these packages are not installed?

It is similar to #5071.

@marcfrankel
Copy link
Author

I wanted to update that it appears to be working now for us with the following combination of stuff:

Expo 47
Hermes
Static Frameworks on
Realm JS 11.2.0

So I believe we're all good. Thanks to the team for apparently fixing this! Will report back if it regresses

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Nov 17, 2022
@kneth
Copy link
Contributor

kneth commented Nov 18, 2022

@marcfrankel Thank you for the update. I imagine you are using React Native 0.70.

@sync-by-unito sync-by-unito bot removed the Needs-Attention Reporter has responded. Review comment. label Nov 18, 2022
@marcfrankel
Copy link
Author

@kneth Yup, sorry for not specifying. I was implying it through my usage of Expo 47, but I'm on RN version 0.70.5. Also still no issues 🎊

@klcantrell
Copy link

klcantrell commented Nov 24, 2022

I have a minimal example that reliably reproduces the app crashing on iOS characterized by this issue as well as #5071 and #5083.

The particular combination of dependencies:

Steps to reproduce:

  1. Clone down the minimal example and install dependencies
  2. Run in release mode to observe the crash

Further observations:

  1. Simply having Realm + Expo SDK installed at the same time causes the issue. I don't even need to instantiate Realm from the JavaScript side.
  2. Any of the following changes will allow the app to launch in release mode successfully
    • Uninstall Realm
    • Uninstall Expo
    • Disable hermes
  3. I've also observed this issue on a much larger project with dozens of dependencies. It seems unique to the interplay between Realm and Expo as simply uninstalling Realm lets the app launch successfully.
  4. App seems to run fine in debug
  5. Things seem to work fine on Android

Other info about the setup I used to repro the issue:

  • iPhone 11 simulator on iOS 16.1
  • Mac with Intel processor

Sample stack trace on crash (iOS):

* thread #10, name = 'com.facebook.react.JavaScript'
    frame #0: 0x0000000110d97fc8 hermes`___lldb_unnamed_symbol6597 + 120
    frame #1: 0x0000000110c48310 hermes`___lldb_unnamed_symbol3774 + 112
    frame #2: 0x0000000110c174a0 hermes`___lldb_unnamed_symbol3437 + 4016
    frame #3: 0x0000000110b42f7e hermes`___lldb_unnamed_symbol1107 + 190
    frame #4: 0x0000000110b256a3 hermes`___lldb_unnamed_symbol606 + 723
    frame #5: 0x000000010f143c38 ReactNativeIssueRepro`facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::call(facebook::jsi::Function const&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) [inlined] facebook::jsi::RuntimeDecorator<facebook::jsi::Runtime, facebook::jsi::Runtime>::call(this=0x0000600001f801d8, f=0x0000700007ece930, jsThis=0x0000700007ece800, args=0x0000700007ece810, count=2) at decorator.h:303:19 [opt]
    frame #6: 0x000000010f143c1b ReactNativeIssueRepro`facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::call(this=0x0000600001f801d8, f=<unavailable>, jsThis=<unavailable>, args=<unavailable>, count=<unavailable>) at decorator.h:709:16 [opt]
    frame #7: 0x000000010f1c1086 ReactNativeIssueRepro`facebook::jsi::Value facebook::jsi::Function::call<char const (&) [11], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(facebook::jsi::Runtime&, char const (&) [11], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) const + 198
    frame #8: 0x000000010f1b113a ReactNativeIssueRepro`realm::js::realmjsi::ObjectWrap<realm::js::ObservableClass<realm::js::realmjsi::Types> >::create_constructor(realm::js::JsiEnv) + 602
    frame #9: 0x000000010f1ae1a4 ReactNativeIssueRepro`realm::js::RealmClass<realm::js::realmjsi::Types>::create_constructor(realm::js::JsiEnv) + 36
    frame #10: 0x000000010f1ae01e ReactNativeIssueRepro`realm_jsi_init + 142
  * frame #11: 0x000000010f18f986 ReactNativeIssueRepro`__24-[RealmReact setBridge:]_block_invoke(.block_descriptor=<unavailable>) at RealmReact.mm:156:11 [opt]
    frame #12: 0x000000010f06086b ReactNativeIssueRepro`facebook::react::tryAndReturnError(std::__1::function<void ()> const&) [inlined] std::__1::__function::__value_func<void ()>::operator(this=<unavailable>)() const at function.h:505:16 [opt]
    frame #13: 0x000000010f060859 ReactNativeIssueRepro`facebook::react::tryAndReturnError(std::__1::function<void ()> const&) [inlined] std::__1::function<void ()>::operator(this=<unavailable>)() const at function.h:1182:12 [opt]
    frame #14: 0x000000010f060859 ReactNativeIssueRepro`facebook::react::tryAndReturnError(func=<unavailable>)> const&) at RCTCxxUtils.mm:74:7 [opt]
    frame #15: 0x000000010f055938 ReactNativeIssueRepro`-[RCTCxxBridge _tryAndHandleError:](self=0x00007f8947712c80, _cmd=<unavailable>, block=<unavailable>) at RCTCxxBridge.mm:344:20 [opt]
    frame #16: 0x00007ff800c7f5f7 Foundation`__NSThreadPerformPerform + 177
    frame #17: 0x00007ff800387035 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #18: 0x00007ff800386f74 CoreFoundation`__CFRunLoopDoSource0 + 157
    frame #19: 0x00007ff800386771 CoreFoundation`__CFRunLoopDoSources0 + 212
    frame #20: 0x00007ff800380e73 CoreFoundation`__CFRunLoopRun + 927
    frame #21: 0x00007ff8003806f7 CoreFoundation`CFRunLoopRunSpecific + 560
    frame #22: 0x000000010f05587d ReactNativeIssueRepro`+[RCTCxxBridge runRunLoop](self=<unavailable>, _cmd=<unavailable>) at RCTCxxBridge.mm:335:12 [opt]
    frame #23: 0x00007ff800c7f1c3 Foundation`__NSThread__start__ + 1009
    frame #24: 0x00007ff834c3d4e1 libsystem_pthread.dylib`_pthread_start + 125
    frame #25: 0x00007ff834c38f6b libsystem_pthread.dylib`thread_start + 15

Please let me know if I can provide any other info to help figure this one out (or whether I should open a new issue if this comment doesn't belong here). I appreciate you, Realm team!

@mindrootstech
Copy link

mindrootstech commented Dec 2, 2022

I got same issue, app crashed on launching

Using: M1
below dependencies:

"@expo/react-native-action-sheet": "^3.14.0",
"@invertase/react-native-apple-authentication": "^2.2.2",
"@react-native-async-storage/async-storage": "^1.17.7",
"@react-native-clipboard/clipboard": "^1.11.0",
"@react-native-community/geolocation": "^3.0.3",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-picker/picker": "^2.4.4",
"@react-navigation/bottom-tabs": "^6.3.2",
"@react-navigation/drawer": "^6.4.3",
"@react-navigation/native": "^6.0.11",
"@react-navigation/native-stack": "^6.7.0",
"@react-navigation/stack": "^6.2.2",
"@reduxjs/toolkit": "^1.8.3",
"@types/react-native-vector-icons": "^6.4.11",
"expo": "^46.0.0",
"expo-barcode-scanner": "^11.4.0",
"expo-camera": "^12.3.0",
"i18next": "^21.8.14",
"moment": "^2.29.4",
"react": "18.1.0",
"react-i18next": "^11.18.1",
"react-native": "0.70.1",
"react-native-config": "^1.4.6",
"react-native-device-info": "^10.0.2",
"react-native-fast-image": "^8.6.0",
"react-native-fbsdk": "^3.0.0",
"react-native-gesture-handler": "^2.5.0",
"react-native-highlight-word": "^1.0.3",
"react-native-image-crop-picker": "^0.38.0",
"react-native-image-slider": "^1.1.5",
"react-native-inappbrowser-reborn": "^3.7.0",
"react-native-localize": "^2.2.3",
"react-native-permissions": "^3.6.1",
"react-native-ratings": "^8.1.0",
"react-native-reanimated": "^2.9.1",
"react-native-reanimated-carousel": "^3.0.4",
"react-native-restart": "^0.0.24",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "^3.15.0",
"react-native-splash-screen": "^3.3.0",
"react-native-svg": "^13.0.0",
"react-native-ui-action-sheet": "^1.0.3",
"react-native-vector-icons": "^9.2.0",
"react-native-webview": "^11.23.0",
"react-redux": "^8.0.2",
"realm": "^11.3.0"

if i uninstall realm. then run app on real device then app working fine

any solution?

@qusaieilouti99
Copy link

@marcfrankel

Can u please tell me how did you fix this issue I have almost the same combination but still crashes?
I have:
Expo 47
Hermes enabled
Static Frameworks on
Realm JS 11.3.0
running on an M1 machine
react-native 0.70.6

@MusabBasheer
Copy link

any update on this ??

@klcantrell
Copy link

I think this issue can be closed. See #4735.

@takameyer
Copy link
Contributor

This issue has been fixed by expo by upgrading to expo@47.0.9 or expo@46.0.19

@emanuel-carneiro
Copy link

Just to let you know that this still happens on the latest version.

Install latest version "realm": "^11.4.0" (i.e. "npm i realm") and the app still crashes on iOS.
I have downgraded to "realm": "10.9.0" and it worked.

I haven't tested on Android.

When I debugged the app on Xcode I was getting the same error as @klcantrell

@FN-FAL113
Copy link
Contributor

Just to let you know that this still happens on the latest version.

Install latest version "realm": "^11.4.0" (i.e. "npm i realm") and the app still crashes on iOS. I have downgraded to "realm": "10.9.0" and it worked.

I haven't tested on Android.

When I debugged the app on Xcode I was getting the same error as @klcantrell

having the same issue on android, did u also downgraded your react native version?

@FN-FAL113
Copy link
Contributor

FN-FAL113 commented Feb 7, 2023

Mine crashes on first realm.write()
saw the logcat with debug infos regarding librealm.so and SIGABRT signal
Not sure if react reanimated 2 causes any problem just from what i've read on the forums closed gh issues

@kneth
Copy link
Contributor

kneth commented Feb 8, 2023

@FN-FAL113 I will ask you to create a new issue to ensure we get all needed information.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants