{"action":"created","issue":{"url":"https://api.github.com/repos/wix/react-native-navigation/issues/2331","repository_url":"https://api.github.com/repos/wix/react-native-navigation","labels_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2331/labels{/name}","comments_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2331/comments","events_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2331/events","html_url":"https://github.com/wix/react-native-navigation/issues/2331","id":281480310,"node_id":"MDU6SXNzdWUyODE0ODAzMTA=","number":2331,"title":"Restarting app via instanceManager.recreateReactContextInBackground leads to crash","user":{"login":"ruslan-bikkinin","id":30265843,"node_id":"MDQ6VXNlcjMwMjY1ODQz","avatar_url":"https://avatars2.githubusercontent.com/u/30265843?v=4","gravatar_id":"","url":"https://api.github.com/users/ruslan-bikkinin","html_url":"https://github.com/ruslan-bikkinin","followers_url":"https://api.github.com/users/ruslan-bikkinin/followers","following_url":"https://api.github.com/users/ruslan-bikkinin/following{/other_user}","gists_url":"https://api.github.com/users/ruslan-bikkinin/gists{/gist_id}","starred_url":"https://api.github.com/users/ruslan-bikkinin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruslan-bikkinin/subscriptions","organizations_url":"https://api.github.com/users/ruslan-bikkinin/orgs","repos_url":"https://api.github.com/users/ruslan-bikkinin/repos","events_url":"https://api.github.com/users/ruslan-bikkinin/events{/privacy}","received_events_url":"https://api.github.com/users/ruslan-bikkinin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-12-12T17:54:15Z","updated_at":"2018-06-06T17:20:21Z","closed_at":null,"author_association":"NONE","body":"### Issue Description\r\n\r\nWe are working on [react-native-code-push](https://github.com/avishayil/react-native-code-push) module for CodePush and facing troubles investigating [this](https://github.com/Microsoft/react-native-code-push/issues/1088).\r\nBriefly, we are providing API method for \"soft\" app restart (e.g. without killing application) using RN context restarting mechanism based on [`instanceManager.recreateReactContextInBackground();` method of `ReactInstanceManager` class](https://github.com/avishayil/react-native-restart/blob/master/android/src/main/java/com/avishayil/rnrestart/ReactNativeRestart.java#L55) and for some RNN scenarios this approach leads to the app crashes.\r\nI am asking for assistance from you guys to help us to figure out what could be the source of problem here because restarting breaks only for `react-native-navigation` apps and works like a charm with usual RN app.\r\n\r\n### Steps to Reproduce / Code Snippets / Screenshots\r\n\r\n`App.js`:\r\n\r\n```javascript\r\nimport { AsyncStorage, AppRegistry } from 'react-native';\r\nimport { Navigation } from 'react-native-navigation';\r\nimport React from 'react';\r\nimport { Text } from 'react-native';\r\nimport RNRestart from \"react-native-restart\";\r\n\r\nconst App = () =>\r\n\t<Text onPress={() => RNRestart.Restart()}>\r\n\t\tTouch to run RNRestart.Restart and see the crash\r\n\t</Text>\r\n;\r\n\r\nconst screenName = Math.random().toString();\r\n\r\nNavigation.registerComponent(screenName, () => App);\r\n//check what components was registered\r\nconsole.log(\"Registered components: \" + AppRegistry.getAppKeys());\r\nNavigation.startSingleScreenApp({\r\n\tscreen: {\r\n\t\tscreen: screenName,\r\n\t},\r\n\tpassProps: { },\r\n});\r\n```\r\n\r\n1. Download [demo project](https://github.com/ruslan-bikkinin/rnnCrashApp) and run `npm i`. It uses [react-native-restart](https://github.com/avishayil/react-native-restart) package that contains pure restart code API extracted from `react-native-code-push`.\r\n2. Build it using `./gradlew assembleDebug` from `android` directory\r\n3. Install apk on simulator\r\n4. Ensure there is something like this in Logcat logs:\r\n\r\n![image](https://user-images.githubusercontent.com/30265843/33899558-ee52fd1c-df7c-11e7-9d9e-7c7d50197721.png)\r\n\r\n5. Click on button within app.\r\n6. Observe the crash and ensure there is something like this in Logcat logs:\r\n\r\n![image](https://user-images.githubusercontent.com/30265843/33899587-01fc2622-df7d-11e7-8b78-a9e5898e9167.png)\r\n\r\n**Expected Behavior:**\r\nNo crash, only one registered application is running.\r\n\r\n**Actual Behavior:**\r\nFor some reason RN tries to run old application too instead of running just the new one. \r\n\r\n---\r\n### Environment\r\n* React Native Navigation version: 1.1.305\r\n* React Native version: 0.50.3\r\n* Platform(s) (iOS, Android, or both?): android\r\n* Device info (Simulator/Device? OS version? Debug/Release?): tested on simulator, android 7.0.0, debug\r\n"},"comment":{"url":"https://api.github.com/repos/wix/react-native-navigation/issues/comments/395147323","html_url":"https://github.com/wix/react-native-navigation/issues/2331#issuecomment-395147323","issue_url":"https://api.github.com/repos/wix/react-native-navigation/issues/2331","id":395147323,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTE0NzMyMw==","user":{"login":"ericketts","id":35305520,"node_id":"MDQ6VXNlcjM1MzA1NTIw","avatar_url":"https://avatars1.githubusercontent.com/u/35305520?v=4","gravatar_id":"","url":"https://api.github.com/users/ericketts","html_url":"https://github.com/ericketts","followers_url":"https://api.github.com/users/ericketts/followers","following_url":"https://api.github.com/users/ericketts/following{/other_user}","gists_url":"https://api.github.com/users/ericketts/gists{/gist_id}","starred_url":"https://api.github.com/users/ericketts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericketts/subscriptions","organizations_url":"https://api.github.com/users/ericketts/orgs","repos_url":"https://api.github.com/users/ericketts/repos","events_url":"https://api.github.com/users/ericketts/events{/privacy}","received_events_url":"https://api.github.com/users/ericketts/received_events","type":"User","site_admin":false},"created_at":"2018-06-06T17:20:21Z","updated_at":"2018-06-06T17:20:21Z","author_association":"NONE","body":"Quick follow up to my (painfully long) previous comment, if I hack apart the restart functionality and use `getCurrentActivity()` to manually call `destroyLayouts()` on the presented `NavigationActivity` _before_ the call to `ReactInstanceManager.recreateReactContextInBackground()`, I do not see the redbox nor error in logcat, which seems to confirm my suspicions in the previous post.\r\n\r\nNow how to do this without the hack is the billion dollar movie..."}}
{"actor":{"display_login":"ericketts"}}