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: Discard persisted state on Android Activity restart #946

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Sep 21, 2023

PlayStore console reported some crashes related to react-native-screens that are related to Activity's onCreate method

This bug is well documented in the react-native-screens repository and the recommended action is to discard the Activity's persisted state when restarted

This is because the JS state (redux stores, in-component state etc) is not persisted the same way as the Android activity state, so there can be some inconsistencies between them when the app is restarted

Discarding the state implies that if Android kills the Activity when app is on background, then on when going back to the app it will behave like if it was a fresh start

Another impact is for foldable phones in which the app will restart when splitted into multi-window. But as the app does not support this mode, then this would not be an issue (at least for now)

Related documentation:
https://github.com/software-mansion/react-native-screens#android

Related issue:
software-mansion/react-native-screens#17

@Ldoppea
Copy link
Member Author

Ldoppea commented Sep 21, 2023

Note: this may explain the behaviour we observed when changing App's icon. Cf this PR #931

PlayStore console reported some crashes related to react-native-screens
that are related to Activity's `onCreate` method

This bug is well documented in the react-native-screens repository and
the recommended action is to discard the Activity's persisted state
when restarted

This is because the JS state (redux stores, in-component state etc) is
not persisted the same way as the Android activity state, so there can
be some inconsistencies between them when the app is restarted

Discarding the state implies that if Android kills the Activity when
app is on background, then on when going back to the app it will behave
like if it was a fresh start

Another impact is for foldable phones in which the app will restart
when splitted into multi-window. But as the app does not support this
mode, then this would not be an issue (at least for now)

Related documentation:
https://github.com/software-mansion/react-native-screens#android

Related issue:
software-mansion/react-native-screens#17
@Ldoppea Ldoppea changed the title Fix: Discard persisted state on Android Activity restart fix: Discard persisted state on Android Activity restart Sep 21, 2023
Copy link
Contributor

@Crash-- Crash-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@Ldoppea Ldoppea merged commit b6fef17 into master Sep 21, 2023
1 check passed
@Ldoppea Ldoppea deleted the fix/rnscreen_crash branch September 21, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants