react-native-restart
react-native-restart copied to clipboard
App randomly crashes in production
It almost everytime crashes without any logs, but once I've managed to catch them:
E ReactNativeJS: TypeError: undefined is not a function, js engine: hermes
I ReactNativeJS: Unable to symbolicate stack trace: Bundle was not loaded from Metro.
E ReactNativeJS: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
E ReactNativeJS: This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
I ReactNativeJS: Unable to symbolicate stack trace: Bundle was not loaded from Metro.
E ReactNativeJS: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
E ReactNativeJS: This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
I ReactNativeJS: Unable to symbolicate stack trace: Bundle was not loaded from Metro.
It looks like the problem appeared after updating react native to version 0.64.0. Does this lib support new version or hermes engine?
I'm not familiar with this issue, it happens only on production bundles?
Hi everyone, I faced the same problem on both debug and release dist. I was calling RNRestart.Restart() at the top of RootNavigationStack function. I put the function call in my SplashScreen function (render when using classes) and it's working.
As a workaround for this issue, I suggest adding the following code to the main activity class (the one that extends ReactFragmentActivity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
}
I have been using this in a production app for more than a year now. reference -> https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067
I'm checking compatibility issues with hermes
Any news on this? Crashes on production build with React Native 0.63 / Android / Hermes.
@saskaak does it still crash on production build? I'm considering using this library but these crashes make me nervous.
@saskaak does it still crash on production build? I'm considering using this library but these crashes make me nervous.
For us, yes. Works just fine on iOS.
I don't know if the issue is the same but I had crashes everytime on Android (mostly because of react-navigate-geture-handler).
A fix is instead of restarting as soon as the user press a button, just add some logic to unmount all your components.
RootNavigation.tsx:
const RootNavigation = () => {
const { shouldRestart } = useShouldRestart()
if (shouldRestart) {
return <Restart />
}
// return your navigators
}
Restart.tsx:
import { useMount } from 'ahooks'
import { View } from 'react-native'
const Restart = () => {
useMount(() => {
// restartApp()
})
return <View />
}
export default Restart
useShouldRestart.ts:
import { atom, useRecoilState } from 'recoil'
export const shouldRestartAtom = atom({
key: 'shouldRestart',
default: false
})
const useShouldRestart = () => {
const [shouldRestart, setShouldRestart] = useRecoilState(shouldRestartAtom)
return { shouldRestart, setShouldRestart }
}
export default useShouldRestart
With this, you can simply set shouldRestart
to true and the app should cleanly close itself.
I still have SoftExceptions
s popping on logcat but the app doesn't crash anymore.
I solved the issue by https://github.com/avishayil/react-native-restart/issues/162#issuecomment-1038724027
I solved the issue by #162 (comment)
Facing same issue in production build... I tried above solution but it's not working perfectly(shared video)
https://user-images.githubusercontent.com/75003713/160824634-26970880-f480-4319-b0d2-516b1fdacf47.mp4
- app freezes for little-bit time & throw error,
- there is not others things in my function
code:
const setLanguage = async (code: string) => {
if (code === 'ar') {
await i18next.changeLanguage(code).then(() => {
I18nManager.forceRTL(true);
setTimeout(() => { RNRestart.Restart(); }, 150);
setShowSelectionPopup(false);
});
} else {
await i18next.changeLanguage(code).then(() => {
I18nManager.forceRTL(false);
setTimeout(() => { RNRestart.Restart(); }, 150);
setShowSelectionPopup(false);
});
}
console.log("code:", code);
};
@avishayil
I solved the issue by #162 (comment)
Facing same issue in production build... I tried above solution but it's not working perfectly(shared video)
RN-Restart-rec.mp4
- app freezes for little-bit time & throw error,
- there is not others things in my function
code:
const setLanguage = async (code: string) => { if (code === 'ar') { await i18next.changeLanguage(code).then(() => { I18nManager.forceRTL(true); setTimeout(() => { RNRestart.Restart(); }, 150); setShowSelectionPopup(false); }); } else { await i18next.changeLanguage(code).then(() => { I18nManager.forceRTL(false); setTimeout(() => { RNRestart.Restart(); }, 150); setShowSelectionPopup(false); }); } console.log("code:", code); };
@avishayil
Where you able to fix this issue?
Where you able to fix this issue?
Yep! by changing the Build configuration...
Open xCode > Product > Scheme > Edit Scheme... > Run(select from left panel) > Build configuration(info tab) = Release (this xCode 12.4 attached SS)
I've made a PR for it #211, I've used ProcessPhoenix framework instead of the react-native-code-push code style
Merged #211