-
Notifications
You must be signed in to change notification settings - Fork 473
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
8277785: ListView scrollTo jumps to wrong location when CellHeight is changed #808
Conversation
… and currentIndex are all subject to change when the total estimated size of the entire list is changing. Improvements in the estimated size should not lead to sudden changes during the layout phase.
👋 Welcome back jvos! A progress list of the required criteria for merging this PR into |
Webrevs
|
The proposed PR also fixes the issue with |
/reviewers 2 |
@kevinrushforth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good to me, although I did leave a question about one of the boundary checks. This will need additional testing. Several of the assertEquals
calls have the expected and actual args backwards. I also left a few minor formatting comments (I didn't note all of them).
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewKeyInputTest.java
Outdated
Show resolved
Hide resolved
I did a reformat on the sections that you mentioned. Doing a reformat with NetBeans on the whole file would cause too many changes that would hide the real changes, so that is probably a bit too much? |
Perfect (and yes, I prefer to only reformat the sections being modified). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noted a couple more assertEquals
calls where it looks like the expected and actual are backwards. The rest looks good. I'll finish my testing tomorrow.
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewKeyInputTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java
Outdated
Show resolved
Hide resolved
Reverse expected and actual args in some tests.
I've retested this version of the PR, and I can confirm, that it fixes the bug in the real-world application! So no regression happened when moving to the new PR! So great work! Not sure whether the first two tests are still necessary. There are 2 issues, we shouldn't forget about after this PR: 1.) In my original tests I had a snippet which is removed in this version. I still think the test is correct but it fails. So we should investigate it.
2.) |
I think you missed one place where the I'll do final testing today, but so far everything looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@johanvos This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 18 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
if (needsRecreateCells) { | ||
lastWidth = -1; | ||
lastHeight = -1; | ||
releaseCell(accumCell); | ||
// accumCell = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional or did you may forgot to add back this two lines of code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional -- it was already moved to comments, and there is no need to destroy the accumCell (releasing it is what we need)
/integrate |
Going to push as commit b8302f6.
Your commit was automatically rebased without conflicts. |
This fix seems to break |
A new bug has been filed to track this: JDK-8290348. |
In order to fix the issues reported in JDK-8089589, the VirtualFlow now uses the real sizes of the elements that are displayed. This allows for a more natural way of scrolling through lists that contain items of very different sizes.
The algorithm that is used, does not calculate the size of each individual cell upfront, as that would be a major performance overhead (especially for large lists). Instead, we estimate the total size and the size of the individual cells based on the real measured size of a (growing) number of cells.
There are a number of key variables that depend on this estimated size:
As a consequence, when the estimated size is changing, the absoluteOffset may change which may lead to a new currentIndex. If this happens during a layout phase, or a "complex" operation (e.g. scroll to an item and select it), this may lead to visually unexpected artifacts. While the rendering becomes more "correct" when the estimated size is improving, it is more important that we do not create visual confusion.
The difficulty is that there are a large number of ways to manipulate the VirtualFlow, and different entry points may have different expectations about which variables should be kept constant (or only changed gradually).
In this PR, we focus on consistency in the scrollTo method, where we want to keep the top-cell constant. In case the estimated size is improved during the scrollTo execution, or the next layoutChildren invocation, this implies keeping the result of computeCurrentIndex() constant so that after scrolling to a cell and selecting it, the selected cell is indeed the one that is scrolled to.
This PR contains a number of tests for this scrollTo behaviour, that should also be considered as regression test in case we want to add more invariants later.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/808/head:pull/808
$ git checkout pull/808
Update a local copy of the PR:
$ git checkout pull/808
$ git pull https://git.openjdk.org/jfx pull/808/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 808
View PR using the GUI difftool:
$ git pr show -t 808
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/808.diff