react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Maximum call stack size exceeded (native stack depth) when loading from EAS Update

Open sagihsh opened this issue 2 years ago • 12 comments

Description

Hi, I am running an Expo managed app with SDK 49, and Reanimated 3.3.0 After upgrading to SDK 49 (and to Reanimated 3.3.0 which goes with it), my app started crashing when loaded from an EAS update using the Expo Go app, while working fine locally (Both with Expo Go or in a development build).

While debugging the issue I noticed that it only happens while I still have some usage of reanimated. Once reanimated is out, the issue goes away.

On iOS it crashes completely, in Android in hangs on 'New update available, downloading...'

I have pulled the following errors from the iOS logs (similar error appears in Android logcat logs too):

Expo Go RangeError: Maximum call stack size exceeded (native stack depth), js engine: hermes Expo Go Invariant Violation: "main" has not been registered. This can happen if: Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes Expo Go NSInvalidArgumentException: -[EXReactAppExceptionHandler handleFatalJSExceptionWithMessage:stack:exceptionId:extraDataAsJSON:]: unrecognized selector sent to instance 0x281fa8380

Steps to reproduce

  1. Clone the minimal reproducible project
  2. Run npm i
  3. Run npm start and see the project runs locally
  4. use eas update command to make an update (you will probably have to change the configuration in app.json to match an Expo project you have access to, possibly a fresh one you created. See 'extra.eas.projectId' & 'updates.url' keys in app.json file)
  5. Try to load that update using the Expo Go app

Snack or a link to a repository

https://github.com/sagihsh/expo-sdk-49-eas-update-crash-example

Reanimated version

3.3.0

React Native version

0.72.3

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

Expo managed workflow

Architecture

Paper (Old Architecture)

Build type

None

Device

Real device

Device model

iPhone 13 for iOS / Samsung Galaxy S8 for Android

Acknowledgements

Yes

sagihsh avatar Aug 13 '23 07:08 sagihsh

I have the same error after upgrading to React Native 0.71. I used react-native-reanimated 2.14.4 and 3.4.2, doesn't seem to make any difference. To be fair I do not know if it is related to react-native-reanimated, I haven't been able to reproduce the issue myself but I am getting lots of reports for this same error.

Pingou avatar Aug 16 '23 07:08 Pingou

Same issue here

pohsiu avatar Sep 16 '23 10:09 pohsiu

Maybe related to https://github.com/expo/expo/issues/23382

mo6zes avatar Sep 24 '23 13:09 mo6zes

I also face this issue in expo prebuild unless I run ./gradlew assembleRelease in android folder it work fine if I run yarn android --variant=release is crashed

chanphiromsok avatar Oct 02 '23 09:10 chanphiromsok

Same for me, when using latest RN version + reanimated 3 it leads to crash with react-navigation/drawer

T-Damer avatar Oct 05 '23 16:10 T-Damer

This randomly started happening to me out of nowhere does anybody have a workaround?

pfcodes avatar Nov 24 '23 05:11 pfcodes

Update: This issue is confirmed to be fixed by upgrading to 3.6.0

https://github.com/expo/expo/issues/23382#issuecomment-1834527955

pfcodes avatar Dec 01 '23 05:12 pfcodes

Hi @sagihsh. Does this error still occure in your case? I tried to reproduce it, but everything works for me. If so, does it still crashes with Expo SDK 50?

jfedak avatar Dec 15 '23 14:12 jfedak

I am still having this crash with the updated version. Again, I'm not sure it comes from react-native-reanimated and my stacktrace is different.

Pingou avatar Dec 26 '23 10:12 Pingou

I had this issue as soon as I upgraded to SDK 50 as well. I was able to find the root cause for my case if that's helpful for anyone else. My issue was in @expo/config-plugins with a Config object attempting to be destructured for an expoUsername property when it was undefined

I fixed this using npx patch-package, here is the patch:

diff --git a/node_modules/@expo/config-plugins/build/android/Updates.js b/node_modules/@expo/config-plugins/build/android/Updates.js
index 0c071b0..6f19aa7 100644
--- a/node_modules/@expo/config-plugins/build/android/Updates.js
+++ b/node_modules/@expo/config-plugins/build/android/Updates.js
@@ -89,7 +89,7 @@ exports.Config = Config;
 })(Config || (exports.Config = Config = {}));
 const withUpdates = (config, {
   expoUsername
-}) => {
+} = {}) => {
   return (0, _withPlugins().withPlugins)(config, [[withUpdatesManifest, {
     expoUsername
   }], withRuntimeVersionResource]);
diff --git a/node_modules/@expo/config-plugins/build/ios/Updates.js b/node_modules/@expo/config-plugins/build/ios/Updates.js
index 82deb1a..7c89031 100644
--- a/node_modules/@expo/config-plugins/build/ios/Updates.js
+++ b/node_modules/@expo/config-plugins/build/ios/Updates.js
@@ -62,7 +62,7 @@ exports.Config = Config;
 })(Config || (exports.Config = Config = {}));
 const withUpdates = (config, {
   expoUsername
-}) => {
+} = {}) => {
   return (0, _iosPlugins().withExpoPlist)(config, config => {
     const projectRoot = config.modRequest.projectRoot;
     const expoUpdatesPackageVersion = (0, _Updates().getExpoUpdatesPackageVersion)(projectRoot);

ladyshaitan avatar Mar 12 '24 20:03 ladyshaitan

i have same when i install core-js & jwt-decode

sampadanaik avatar May 10 '24 06:05 sampadanaik

i have same when i install core-js & jwt-decode

same here

ahsanbhatti98 avatar May 14 '24 12:05 ahsanbhatti98

I am facing the same issue. A lot of these error logs are printed in my console but only on Android both in debug and release mode, no such errors in iOS. The app works fine though, it never crashes. As @Pingou mentioned, I also started facing this issue after upgrading my RN version to RN 71.x. This strongly seems to be an issue related to Hermes on Android as mentioned here: https://github.com/handsontable/hyperformula/discussions/1286.

The error is also hard to debug as it does not get caught by any breakpoint and there are no stack traces, just this:

Unhandled promise rejection [RangeError: Maximum call stack size exceeded (native stack depth)]
Unhandled promise rejection [RangeError: Maximum call stack size exceeded (native stack depth)]
Unhandled promise rejection [RangeError: Maximum call stack size exceeded (native stack depth)]
Unhandled promise rejection [RangeError: Maximum call stack size exceeded (native stack depth)]
Unhandled promise rejection [RangeError: Maximum call stack size exceeded (native stack depth)]

JJSLIoT avatar Jul 08 '24 06:07 JJSLIoT

@JJSLIoT My issue was that I was resetting the state in the parent component when the app went into foreground/background and also in the child component. Not sure why that was an issue but removing one of them fixed it for me.

Pingou avatar Jul 08 '24 09:07 Pingou

The issue seems to have found a fix here. And the other reported things aren't connected to Reanimated whatsoever

szydlovsky avatar Jul 08 '24 11:07 szydlovsky