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

8290348: TreeTableView jumping to top #836

Closed
wants to merge 4 commits into from

Conversation

johanvos
Copy link
Collaborator

@johanvos johanvos commented Jul 17, 2022

Do not recalculate total estimated size recursively.

In the (unlikely) event that the recalculation triggers a new recalculation (e.g. when the height of a Cell is changed), do not start this recalculation.
The cache and cache size may become inconsistent if a recursive calculation is started.
This fixes JDK-8290348


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

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 836

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

Using diff file

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

In the (unlikely) event that the recalculation triggers a new recalculation
(e.g. when the height of a Cell is changed), do not start this recalculation.
The cache and cache size may become inconsistent if a recursive calculation is
started.
This fixes JDK-8290348
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 17, 2022

👋 Welcome back jvos! A progress list of the required criteria for merging this PR into jfx19 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 Jul 17, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 17, 2022

Webrevs

@kevinrushforth
Copy link
Member

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jul 18, 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).

@aghaisas
Copy link
Collaborator

aghaisas commented Jul 18, 2022

I tested on macOS. It is observed that the newly added test passes even without the VirtualFlow.java code change done in this PR.

@johanvos
Copy link
Collaborator Author

I'll make the test more deterministic.
FWIW, the following UI code allows to reproduce the failure (and fix) easier, but it is UI-based and has a Thread.sleep() so I won't add this in a unit test.
(the generateChildren method is the same as in the unit test)


        TreeItem<String> root = new TreeItem<>("Root Node");
        root.setExpanded(true);
        root.getChildren().addAll(generateChildren(1));

        TreeView<String> treeView = new TreeView<>(root);

        treeView.scrollTo(100);
        Thread t = new Thread() {
            @Override public void run() {
                try {
                    Thread.sleep(3000);
                    Platform.runLater(() -> {
                        root.getChildren().get(1).setExpanded(false);
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        t.start();
        Scene scene = new Scene(treeView, 640, 480);
        stage.setScene(scene);
        stage.show();

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.

Looks good to me!

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

Looks good. I confirm that both the visual test and updated unit test fail without the fix and pass with the fix. I left one question inline, but I doubt it is a problem.

@@ -3107,7 +3110,7 @@ private void recalculateAndImproveEstimatedSize(int improve) {
this.absoluteOffset = newOffset + oldOffset;
adjustPosition();
}

recalculating = false;
Copy link
Member

Choose a reason for hiding this comment

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

Is it likely that this method might get an exception? I was wondering whether the assignment to false should be in a try / finally. If there is no probable way an exception could occur, or if an exception is non-recoverable (which is quite possible), then no need for a try / finally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question. There should be no non-recoverable exceptions in the VirtualFlow specific code. However, since IndexedCell.updateItem() and others might get called from this method, exceptions there might propagate.
My initial thought was to fail-fast, but it is probably better to use a try/finally so that at least this method is still "working" somehow. I'll add that.

@openjdk
Copy link

openjdk bot commented Jul 20, 2022

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

8290348: TreeTableView jumping to top

Reviewed-by: aghaisas, kcr

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

Please see this link for an up-to-date comparison between the source branch of this pull request and the jfx19 branch.
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 jfx19 branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Jul 20, 2022
@openjdk openjdk bot removed the ready Ready to be integrated label Jul 21, 2022
@openjdk openjdk bot added the ready Ready to be integrated label Jul 21, 2022
@johanvos
Copy link
Collaborator Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 21, 2022

Going to push as commit 6da05c2.
Since your change was applied there have been 7 commits pushed to the jfx19 branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 21, 2022
@openjdk openjdk bot closed this Jul 21, 2022
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels Jul 21, 2022
@openjdk
Copy link

openjdk bot commented Jul 21, 2022

@johanvos Pushed as commit 6da05c2.

💡 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
3 participants