react-native-restart
react-native-restart copied to clipboard
App crash when RN.restart() use on IOS
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
https://github.com/facebook/react-native/issues/36776
Thank you very much
Are you using react-native-reanimated in your project?
Are you using
react-native-reanimatedin your project?
Yes. And I have the same issue both v3 version or below
Are you using
react-native-reanimatedin 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.
I have already.
setTimeout(()=>{
RNRestart.restart();
},300)
I will try with 1000 like you.
By the way, Restart is deprecated; restart must be use.
I just tried, still the same problem.
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.
the same problem
Always the same for me. Any idea @avishayil ?
Same problem
Same problem, adding a timeout does not help
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.
Hello, on my side I solved the problem by enabling hermes in podfile + pod install. Tested on device & simulator.
same。
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();
}
BTW I use Xcode_14.3.1.app to build the app
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.
The same. Any solution so far?
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.
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.
i just facing the issue for now, any update ?
My app crashes on iOS 17 when using RNRestart.restart() or RNRestart.Restart(). When will the bug be fixed?
This issue is caused by react-native-reanimated with disabled Hermes
https://github.com/software-mansion/react-native-reanimated/issues/1424
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
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 ?
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.
+1
Same problem !! anyone get any solution ?
@ThadeusRonnThomas Tried commenting the same but didnt work for me. Can you help us with a temporary workaround?
Same problem!! is there any workaround??
+1