You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working on RTL support in react-native-screens, we noticed a bug with ScrollView disappearing after navigation action. When we checked the view hierarchy, it turned out that the ScrollView's content moves outside the window, to the left of the screen, by its width. If you repeat the same navigation action multiple times, the ScrollView's content is offset to the left by some multiple of its width.
The bug happens only in RTL (e.g. when forceRTL(true) is used)
When you disable recycling for RCTScrollViewComponentView, the bug does not happen.
After some debugging, we managed to find the exact change responsible for this bug: b37023c. When you remove this line, the bug does not happen.
It seems like UIKit changes layer position when zoomScale is changed:
This results in _containerView.frame being changed. When RCTScrollViewComponentView is used again, _containerView.frame is not updated in updateState:oldState: due to an early return:
[RCTScrollViewComponentView_debug] updateState _contentSize {0, 0} vs contentSize {402, 919}
[RCTScrollViewComponentView_debug] updateState updating _containerView.frame before: {{0, 0}, {0, 0}}
[RCTScrollViewComponentView_debug] _containerView.layer.position changed from {0, 0} to {201, 459.5}
[RCTScrollViewComponentView_debug] updateState updating _containerView.frame after: {{0, 0}, {402, 919}}
=== frame change happens here: ===
[RCTScrollViewComponentView_debug] prepareForRecycle reseting zoom scale, _containerView.frame {{0, 0}, {402, 919}}
[RCTScrollViewComponentView_debug] _containerView.layer.position changed from {201, 459.5} to {603, 1378.5}
[RCTScrollViewComponentView_debug] _containerView.layer.position changed from {603, 1378.5} to {603, 459.5}
[RCTScrollViewComponentView_debug] prepareForRecycle finished reseting zoom scale, _containerView.frame {{402, 0}, {402, 919}}
=== ScrollView is recycled but updateState does not update the frame: ===
[RCTScrollViewComponentView_debug] updateState _contentSize {402, 919} vs contentSize {402, 919}
[RCTScrollViewComponentView_debug] updateState early return, _containerView.frame {{402, 0}, {402, 919}}
Resetting _contentSize to CGSizeZero in prepareForRecycle: after changing _scrollView.zoomScale fixes the bug but I'm not sure if this is a valid fix.
Steps to reproduce
Launch reproducer app on iOS simulator via Xcode.
Click Push button to push a screen.
Verify that ScrollView is visible.
Click Pop button.
Click Push button once again.
ScrollView will not be visible. Check View Hierarchy in Xcode with Show Clipped Content enabled to verify that ScrollView's content is offset to the left of the window.
If you keep repeating pop-push operations and check View Hierarchy, ScrollView's content will be even further from the window.
Description
When working on RTL support in
react-native-screens, we noticed a bug withScrollViewdisappearing after navigation action. When we checked the view hierarchy, it turned out that theScrollView's content moves outside the window, to the left of the screen, by its width. If you repeat the same navigation action multiple times, theScrollView's content is offset to the left by some multiple of its width.forceRTL(true)is used)RCTScrollViewComponentView, the bug does not happen.zoomScaleis changed:This results in
_containerView.framebeing changed. WhenRCTScrollViewComponentViewis used again,_containerView.frameis not updated inupdateState:oldState:due to an early return:_contentSizetoCGSizeZeroinprepareForRecycle:after changing_scrollView.zoomScalefixes the bug but I'm not sure if this is a valid fix.Steps to reproduce
Pushbutton to push a screen.ScrollViewis visible.Popbutton.Pushbutton once again.ScrollViewwill not be visible. Check View Hierarchy in Xcode withShow Clipped Contentenabled to verify thatScrollView's content is offset to the left of the window.ScrollView's content will be even further from the window.React Native Version
0.84.0
Affected Platforms
Runtime - iOS
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
https://github.com/kligarski/rn-disappearing-scroll-view-rtl-reproducer
Screenshots and Videos
rtl_scroll_view_bug_1080p_trimmed.mov