react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[ListView] Rendering new rows while scrolling can cause the underlying ScrollView to scroll back up

Open brentvatne opened this issue 11 years ago • 25 comments

See: https://www.youtube.com/watch?v=_8Wkf6SmuLQ for a demo And: https://github.com/brentvatne/ListViewRenderScrollingError for an example.

It's sometimes hard to reproduce - scroll up a bit and then back down to the bottom, and if the timing is right then when you hit the bottom of the scroll view it will smooth scroll back up.

brentvatne avatar Sep 25 '15 19:09 brentvatne

cc @mkonicek @kmagiera

brentvatne avatar Sep 25 '15 19:09 brentvatne

It also happens when I scroll very fast and it hasn't finished rendering the rows yet.

satya164 avatar Sep 26 '15 17:09 satya164

That's a known problem. JS listview dynamically adds rows while fling animation is going on. Apparently there is a bug in android scrollview fling animation which doesn't take into account that the height of the scrollview may change while in the meantime. Because it's using hidden API on android there is no good way to workaround this problem. We're working on an alternative implementation that would use native list view instead and should address this problem

kmagiera avatar Sep 26 '15 20:09 kmagiera

Great, thanks for the update @kmagiera!

brentvatne avatar Sep 26 '15 23:09 brentvatne

@kmagiera can this issue also manifest in IOS ?

Sherlock92 avatar Oct 25 '15 20:10 Sherlock92

@Sherlock92 - nope

brentvatne avatar Oct 25 '15 22:10 brentvatne

@kmagiera Since RecyclerViewBackedScrollView fixes this should we use it everywhere by default on Android (whenever you use <ScrollView>) and close this?

mkonicek avatar Oct 26 '15 23:10 mkonicek

We're still experimenting with performance there. This should be done this week. Then we can switch <ListView> over to it on android

kmagiera avatar Oct 27 '15 20:10 kmagiera

:+1:

mkonicek avatar Oct 28 '15 00:10 mkonicek

@brentvatne @kmagiera any updates on this

ghost avatar Dec 31 '15 18:12 ghost

@tUrG0n - there is a patched ScrollView for Android that fixes this, working on open sourcing it. cc @vjeux

brentvatne avatar Jan 01 '16 02:01 brentvatne

@tUrG0n RecyclerViewBackedScrollView landed a while ago and it's ready to be used. You can use <RecyclerViewBackedScrollView> the same way as you use <ScrollView>. If you're using ListView component you can pass renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />} as a prop to the ListView component in order for it to use recycler view as a backend

kmagiera avatar Jan 04 '16 17:01 kmagiera

RecyclerViewBackedScrollView doesn't fix this issue but it does help a lot with scrolling perf. I'll try to open source the BugFixScrollView soon!

brentvatne avatar Jan 22 '16 21:01 brentvatne

Looks like RecyclerViewBackedScrollView fixes the same issue for me (at least on Android)

AlexeyToksarov avatar Feb 18 '16 09:02 AlexeyToksarov

@brentvatne Any update on the BugFixScrollView?

ramilushev avatar Apr 21 '16 07:04 ramilushev

also interested on the fix - my app has several long ListViews in it and i can't smoothly fling through them unless i initialize the list to be the whole thing right off the bat Slightly unrelated, but RecyclerViewBackedScrollView doesn't seem to be working for me as well; it gives an "IndexOutOfBoundsException: Inconsistency detected. Invalid item position" error

saoasuna avatar Apr 23 '16 04:04 saoasuna

+1

ghost avatar Jun 07 '16 09:06 ghost

Seems like I get similar errors on Android (RN 0.28), stack trace:

Fatal Exception: java.lang.IndexOutOfBoundsException: Invalid index 55, size is 41
       at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
       at java.util.ArrayList.get(ArrayList.java:308)
       at com.facebook.react.views.recyclerview.RecyclerViewBackedScrollView$ScrollOffsetTracker.getTopOffsetForItem(RecyclerViewBackedScrollView.java:169)
       at com.facebook.react.views.recyclerview.RecyclerViewBackedScrollView$ReactListAdapter.getTopOffsetForItem(RecyclerViewBackedScrollView.java:310)
       at com.facebook.react.views.recyclerview.RecyclerViewBackedScrollView.calculateAbsoluteOffset(RecyclerViewBackedScrollView.java:325)
       at com.facebook.react.views.recyclerview.RecyclerViewBackedScrollView.onScrollChanged(RecyclerViewBackedScrollView.java:344)

not sure if it's a bug or if I'm doing something wrong?

knowbody avatar Jul 16 '16 08:07 knowbody

Closing due to https://github.com/facebook/react-native/commit/36ca1a078acbaba770c196847254e7a6e80c6918

ide avatar Aug 01 '16 19:08 ide

Is the IndexOutOfBoundsException issue resolved as well ? I still experiencing it with RN 0.35 in Android.

tlcheah2 avatar Nov 01 '16 13:11 tlcheah2