I encountered an ANR error while using the library, and after some debugging, I managed to locate the source of the issue. The dispatchEvent calls in the goTo function appear to conflict with the dispatchEvent in the onPageSelected event of OnPageChangeCallback.
The ANR error occurs when calling setPage or setPageWithoutAnimation multiple times. I'm not good at Android development, but when I commented out one of the two dispatchEvent calls, the ANR error disappeared.
Same here. ANR happens after using setPage() and then scrolling FlatList. So, ANR doesn't happen instantly after using setPage(), but after scrolling when setPage() was used.
Environment
Description
I encountered an ANR error while using the library, and after some debugging, I managed to locate the source of the issue. The dispatchEvent calls in the goTo function appear to conflict with the dispatchEvent in the onPageSelected event of OnPageChangeCallback.
https://github.com/callstack/react-native-pager-view/blob/2946c1c33df6cacc8f9f77220bb879b39bb75ace/android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt#L167-L182
https://github.com/callstack/react-native-pager-view/blob/2946c1c33df6cacc8f9f77220bb879b39bb75ace/android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt#L54-L59
The ANR error occurs when calling
setPage
orsetPageWithoutAnimation
multiple times. I'm not good at Android development, but when I commented out one of the two dispatchEvent calls, the ANR error disappeared.Reproducible Demo
https://github.com/callstack/react-native-pager-view/assets/10294977/af5866b6-d265-443d-80e2-4e2f23067993