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

App crash when RN.restart() use on IOS #239

Open
Sekiro-kost opened this issue Apr 4, 2023 · 34 comments
Open

App crash when RN.restart() use on IOS #239

Sekiro-kost opened this issue Apr 4, 2023 · 34 comments

Comments

@Sekiro-kost
Copy link

Hello

I'v a crash issue with IOS build (with metro and release build), when I use RN.restart()

Here is my thread about my issue

facebook/react-native#36776

Thank you very much

@Orange9000
Copy link

Are you using react-native-reanimated in your project?

@Sekiro-kost
Copy link
Author

Are you using react-native-reanimated in your project?

Yes. And I have the same issue both v3 version or below

@Orange9000
Copy link

Are you using react-native-reanimated in your project?

Yes. And I have the same issue both v3 version or below

Same here. I traced my crashes to reanimated. If you're using v3, could you try adding a delay before restart like this?

setTimeout(() => RNRestart.Restart(), 1000)

This seems to have helped in my case, although I'm still investigating.

@Sekiro-kost
Copy link
Author

Sekiro-kost commented Apr 18, 2023

I have already.

setTimeout(()=>{
      RNRestart.restart();
    },300)

I will try with 1000 like you.

By the way, Restart is deprecated; restart must be use.

@Sekiro-kost
Copy link
Author

I just tried, still the same problem.

@Devojha408
Copy link

Devojha408 commented May 7, 2023

I'm currently using React Native version 0.68 and the react-native-restart library version 0.0.24. I've tried adding a delay to my code, but I'm still experiencing crashes with the iOS build of my app.
@Sekiro-kost you still experiencing the issue.

@MohsinaliEMed
Copy link

the same problem

@Sekiro-kost
Copy link
Author

Always the same for me.
Any idea @avishayil ?

@rocket13011
Copy link

Same problem

@ShepSims
Copy link

ShepSims commented Jun 5, 2023

Same problem, adding a timeout does not help

@ArturKalach
Copy link

It seems that this problem related to runOnJS function from react-native-reanimated.

Like an example, when you use reanimated with gesture-hangler, using runOnJS can lead to crash.

If you use something like that:

    const tapGesture = Gesture.Tap().onStart(() => {
      runOnJS(onPress)()
    })

You can avoid issue with

    const tapGesture = Gesture.Tap()
      .runOnJS(true)
      .onStart(() => {
        onPress()
      })

But when we talk about worklets it gets difficult, I haven't find any solution yet.

@Lidobix
Copy link

Lidobix commented Jun 6, 2023

Hello, on my side I solved the problem by enabling hermes in podfile + pod install. Tested on device & simulator.

@Simoon-F
Copy link

Simoon-F commented Jul 3, 2023

same。

@ludwig-pro
Copy link

I have exactly the same problem. at first i suspected reanimated, but after patching it, i still get the bug.

Only in "release", according to sentry tracking, it's a RAM problem:

WatchdogTermination: The OS watchdog terminated your app, possibly because it overused RAM.

I try to replace react-native-restart by code-push and I have the same issue, also reported by other here

reanimated patch for react-native-reanimated 3.1.0 =>

diff --git a/node_modules/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m b/node_modules/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m
index 365ae4f..6290823 100644
--- a/node_modules/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m
+++ b/node_modules/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m
@@ -396,7 +396,7 @@ BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
     return NO;
   }
 
-  BOOL hasExitAnimation = _hasAnimationForTag(view.reactTag, EXITING) || [_exitingViews objectForKey:view.reactTag];
+  BOOL hasExitAnimation = [self hasAnimationForTag:view.reactTag type:EXITING] || [_exitingViews objectForKey:view.reactTag];
   BOOL hasAnimatedChildren = NO;
   shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation;
   NSMutableArray *toBeRemoved = [[NSMutableArray alloc] init];
@@ -521,7 +521,7 @@ BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
 {
   LayoutAnimationType type = before == nil ? ENTERING : LAYOUT;
   NSNumber *viewTag = view.reactTag;
-  if (_hasAnimationForTag(viewTag, type)) {
+  if ([self hasAnimationForTag:viewTag type:type]) {
     REASnapshot *after = [[REASnapshot alloc] init:view];
     if (before == nil) {
       [self onViewCreate:view after:after];
@@ -533,7 +533,7 @@ BOOL REANodeFind(id<RCTComponent> view, int (^block)(id<RCTComponent>))
     [self setNewProps:before.values forView:view];
   }
 
-  if (_hasAnimationForTag(viewTag, SHARED_ELEMENT_TRANSITION)) {
+  if ([self hasAnimationForTag:viewTag type:SHARED_ELEMENT_TRANSITION]) {
     if (type == ENTERING) {
       [_sharedTransitionManager notifyAboutNewView:view];
     } else {
diff --git a/node_modules/react-native-reanimated/src/reanimated2/mappers.ts b/node_modules/react-native-reanimated/src/reanimated2/mappers.ts
index 4e66106..bc8712f 100644
--- a/node_modules/react-native-reanimated/src/reanimated2/mappers.ts
+++ b/node_modules/react-native-reanimated/src/reanimated2/mappers.ts
@@ -80,8 +80,11 @@ export function createMapperRegistry() {
   }
 
   function mapperRun() {
-    processingMappers = true;
     runRequested = false;
+    if (processingMappers) {
+      return;
+    }
+    processingMappers = true;
     if (mappers.size !== sortedMappers.length) {
       updateMappersOrder();
     }

@ludwig-pro
Copy link

BTW I use Xcode_14.3.1.app to build the app

@jpangan
Copy link

jpangan commented Sep 6, 2023

This happens to me in Android. my setup is RN version 0.68.5, installed "react-native-restart": "0.0.24". I followed what's stated in the README.md but still getting the issue on Android.

@serhiiharbo
Copy link

The same. Any solution so far?

@bviebahn
Copy link

In my case I'm doing the restart when selecting a value from a dropdown which also results in this crash. I just removed the reanimated animation from the dropdown which seems to fix it.

@ghost
Copy link

ghost commented Oct 17, 2023

Getting a similar issue with the following:
"react-native-code-push": "^8.0.0",
"react-native": "0.71.13",
"react-native-reanimated": "3.5.4",

From Xcode logs:
2023-10-17 12:04:34.002039-0700 app[5567:35772] [native] Invalidating <RCTCxxBridge: 0x7fb2a5a08dc0> (parent: <RCTBridge: 0x6000028acbd0>, executor: (null))
Assertion failed: (objectCounter_ == 0 && "JSCRuntime destroyed with a dangling API object"), function ~JSCRuntime, file JSCRuntime.cpp, line 412.

@NguyenHoangMinhkkkk
Copy link

i just facing the issue for now, any update ?

@VadymBezsmertnyi
Copy link

My app crashes on iOS 17 when using RNRestart.restart() or RNRestart.Restart(). When will the bug be fixed?

@vasylnahuliak
Copy link

This issue is caused by react-native-reanimated with disabled Hermes

software-mansion/react-native-reanimated#1424

@ThadeusRonnThomas
Copy link

I Commented out the following assertions for the time being.
from react jsc

//#ifndef NDEBUG
// assert(
// objectCounter_ == 0 && "JSCRuntime destroyed with a dangling API object");
// assert(
// stringCounter_ == 0 && "JSCRuntime destroyed with a dangling API string");
//#endif

@NguyenHoangMinhkkkk
Copy link

I Commented out the following assertions for the time being. from react jsc

//#ifndef NDEBUG // assert( // objectCounter_ == 0 && "JSCRuntime destroyed with a dangling API object"); // assert( // stringCounter_ == 0 && "JSCRuntime destroyed with a dangling API string"); //#endif

hello, is this a workaround ?

@ThadeusRonnThomas
Copy link

You can use it as a temporary workaround. This just disables the check for objectCounter_ and stringCounter_.
This is not a fix for the issue.

@malikzype
Copy link

+1

@Pankajjajra
Copy link

Same problem !! anyone get any solution ?

@malikzype
Copy link

@ThadeusRonnThomas Tried commenting the same but didnt work for me. Can you help us with a temporary workaround?

@GwiYeong
Copy link

Same problem!! is there any workaround??

@Kozlove3
Copy link

+1

@Sekiro-kost
Copy link
Author

Sekiro-kost commented Jul 31, 2024

I solve the problem with :

"react-native-restart": "0.0.27" , "react-native-reanimated": "3.5.2", on my package.json

import RNRestart from 'react-native-restart';

RNRestart.restart();

@Ahsanabid27
Copy link

Ahsanabid27 commented Aug 16, 2024

Hey I'm using "react-native-restart" but getting an error on the ios release build
App got stuck on the change language screen sometimes it's working smoothly sometimes it's stuck i've try to debug this run on the debuging mode it gives an error when i close the metro on Ios
Error: "Timed out waiting for modules to be invalidated"
(in debug mode working fine)

@junaiddarajat
Copy link

I solve the problem with :

"react-native-restart": "0.0.27" , "react-native-reanimated": "3.5.2", on my package.json

import RNRestart from 'react-native-restart';

RNRestart.restart();

Tried this but still the same behavior on iOS, are you certain about this?

@Sekiro-kost
Copy link
Author

Sekiro-kost commented Oct 7, 2024

I solve the problem with :
"react-native-restart": "0.0.27" , "react-native-reanimated": "3.5.2", on my package.json
import RNRestart from 'react-native-restart';
RNRestart.restart();

Tried this but still the same behavior on iOS, are you certain about this?

Yes I'm sure, my app is in production, and everything works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests