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

8274137: TableView scrollbar/header misaligned when reloading data #629

Closed
wants to merge 5 commits into from

Conversation

@effad
Copy link
Collaborator

@effad effad commented Sep 23, 2021

This PR fixes JDK-8274137 by removing the optimization from updateHbar() that will no-op the method in case the VirtualFlow is invisible or currently has no scene.
Since changes to the hBar's value can happen even if the VirtualFlow is not currently visible, the synchronisation between hBar and clipX must happen all the time.

A test agains VirtualFlow has been added that will fail before the change and pass afterwards.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8274137: TableView scrollbar/header misaligned when reloading data

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/629/head:pull/629
$ git checkout pull/629

Update a local copy of the PR:
$ git checkout pull/629
$ git pull https://git.openjdk.java.net/jfx pull/629/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 629

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/629.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 23, 2021

👋 Welcome back rlichten! 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 label Sep 23, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Sep 23, 2021

Webrevs

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Sep 23, 2021

I am hesitant to take this fix "as is". At least not without more evaluation and testing.

First, this has the potential to hurt performance for applications that do a lot of setup on tables that aren't visible. There are several places where we defer updating and the usual way we address any such problems is to validate when "something" changes. In this case, the "something" should include becoming visible or the scene going to non-null (or alternatively being "treeVisible", which means visible and part of a scene that is showing).

Second, the code you propose to remove was added as part of the fix for JDK-8112072, and while I doubt it was added to ensure correctness, it will need to be tested.

Third, I prefer that tests not check a specific implementation detail such as ensuring that derived values are computed when the scene is null or the node is invisible. Rather, it is better to check that a change made while the node is not visible (or the scene is null), is valid after making it visible on an active scene.

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Sep 23, 2021

/reviewers 2

@openjdk
Copy link

@openjdk openjdk bot commented Sep 23, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@effad
Copy link
Collaborator Author

@effad effad commented Sep 24, 2021

First, this has the potential to hurt performance for applications that do a lot of setup on tables that aren't visible.

That would be possible if the hbar changes its visibility or its value. I can't really see how that would happen as long as the hbar isn't visible. Well I guess it is theoretically possible that someone subclasses VirtualFlow and adds thousands of items and changes the hbar value to some value after each item before making the VirtualFlow visible.

There are several places where we defer updating and the usual way we address any such problems is to validate when "something" changes. In this case, the "something" should include becoming visible or the scene going to non-null (or alternatively being "treeVisible", which means visible and part of a scene that is showing).

If this is the "convention" of how things should be done then I will adapt my PR to not remove the said line but instead make the listenerX fire also when the VIrtualFlow's visible or scene property changes.
This will also fix the problem an keep the performance optimization in place.

Second, the code you propose to remove was added as part of the fix for JDK-8112072, and while I doubt it was added to ensure correctness, it will need to be tested.

As posted in JDK-8274137: Tested it, found no problems.

Third, I prefer that tests not check a specific implementation detail such as ensuring that derived values are computed when the scene is null or the node is invisible. Rather, it is better to check that a change made while the node is not visible (or the scene is null), is valid after making it visible on an active scene.
I claim that testScrollBarClipSyncWhileInvisibleOrNoScene does just that.

  • It first checks that hBar and clipping stay in sync when the flow is visible and has a scene. (sunshine case)
  • Then it changes the hBar while the flow is invisible, makes the flow visible again and checks if (after the flow is now visible again) hBar and clipping are in sync again.
  • Then it does the same by removing hBar from the scene.

Alternative fix using additional listeners instead of removing
optimization.
@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Sep 24, 2021

First, this has the potential to hurt performance for applications that do a lot of setup on tables that aren't visible.

That would be possible if the hbar changes its visibility or its value. I can't really see how that would happen as long as the hbar isn't visible. Well I guess it is theoretically possible that someone subclasses VirtualFlow and adds thousands of items and changes the hbar value to some value after each item before making the VirtualFlow visible.

There are several places where we defer updating and the usual way we address any such problems is to validate when "something" changes. In this case, the "something" should include becoming visible or the scene going to non-null (or alternatively being "treeVisible", which means visible and part of a scene that is showing).

If this is the "convention" of how things should be done then I will adapt my PR to not remove the said line but instead make the listenerX fire also when the VIrtualFlow's visible or scene property changes.
This will also fix the problem an keep the performance optimization in place.

Good. This seems a better fix. While the performance hit is likely theoretical, it becomes a non-issue with your update fix.

Second, the code you propose to remove was added as part of the fix for JDK-8112072, and while I doubt it was added to ensure correctness, it will need to be tested.

As posted in JDK-8274137: Tested it, found no problems.

Thanks.

Third, I prefer that tests not check a specific implementation detail such as ensuring that derived values are computed when the scene is null or the node is invisible. Rather, it is better to check that a change made while the node is not visible (or the scene is null), is valid after making it visible on an active scene.
I claim that testScrollBarClipSyncWhileInvisibleOrNoScene does just that.

  • It first checks that hBar and clipping stay in sync when the flow is visible and has a scene. (sunshine case)
  • Then it changes the hBar while the flow is invisible, makes the flow visible again and checks if (after the flow is now visible again) hBar and clipping are in sync again.
  • Then it does the same by removing hBar from the scene.

Clearly I didn't look closely enough at the test. I missed that you were already doing what I was asking for.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

The fix and test look good. I left one comment about some unrelated changes. I still need to test this, but will do so soon.

@kevinrushforth kevinrushforth self-requested a review Sep 29, 2021
@aghaisas
Copy link
Collaborator

@aghaisas aghaisas commented Oct 4, 2021

Fix is fine!

@effad
Copy link
Collaborator Author

@effad effad commented Oct 6, 2021

Ist there anything left for me to do? IIRC someone must now /sponsor this change and then I can /integrate it, right?

@aghaisas
Copy link
Collaborator

@aghaisas aghaisas commented Oct 8, 2021

Ist there anything left for me to do? IIRC someone must now /sponsor this change and then I can /integrate it, right?

This PR needs two review approvals; currently it has one.
We shall wait for @kevinrushforth to review and approve it. Once he does it, you can /integrate it and one of us will /sponsor it.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Looks good.

@openjdk
Copy link

@openjdk openjdk bot commented Oct 13, 2021

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

8274137: TableView scrollbar/header misaligned when reloading data

Reviewed-by: kcr, aghaisas

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

  • bb73d43: 8272870: Add convenience factory methods for border and background
  • 2c86e0f: 8274433: All Cells: misbehavior of startEdit
  • 64aa926: 8188026: TextFieldXXCell: NPE on calling startEdit
  • f3c72b9: 8214158: Implement HostServices.showDocument on macOS without calling AWT
  • 30f5606: 8231644: TreeTableView Regression: Indentation wrong using Label as column content type
  • 55faac4: 8271474: Tree-/TableCell: inconsistent edit event firing pattern
  • 478512b: 8274107: Cherry pick GTK WebKit 2.32.4 changes
  • 4b9cb21: 8273969: Memory Leak on the Runnable provided to Platform.startup
  • 338b999: 8273946: Move clearQuad method to BaseShaderGraphics superclass
  • 5c355fa: 8090158: Wrong implementation of adjustValue in scrollBars

Please see this link for an up-to-date comparison between the source branch of this pull request and the master 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kevinrushforth, @aghaisas) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Oct 13, 2021
@effad
Copy link
Collaborator Author

@effad effad commented Oct 13, 2021

/integrate

@openjdk openjdk bot added the sponsor label Oct 13, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 13, 2021

@effad
Your change (at version 2015678) is now ready to be sponsored by a Committer.

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Oct 13, 2021

/sponsor

@openjdk
Copy link

@openjdk openjdk bot commented Oct 13, 2021

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

  • bb73d43: 8272870: Add convenience factory methods for border and background
  • 2c86e0f: 8274433: All Cells: misbehavior of startEdit
  • 64aa926: 8188026: TextFieldXXCell: NPE on calling startEdit
  • f3c72b9: 8214158: Implement HostServices.showDocument on macOS without calling AWT
  • 30f5606: 8231644: TreeTableView Regression: Indentation wrong using Label as column content type
  • 55faac4: 8271474: Tree-/TableCell: inconsistent edit event firing pattern
  • 478512b: 8274107: Cherry pick GTK WebKit 2.32.4 changes
  • 4b9cb21: 8273969: Memory Leak on the Runnable provided to Platform.startup
  • 338b999: 8273946: Move clearQuad method to BaseShaderGraphics superclass
  • 5c355fa: 8090158: Wrong implementation of adjustValue in scrollBars

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 13, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Oct 13, 2021

@kevinrushforth @effad Pushed as commit b591912.

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