-
Notifications
You must be signed in to change notification settings - Fork 461
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
8089589: [ListView] ScrollBar content moves toward-backward during scrolling. #398
Conversation
👋 Welcome back jvos! A progress list of the required criteria for merging this PR into |
* release accumCell and empty parent when invalidating CellFactory
Webrevs
|
/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.
I reviewed the code, and tested this, both using automated tests and various manual tests, and it looks good to me. In addition to the simple test attached to the bug report, I can reproduce the bug with HelloTableView
and the HorizontalListView
sample of Ensemble8
.
HelloTableView
- Run
HelloTableview
program - Sort by first name
- Slowly scroll down by dragging the thumb
BUG: the scrolling jitters slightly when you reach the taller row (Jacob Smith Smith Smith)
Ensemble8
- Run
Ensemble8
and selectHorizontalListView
sample - Scroll all the way to the right
- Slowly scroll to the left by dragging the thumb
BUG: the scrolling jitters slightly when you reach the wider row (Long Row 3)
All three test cases run fine with the fix.
I left a few inline questions and comments (mostly about code style w.r.t., inline whitespace, and a couple typos).
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
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
Show resolved
Hide resolved
return (int) (getPosition() * getCellCount()); | ||
double total = 0; | ||
int currentCellCount = getCellCount(); | ||
double estSize = estimatedSize/currentCellCount; |
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.
MInor: missing spaces before and after /
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.
changed
} | ||
// Make sure we have enough space in the cache to store this index | ||
while (idx >= itemSizeCache.size()) { | ||
itemSizeCache.add(itemSizeCache.size(), 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.
Can this be simplified to itemSizeCache.add(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.
That won't add enough elements. For example, in case idx = 10, and the itemSizeCache has 5 elements, we need to add 5 empty elements to the cache, as they might get queried/pushed, e.g. we might do
itemSizeCache.set(7, 123.45);
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.
Sure, that's why you need the while
loop. What I meant is that the following two calls are equivalent for any list:
list.add(list.size(), null);
and
list.add(null);
Thanks for the review. I answered the questions, and corrected the styling errors. |
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.
Thanks for the explanations about the algorithm. I have no more questions on the logic.
I think Ajit will review this later this week.
Btw, I did another pass over the code and noted a few more formatting inconsistencies (missing spaces).
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/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
if (viewportLength >= estimatedSize) { | ||
setPosition(0.); | ||
} else { | ||
setPosition(absoluteOffset/(estimatedSize - viewportLength)); |
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.
Minor: spacing
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
Outdated
Show resolved
Hide resolved
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.
Code changes are OK. I have noted a few minor comments.
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
Outdated
Show resolved
Hide resolved
@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 44 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 |
/integrate |
@johanvos Since your change was applied there have been 44 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 8e54757. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
// When the position is changed explicitly, we need to make sure | ||
// the absolute offset is changed accordingly. | ||
adjustAbsoluteOffset(); | ||
} |
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 seems to violate the invariant setPosition(...)
≙ positionProperty().set(...)
.
Your comment indicates that this is by design, but how do you prevent people from invoking positionProperty().set(...)
and getting a different behavior?
This PR introduces a refactory for VirtualFlow, fixing a number of issues reported about inconsistent scrolling speed (see https://bugs.openjdk.java.net/browse/JDK-8089589)
The problem mentioned in the JBS issue (and in related issues) is that the VirtualFlow implementation depends on cell index and cell count, instead of on pixel count. The latter is unknown when the VirtualFlow is created, and pre-calculating the size of a large set of items would be very expensive.
Therefore, this PR uses a combination of a gradual calculation of the total size in pixels (estimatedSize) and a smoothing part that prevents the scrollback to scroll in the reverse direction as the requested change.
This PR currently breaks a number of tests that hard-coded depend on a number of evaluations. This is inherit to the approach of this PR: if we want to estimate the total size, we need to do some additional calculations. In this PR, I try to balance between consistent behavior and performance.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/398/head:pull/398
$ git checkout pull/398
Update a local copy of the PR:
$ git checkout pull/398
$ git pull https://git.openjdk.java.net/jfx pull/398/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 398
View PR using the GUI difftool:
$ git pr show -t 398
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/398.diff