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: account for ListHeaderComponent length when calculating offset… #17415

Closed
wants to merge 2 commits into from

Conversation

shakyShane
Copy link
Contributor

… in VirtualizedList - fixes #16612

Issue is detailed in #16612

Motivation

I need onViewableItemsChanged to account for the length of any ListHeaderComponents

Test Plan

I couldn't find any tests that currently cover the use-case of a VirtualizedList + ListComponent + scroll with onViewableItemsChanged, so I have not added any tests - all previous tests pass however.

Release Notes

[GENERAL][BUGFIX][VirtualizedList] - account for ListHeaderComponent length

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 2, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot
Copy link
Contributor

@shakyShane I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@react-native-bot react-native-bot added Bug Fix 🐛 Ran Commands One of our bots successfully processed a command. labels Mar 16, 2018
@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jun 28, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

hramos pushed a commit that referenced this pull request Jul 4, 2018
#17415)

Summary:
… in VirtualizedList - fixes #16612

Issue is detailed in #16612

<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

I need `onViewableItemsChanged` to account for the length of any ListHeaderComponents

I couldn't find any tests that currently cover the use-case of a VirtualizedList + ListComponent + scroll with onViewableItemsChanged, so I have not added any tests - all previous tests pass however.

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[GENERAL][BUGFIX][VirtualizedList] - account for `ListHeaderComponent` length
Closes #17415

Differential Revision: D8683555

Pulled By: hramos

fbshipit-source-id: 05df7b79c16e3c07c12468e782f3c4b0bdce7403
@bestander
Copy link
Contributor

FYI, this PR may have caused a rare issue where a FlatList keeps scrolling down without stop.
We'll need to revert to see if this is the reason.
If it is not we'll roll it back.

@shakyShane
Copy link
Contributor Author

@bestander Thanks for the update. This is a crucial aspect of creating super-high perf on lists, so I appreciate it now getting some focus :)

@bestander
Copy link
Contributor

Hey all.

This is the revert commit 604bcfa.

So what happened.
We have a fairly popular app that uses FlatList to display an infinite list of elements.
Each element can be a complicated thing and it can have logic that logs position in the FlatList, does click handling with animations etc.
So what we learned is that after this change after some initial scrolling the FlatList could get into a state where it would start scrolling down indefinitely without a stop.
This happened only on iOS and was hard to reproduce, we noticed it only after users started reporting it.

We'll be doing a follow up on this issue internally: what was actually causing the infinite scroll and also how to prevent such break in the future. We'll also raise a question of the original issue that this PR tried to fix.

@shakyShane, do you have some insight what might have caused the infinite scroll?

@AndrewJack
Copy link
Contributor

AndrewJack commented Jul 31, 2018

We experienced the same infinite scrolling issue when using this patch. Reverting this back or not using a header component fixes the issue.

I think the issue occurs when flinging. The _onScrollEndDrag method.

@shakyShane
Copy link
Contributor Author

It's so sad that this caused such regressions elsewhere as it's an absolutely essential feature :(

if you have complicated lists, windowing is the solution to perf, and when the calculations for onViewableItemsChanged is off as detailed in this issue, you have no chance of getting this right

@shakyShane
Copy link
Contributor Author

I've just tried the latest React Native (0.58.1) and this is still an issue. :(

@Akash-T2S
Copy link

Akash-T2S commented Dec 4, 2020

Hey @shakyShane I'm facing a issue same as you have mentioned - (#16612). Is there any solution for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved. Ran Commands One of our bots successfully processed a command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The calculations for onViewableItemsChanged are incorrect if Flatlist has ListHeaderComponent
7 participants