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): index out of bounds crash #805

Merged

Conversation

pavangoyal42
Copy link
Contributor

Summary

We are using "react-native-tab-view" in Dream11 App. We were not able to reproduce the crash, But we are seeing crash instance in firebase. We can see that partial fix of this is already merged in react-native-tab-view. This fix works only if removeChildAt of ViewPagerAdapter gets called from removeChild of ViewPagerAdapter. The existing fix won't work here. This PR takes care of boundary conditions of childrenViews array.
Here are the attached logs/stack traces.

Fatal Exception: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
       at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
       at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
       at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
       at java.util.Objects.checkIndex(Objects.java:359)
       at java.util.ArrayList.remove(ArrayList.java:511)
       at o.requestAccessibilityFocus.Instrument(SourceFile:57)
       at o.requestAccessibilityFocus.values(SourceFile:47)
       at com.reactnativepagerview.PagerViewViewManager.removeView(SourceFile:110)
       at com.reactnativepagerview.PagerViewViewManager.removeView(SourceFile:21)
       at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.lambda$manageChildren$0(SourceFile:375)
       at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager$$ExternalSyntheticLambda0.run(:8)

Fatal Exception: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 3
       at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
       at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
       at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
       at java.util.Objects.checkIndex(Objects.java:359)
       at java.util.ArrayList.remove(ArrayList.java:511)
       at o.requestAccessibilityFocus.Instrument(SourceFile:57)
       at o.requestAccessibilityFocus.values(SourceFile:47)
       at com.reactnativepagerview.PagerViewViewManager.removeView(SourceFile:110)
       at com.reactnativepagerview.PagerViewViewManager.removeView(SourceFile:21)
       at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.lambda$manageChildren$0(SourceFile:375)
       at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager$$ExternalSyntheticLambda0.run(:8)
       at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(SourceFile:414)
       at com.facebook.react.uimanager.NativeViewHierarchyManager$1.onAnimationEnd(SourceFile:491)

Compatibility

OS Implemented
iOS
Android

Checklist

  • [ ✅ ] I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

@pavangoyal42
Copy link
Contributor Author

pavangoyal42 commented Feb 3, 2024

@troZee @krozniata @okwasniewski could you please check this PR ? Currently at Dream11 code we are using this as patch to fix mentioned crashes in summary.

@pavangoyal42
Copy link
Contributor Author

@krozniata Thanks for taking time to review this PR. can you please let me know, who can help in merging this to master ?

@troZee troZee merged commit 83979f9 into callstack:master Feb 6, 2024
3 checks passed
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.

3 participants