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

8298728: Cells in VirtualFlow jump after resizing #974

Closed
wants to merge 3 commits into from

Conversation

johanvos
Copy link
Collaborator

@johanvos johanvos commented Dec 14, 2022

When recalculating sizes, we often don't want the current index and/or offset to change.

Allow to fix the index/offset when doing recalculations.

Fix JDK-8298728


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8298728: Cells in VirtualFlow jump after resizing

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/974/head:pull/974
$ git checkout pull/974

Update a local copy of the PR:
$ git checkout pull/974
$ git pull https://git.openjdk.org/jfx pull/974/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 974

View PR using the GUI difftool:
$ git pr show -t 974

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/974.diff

…r offset to change.

Allow to fix the index/offset when doing recalculations.

Fix JDK-8298728
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 14, 2022

👋 Welcome back jvos! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Dec 14, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 14, 2022

Webrevs

@andy-goryachev-oracle
Copy link
Contributor

I am trying to understand what the behavioral difference is between this branch and the current master. The ticket JDK-8298728 does not seem to specify the exact scenario, so I tried the following code with the large model (3000 lines) with a wrapping Text as graphic node. Resizing both vertically and horizontally produces what I this is identical result where the top visible selected cell scrolls out of the view in both cases.

cell factory:

                       TableColumn<String,String> c = new TableColumn<>();
                        table.getColumns().add(c);
                        c.setText("C" + table.getColumns().size());
                        c.setCellValueFactory((f) -> new SimpleStringProperty(describe(c)));
                        c.setCellFactory((r) -> {
                            return new TableCell<>() {
                                @Override
                                protected void updateItem(String item, boolean empty) {
                                    super.updateItem(item, empty);
                                    Text t = new Text("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n2\n3\n");
                                    t.wrappingWidthProperty().bind(widthProperty());
                                    setPrefHeight(USE_COMPUTED_SIZE);
                                    setGraphic(t);
                                }
                            };
                        });

I can attache the whole program to the jira ticket.

int oldIndex = computeCurrentIndex();
double cellLength = getOrCreateCellSize(index);
if (index > 0) getOrCreateCellSize(index - 1);
if (index < getCellCount() -1) getOrCreateCellSize(index + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to keep one statement per line - for stepping through in a debugger, and also if an exception gets thrown it will be easier to see where.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True -- I'll change that.

@johanvos
Copy link
Collaborator Author

I am trying to understand what the behavioral difference is between this branch and the current master.

I added a new test in VirtualFlowTest. It fails without the patch, and succeeds with the patch. The change is that if a cell is shown with some given content, then a cell is resized, and then a scroll operation is performed, the result of this scroll could be unexpected. I added comments in the added test so that the flow should be clear. Does this help?

@andy-goryachev-oracle
Copy link
Contributor

I think this might be the case when unit tests are insufficient.
With this change, I notice something else: select a cell somewhere in the middle of the table, click on the scroll bar to page up, then click on the other side of the scroll bar to page down. The existing code works correctly, the new code does not - the position is different, sometimes the selected cell is scrolled outside of the view.
see "does not page back to the same spot.mp4" in jira

@kevinrushforth
Copy link
Member

/reviewers 2

@openjdk
Copy link

openjdk bot commented Dec 14, 2022

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@johanvos
Copy link
Collaborator Author

That sounds exactly like something that should be a unit test.

Add another failing test, and a fix: when the cell that is positioned at the "current index"
is resized, we also need to modify the offset (wich is calculated from the top of that cell
to the start of the viewport).
@andy-goryachev-oracle
Copy link
Contributor

  1. I see the same issue with page up/page down described earlier (see the video clip attached to the jira ticket https://bugs.openjdk.org/secure/attachment/102048/does%20not%20page%20back%20to%20the%20same%20spot.mov )

  2. I am still not clear what exactly the problem is. The jira ticket contains conditionals ("if we want..."), rather than a typical steps to reproduce -> expected to see -> actual behavior steps.

Could you comment on #1 and #2 please?

@FlorianKirmaier
Copy link
Member

I can confirm that this fixes every remaining issue related to ListView to my knowledge.

My test application (which was an extended version of the test in this ticket: https://bugs.openjdk.org/browse/JDK-8277785) works now 100% correctly.

The application at Zeiss works now without any ListView-related workaround.

So, on my side - with this fix, all ListView issues known to me are fixed.

@johanvos
Copy link
Collaborator Author

  1. I see the same issue with page up/page down described earlier (see the video clip attached to the jira ticket https://bugs.openjdk.org/secure/attachment/102048/does%20not%20page%20back%20to%20the%20same%20spot.mov )
  2. I am still not clear what exactly the problem is. The jira ticket contains conditionals ("if we want..."), rather than a typical steps to reproduce -> expected to see -> actual behavior steps.

Could you comment on #1 and #2 please?

#1: I had a look at that video and I don't think this is a bug. Nowhere in the spec or javadoc it is mentioned that a page-up followed by a page-down should give the same position. This would imho actually be a bad requirement, as in case sizes are changing (which happens to be the case in most real-world scenario's I've seen so far) this would conflict with other requirements. One might argue that "in case the size of individual cells didn't change", the scroll-up/scroll-down should result in a same "offset" as before the operation but that is not a requirement so far. Could be discussed in another issue.

#2. I don't see what is missing. It seems to me both the ticket and the new test in the PR show the scenario of what goes wrong before the patch, and what is expected (in the assert). I can copy it here again, but I'm not understanding your question I think.

@andy-goryachev-oracle
Copy link
Contributor

Thank you for commenting, Johan.

Interesting. Why would sizes change in #1 scenario, since there are no changes in the component width and the scroll bar state? But I might disagree - it's the most natural case when pgup/pgdn results in the same state, as any text editor would demonstrate. In fact, I have a similar problem with "If we want the position of the thumb constant," - I'd rather see the thumb reflecting reality as much as it could, so it is ok for it to jump, as long as the selected cell remains in the same position on screen. It looks like the ticket talks about the "first cell" instead which would be an acceptable replacement.

As for #2 - it might be just me, I cannot translate these words into a scenario. Are you saying that, for example, resizing and immediately issuing pgup/pgdn (via click on a scrollbar) would shift the viewport too far/not enough? Or is there another scenario? What are the exact steps that result in erroneous behavior, in human words?

Copy link
Collaborator

@aghaisas aghaisas left a comment

Choose a reason for hiding this comment

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

Overall fix looks good to me.

I have identified two very minor typos.

assertEquals(300, thirdCell.getLayoutY(), 1.);


for (int i =0 ; i < heights.length; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor : Need a space after =

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

if (index > 0) {
getOrCreateCellSize(index - 1);
}
if (index < getCellCount() -1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor : Need a space after -

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

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

lgtm

@openjdk
Copy link

openjdk bot commented Jan 5, 2023

@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:

8298728: Cells in VirtualFlow jump after resizing

Reviewed-by: aghaisas, angorya

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 16 new commits pushed to the master branch:

  • e866a6c: 8296413: Tree/TableView with null focus model throws NPE in queryAccessibleAttribute()
  • 0dbc448: 8231864: JavaFX Labels in Tab's VBox is not displayed until it is clicked
  • 94fb7ed: 8216507: StyleablePropertyFactory: example in class javadoc does not compile
  • 012fa16: 8209017: CheckBoxTreeCell: graphic on TreeItem not always showing
  • a35c3bf: 8292922: [Linux] No more drag events when new Stage is created in drag handler
  • 48f6f5b: 8299272: Update copyright header for files modified in 2022
  • 5b96d34: 8296654: [macos] Crash when launching JavaFX app with JDK that targets SDK 13
  • 1d9e2af: 8297068: Update boot JDK to 19.0.1
  • ac3f60c: 8297554: Remove Scene.KeyHandler
  • 9c52605: 8252863: Spinner keeps spinning if removed from Scene
  • ... and 6 more: https://git.openjdk.org/jfx/compare/8763e8b0d67db33fc3aa40c459058957e3230346...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Jan 5, 2023
@johanvos
Copy link
Collaborator Author

johanvos commented Jan 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jan 5, 2023

Going to push as commit ca29cc6.
Since your change was applied there have been 16 commits pushed to the master branch:

  • e866a6c: 8296413: Tree/TableView with null focus model throws NPE in queryAccessibleAttribute()
  • 0dbc448: 8231864: JavaFX Labels in Tab's VBox is not displayed until it is clicked
  • 94fb7ed: 8216507: StyleablePropertyFactory: example in class javadoc does not compile
  • 012fa16: 8209017: CheckBoxTreeCell: graphic on TreeItem not always showing
  • a35c3bf: 8292922: [Linux] No more drag events when new Stage is created in drag handler
  • 48f6f5b: 8299272: Update copyright header for files modified in 2022
  • 5b96d34: 8296654: [macos] Crash when launching JavaFX app with JDK that targets SDK 13
  • 1d9e2af: 8297068: Update boot JDK to 19.0.1
  • ac3f60c: 8297554: Remove Scene.KeyHandler
  • 9c52605: 8252863: Spinner keeps spinning if removed from Scene
  • ... and 6 more: https://git.openjdk.org/jfx/compare/8763e8b0d67db33fc3aa40c459058957e3230346...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 5, 2023
@openjdk openjdk bot closed this Jan 5, 2023
@openjdk openjdk bot removed the ready Ready to be integrated label Jan 5, 2023
@openjdk openjdk bot removed the rfr Ready for review label Jan 5, 2023
@openjdk
Copy link

openjdk bot commented Jan 5, 2023

@johanvos Pushed as commit ca29cc6.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants