Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Conversation

richardhuaaa
Copy link
Contributor

As identified in #582, with RN 36 and 37, CodePush will crash on Android when the app is restarted using the InstallMode.IMMEDIATE and InstallMode.ON_NEXT_RESUME modes. The regression seems to originate from this change, where React's LifeCycleEventListener will now trigger onAppResume() immediately if it is added while the app is in the foreground. As our code depends on this being triggered only in the act of the app being resumed from the background, loadBundle() will be called twice, causing issues.

The solution here is to modify our resume handler to only perform the action if the app is backgrounded AND THEN resumed. There is a limitation here - in the rare cases when the app is in the background when the listener is added, then it will need to be resumed twice to achieve the desired effect. It is unclear to me how to work around this - we could try to use the RESUMED and BEFORE_RESUME enum values provided by React Native, but then we'd lose compatibility with earlier RN versions. It's also strange that onHostPause() is not also triggered immediately when added if the app is in the background, but that would have also solved this problem.

@richardhuaaa richardhuaaa merged commit d9a85c8 into master Nov 15, 2016
richardhuaaa pushed a commit that referenced this pull request Nov 16, 2016
* Upgrade example app to react-native@0.37.0
* Fix crash on restart caused by loadBundle() being called twice
@sergey-akhalkov sergey-akhalkov deleted the upgrade-rn-37 branch January 9, 2018 08:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants