Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: android rn screen crash #5062

Merged
merged 4 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions HACKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 5 additions & 1 deletion android/app/src/main/java/net/artsy/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down