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: make sure we only call onDetachedFromWindow once #985

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

WoLewicki
Copy link
Member

@WoLewicki WoLewicki commented Jun 16, 2021

Description

Suggested by @kmagiera change to ScreenContainer.java, altering #477, switching removeAllViews(); to removeViewAt(i); in order to fix the case of calling onDetachedFromWindow multiple times in the child Screens, which can be seen in Test913.tsx. This behaviors occurs due to the logic of removeAllViews method, which does not check if the child views are not already detached when the method is called, whereas the check is present in removeViewAt method (see https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#5559 which is not present in https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#5771).

Test code and steps to reproduce

Test913.tsx in TestsExample project.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@kacperkapusciak kacperkapusciak merged commit b531797 into master Jun 17, 2021
@kacperkapusciak kacperkapusciak deleted the @wolewicki/fix-double-detach branch June 17, 2021 10:59
Strate added a commit to chatium/react-native-screens that referenced this pull request Nov 2, 2021
Meninblack007 pushed a commit to myntra/react-native-screens that referenced this pull request Nov 2, 2022
…on#985)

Suggested by @kmagiera change to ScreenContainer.java, altering software-mansion#477, switching removeAllViews(); to removeViewAt(i); in order to fix the case of calling onDetachedFromWindow multiple times in the child Screens, which can be seen in Test913.tsx. This behaviour occurs due to the logic of removeAllViews method, which does not check if the child views are not already detached when the method is called, whereas the check is present in removeViewAt method (see https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#5559 which is not present in https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#5771).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants