From 7e7a4ec468530e0f37cd4e57aea3ad6f4aa41fa3 Mon Sep 17 00:00:00 2001 From: brainbicycle Date: Tue, 29 Jun 2021 12:33:27 -0400 Subject: [PATCH 1/3] Don't restore state in main activity --- android/app/src/main/java/net/artsy/app/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..afb02708876 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,7 @@ private boolean isTablet() { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + super.onCreate(null); if (!isTablet()) { // prevent screen rotation on phones setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); From 46a9fe135510285d4fbfc01da2c3c2fd34235b9a Mon Sep 17 00:00:00 2001 From: brainbicycle Date: Tue, 29 Jun 2021 14:28:14 -0400 Subject: [PATCH 2/3] Add explanatory comment and HACKS.md entry --- HACKS.md | 13 +++++++++++++ .../src/main/java/net/artsy/app/MainActivity.java | 4 ++++ 2 files changed, 17 insertions(+) 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 afb02708876..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) { + // 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); From 077b6f286ab3f5d45c85f7380c2cd6eda5a93e3e Mon Sep 17 00:00:00 2001 From: brainbicycle Date: Tue, 29 Jun 2021 14:33:49 -0400 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.yml b/CHANGELOG.yml index 33f5a66559c..c1ef0fb8479 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 releases: - version: 6.9.5