diff --git a/CHANGELOG.yml b/CHANGELOG.yml index 6026ca34327..4400ccf027c 100644 --- a/CHANGELOG.yml +++ b/CHANGELOG.yml @@ -17,6 +17,7 @@ upcoming: - Implement share button for articles - katsiaryna alshannikava, mounir - Connect auction results for you to metaphysics endpoint - yauheni - Fix opening artist page after passing new onboarding on ios - dzmitry + - Fix crash when opening app from background on android - brian - Change error handling middleware & include optionalField graphql directive to home screen - ole releases: diff --git a/HACKS.md b/HACKS.md index 88d37f749de..8a5538cfd91 100644 --- a/HACKS.md +++ b/HACKS.md @@ -221,3 +221,16 @@ Once we work on [CX-1421](https://artsyproduct.atlassian.net/browse/CX-1421?atlO Basically these patches remove the podspecs of these two deps. They confuse and break ios, and we don't use them there yet anyway. Once we start working on replacing the native analytics with TS ones, then we remove these two patches too. + +# `react-native-screens` fragment crash on open from background on Android + +#### When can we remove this: + +Once https://github.com/software-mansion/react-native-screens/issues/17 is solved or we use another library for screen management. + +#### Explanation/Context: + +There is a known issue in react-native-screens that causes the app to crash on restoring from background. The react-native-screens team recommends the following workaround to be +added to the MainActivity class on Android https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067. + +This has the UX downside of not allowing state restore from background but this is an unsolved problem for RN apps. diff --git a/android/app/src/main/java/net/artsy/app/MainActivity.java b/android/app/src/main/java/net/artsy/app/MainActivity.java index 2a1672ed2f2..36a26e60b3d 100644 --- a/android/app/src/main/java/net/artsy/app/MainActivity.java +++ b/android/app/src/main/java/net/artsy/app/MainActivity.java @@ -45,7 +45,11 @@ private boolean isTablet() { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + // Following line is required to prevent a crash + // See HACKS.md for more context + // https://github.com/software-mansion/react-native-screens/issues/17 + super.onCreate(null); + if (!isTablet()) { // prevent screen rotation on phones setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);