realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Latest Hermes Realm + Reanimated V2 = Crash on re-open

Open hassanbazzi opened this issue 2 years ago • 27 comments

How frequently does the bug occur?

Sometimes

Description

Hey!

I'm seeing tons of crashes coming in from our users ever since we added reanimated v2 to our project. Everything was going perfectly with 10.20.0-beta.2. But then the crashes started coming in when we added Reanimated v2.

We have no idea why it's happening but we get:

Fatal Exception: RCTFatalException: Unhandled JS Exception: Error: Missing Realm constructor. Did you run "pod install"? through firebase console.

Stacktrace & log output

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, js engine: hermes
0  CoreFoundation                 0x99d78 __exceptionPreprocess
1  libobjc.A.dylib                0x16734 objc_exception_throw
2  Nuna                           0x2bb368 RCTFormatError + 166 (RCTAssert.m:166)
3  Nuna                           0x33becc -[RCTExceptionsManager reportFatal:stack:exceptionId:] + 68 (RCTExceptionsManager.mm:68)
4  Nuna                           0x33c8d4 -[RCTExceptionsManager reportException:] + 135 (RCTExceptionsManager.mm:135)
5  CoreFoundation                 0x22614 __invoking___
6  CoreFoundation                 0x40100 -[NSInvocation invoke]
7  CoreFoundation                 0x7713c -[NSInvocation invokeWithTarget:]
8  Nuna                           0x2eeee4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 587 (RCTModuleMethod.mm:587)
9  Nuna                           0x2f1528 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext) + 183 (RCTNativeModule.mm:183)
10 Nuna                           0x2f114c invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 419 (Optional.h:419)
11 libdispatch.dylib              0x1e68 _dispatch_call_block_and_release
12 libdispatch.dylib              0x3a2c _dispatch_client_callout
13 libdispatch.dylib              0xb124 _dispatch_lane_serial_drain
14 libdispatch.dylib              0xbc80 _dispatch_lane_invoke
15 libdispatch.dylib              0x16500 _dispatch_workloop_worker_thread
16 libsystem_pthread.dylib        0x10bc _pthread_wqthread
17 libsystem_pthread.dylib        0xe5c start_wqthread

Can you reproduce the bug?

Yes, sometimes

Reproduction Steps

This usually never happens on fresh install. It only happens if users quit the app and then relaunch.

Version

10.20.0-beta.2

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

iOS

Build environment

PodFile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'aya' do
  # Pods for aya

  config = use_native_modules!
 
  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => true
  )


  target 'ayaTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end

Package JSON:

"dependencies": {
        "@hexigames/react-native-apple-ads-attribution": "^1.0.2",
        "@invertase/react-native-apple-authentication": "^2.1.0",
        "@notifee/react-native": "^5.0.2",
        "@react-native-async-storage/async-storage": "^1.15.17",
        "@react-native-community/cli-platform-ios": "6.2.0",
        "@react-native-community/netinfo": "7.1.2",
        "@react-native-community/push-notification-ios": "^1.10.1",
        "@react-native-community/slider": "^4.1.10",
        "@react-native-firebase/app": "^14.5.0",
        "@react-native-firebase/auth": "^14.5.0",
        "@react-native-firebase/crashlytics": "^14.5.0",
        "@react-native-firebase/dynamic-links": "^14.5.0",
        "@react-native-firebase/messaging": "^14.5.0",
        "@react-native-firebase/perf": "^14.5.0",
        "@react-native-firebase/remote-config": "^14.5.0",
        "@react-native-google-signin/google-signin": "7.0.1",
        "@react-native-seoul/masonry-list": "^1.0.6",
        "@react-navigation/bottom-tabs": "^6.0.9",
        "@react-navigation/native": "^6.0.6",
        "@react-navigation/stack": "^6.0.11",
        "@segment/analytics-react-native": "^1.4.4",
        "@segment/analytics-react-native-amplitude": "^1.4.4",
        "@segment/analytics-react-native-firebase": "^1.5.0",
        "axios": "0.26.1",
        "lottie-ios": "3.2.3",
        "lottie-react-native": "5.0.1",
        "moment": "^2.25.3",
        "patch-package": "^6.4.7",
        "postinstall-postinstall": "^2.1.0",
        "prop-types": "^15.7.2",
        "react": "17.0.2",
        "react-native": "0.67.4",
        "react-native-check-box": "^2.1.7",
        "react-native-circular-progress-indicator": "^2.0.6",
        "react-native-date-picker": "^4.1.5",
        "react-native-dotenv": "^2.5.3",
        "react-native-flash-message": "0.2.0",
        "react-native-gesture-handler": "^1.10.3",
        "react-native-in-app-review": "^3.3.2",
        "react-native-linear-gradient": "^2.5.6",
        "react-native-modal": "13.0.0",
        "react-native-onesignal": "4.3.5",
        "react-native-progress-circle": "^2.1.0",
        "react-native-purchases": "^4.5.2",
        "react-native-reanimated": "^2.4.1",
        "react-native-safe-area-context": "^3.3.2",
        "react-native-screens": "^3.9.0",
        "react-native-snap-carousel": "^3.9.1",
        "react-native-svg": "^12.1.0",
        "react-native-svg-transformer": "^0.14.3",
        "react-native-webview": "^9.4.0",
        "react-native-youtube": "^2.0.1",
        "react-redux": "^7.2.0",
        "realm": "v10.20.0-beta.2",
        "redux": "^4.0.5",
        "redux-thunk": "^2.3.0"
    },
    "devDependencies": {
        "@babel/core": "^7.16.0",
        "@babel/eslint-parser": "^7.16.3",
        "@babel/runtime": "7.12.5",
        "@react-native-community/eslint-config": "^2.0.0",
        "babel-eslint": "^10.1.0",
        "babel-jest": "26.6.3",
        "eslint": "^7.14.0",
        "eslint-plugin-react": "^7.26.0",
        "eslint-plugin-react-hooks": "^4.3.0",
        "eslint-plugin-react-native": "^3.11.0",
        "eslint-plugin-unicorn": "^39.0.0",
        "husky": "^4.3.8",
        "jest": "26.6.3",
        "jetifier": "^1.6.6",
        "lint-staged": "^10.5.4",
        "metro-react-native-babel-preset": "0.66.2",
        "prettier": "^2.0.5",
        "pretty-quick": "^3.1.0",
        "react-native-clean-project": "^3.6.4",
        "react-test-renderer": "17.0.2"
    },

Cocoapods version

1.11.2

hassanbazzi avatar Mar 24 '22 18:03 hassanbazzi

Hi @hassanbazzi .. we just released 10.20.0-beta.3. Can I have you upgrade and verify that you're still seeing this?

kraenhansen avatar Mar 24 '22 18:03 kraenhansen

Same error on [email protected]. This only happens on iOS.

sashansk3 avatar Mar 25 '22 04:03 sashansk3

I tried (but failed) to reproduce this. I've setup an app with the latest hermes release of Realm JS and React Native Reanimated 2.5.0: https://github.com/kraenhansen/reanimated-realm-test .. I tried swiping out the app, hot reloading, etc. I can't get it to crash.

Any help / PR bringing that repo to a crashing state would be greatly appreciated!

kraenhansen avatar Mar 25 '22 09:03 kraenhansen

@kraenhansen Did you do this with a release build? I've only been able to replicate on release build.

hassanbazzi avatar Mar 25 '22 09:03 hassanbazzi

I'll try my best to replicate in an isolated way today.

hassanbazzi avatar Mar 25 '22 09:03 hassanbazzi

Yep. My repo uses Realm JS 10.20.0-beta.3.

kraenhansen avatar Mar 25 '22 09:03 kraenhansen

Thing is, it's tough to replicate in dev. I can only replicate in production in release mode. Maybe try and use my same package.json and pod file?

hassanbazzi avatar Mar 28 '22 12:03 hassanbazzi

@hassanbazzi

Did you do this with a release build?

Yep. I tried this in both release and debug build configurations.

kraenhansen avatar Mar 28 '22 14:03 kraenhansen

We're releasing beta.3 to our users this morning. I'll monitor and let you know :(

hassanbazzi avatar Mar 29 '22 08:03 hassanbazzi

Some notes from our experience. It only happnes on IOS production. There is no way to reproduce this on development. Also Crash happens randomly. 1 out of 10 times it works without any issues.

DioSerdar avatar Mar 30 '22 10:03 DioSerdar

^^ We've seen the same. I basically just close and reopen the app a bunch of times and then it happens. :/

hassanbazzi avatar Mar 30 '22 11:03 hassanbazzi

@hassanbazzi & @DioSerdar are you calling Realm JS APIs from inside Reanimated worklets?

kraenhansen avatar Mar 30 '22 12:03 kraenhansen

atm, we're only using re-animated for entrance and exit animations, nothing else. Not using worklets yet.

hassanbazzi avatar Mar 30 '22 13:03 hassanbazzi

We launched the new version with beta.3, and already having 23 users with the crash.

hassanbazzi avatar Mar 30 '22 13:03 hassanbazzi

@hassanbazzi I'm really sorry to hear that. I'd love to get to the bottom of this - can you help us reproduce this? Perhaps by altering the repo I linked above or provide concrete steps I need to take with that app to get to a crash.

kraenhansen avatar Mar 31 '22 09:03 kraenhansen

@kraenhansen I am not even sure that this is caused by the re-animated. We have it as a dependency on the project but it's only used by react-navigation.

DioSerdar avatar Apr 01 '22 16:04 DioSerdar

@kraenhansen any update on this?

DioSerdar avatar Apr 05 '22 09:04 DioSerdar

@DioSerdar no update, since we're still missing a reproduction. Unfortunately we can't make progress before we can reproduce the crash. See the repo above which tries but doesn't exhibit the crash.

kraenhansen avatar Apr 05 '22 09:04 kraenhansen

Just in case anyone else has this problem. We have solved our crash problem by upgrading our react-navigation from 5.x to 6.x and removed any references to re-animated from our dependencies.

DioSerdar avatar Apr 08 '22 00:04 DioSerdar

@DioSerdar thank you so much. We have upgraded navigation v5 to v6 and it is working ☺

enescang avatar Apr 08 '22 00:04 enescang

@enescang Do you also have reanimated installed? And which version?

As you can see, our react navigation is at v6 already

hassanbazzi avatar Apr 08 '22 05:04 hassanbazzi

@DioSerdar Thank you for sharing

kneth avatar Apr 08 '22 07:04 kneth

@hassanbazzi no we uninstalled react-native-reanimated. No longer needed as we upgrade the version

enescang avatar Apr 08 '22 14:04 enescang

Although I am not using realm in my project, I am posting it here since I feel it is something related to react-native-reanimated v2, react-native v0.67.x and Macs with M1 chips (Not sure though, still figuring out the common grounds for this issue).

Even I am facing the same issue with archived builds i.e app crashes on all the iOS device running on < iOS 15.x, runs perfectly fine on iOS 15.0 devices. It crashes as soon as app is launched, seems like internally the program excecution control is not even reaching the JS bundle. I am using react-native v0.67.2, react-navigation v6, react-native-reanimated v2. I am not using realm. I only get iPhone ReportCrash[1858] <Notice>: Formulating report for corpse[1857] [AppName] log when I try to run it on browser stack devices.

Any help is highly appreciated. Thanks in advance.

abitling avatar Apr 08 '22 20:04 abitling

Updating react-native-reanimated to the latest version "2.8.0" solved this issue for us.

We used previously: Realm: "10.20.0-beta.5" Navigation: "6.*" react-native-reanimated: "2.5.0"

After the update, we could no longer detect any crashes.

dennis-fritsch avatar May 11 '22 12:05 dennis-fritsch

@Fridge-o which version of the Realm are you using?

rkz98 avatar May 13 '22 14:05 rkz98

@rkz98 The same version as mentioned above

"realm": "10.20.0-beta.5"

We only updated react-native-reanimated to the latest version

dennis-fritsch avatar May 17 '22 07:05 dennis-fritsch

Please upgrade to version 11.0.0 or later

kneth avatar Nov 03 '22 16:11 kneth