jfx icon indicating copy to clipboard operation
jfx copied to clipboard

8218745: TableView: visual glitch at borders on horizontal scrolling

Open Maran23 opened this issue 1 year ago • 29 comments

This PR fixes the border glitch/gap as explained in both linked tickets.

I noted that the ScrollPane control does not suffer from this problem, although the code is mostly the same as in VirtualFlow. The ScrollPane snaps the content correctly, no matter which scale. I carefully checked the code and it seems that the container structure in ScrollPane was explicitly written to handle this perfectly. There was definitely some thought on that.

So to finally fix this issue, I rewrote the VirtualFlow container/scrolling code to be exactly the same as in ScrollPane(Skin). And this also fixes the issue, while behaving the same as before.

In the future it may makes sense to try to somewhat unify the code from ScrollPane and VirtualFlow. I already have some ideas.

Unfortunately though, one more container is introduced to VirtualFlow, so the css needs to be changed since it is very strictly written in the first place: Before: .list-view:focused > .virtual-flow > .clipped-container > .sheet > .list-cell After: .list-view:focused > .virtual-flow > .viewport > .clipped-container > .sheet > .list-cell

To better understand this, the container structure (tree) is shown below:

  • ScrollPane
    • viewRect -> setClip -> clipRect (viewContent size)
      • viewContent -> setLayoutX
        • Content
    • vsb
    • hsb
    • corner

  • VirtualFlow
    • viewRect (->NEW IN THIS PR<-) -> setClip -> clipRect (clippedContainer size)
      • clippedContainer/clipView -> setLayoutX (when scrolling)
        • sheet
          • Cell
    • vsb
    • hsb
    • corner

/issue add JDK-8146406


Progress

  • [x] Change must not contain extraneous whitespace
  • [ ] Change requires a CSR request matching fixVersion jfx24 to be approved (needs to be created)
  • [x] Commit message must refer to an issue
  • [ ] Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issues

  • JDK-8218745: TableView: visual glitch at borders on horizontal scrolling (Bug - P4)
  • JDK-8146406: Unexplainable gap between TableCell inside a TableView (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1330

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

Using diff file

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

Webrev

Link to Webrev Comment

Maran23 avatar Jan 10 '24 19:01 Maran23

:wave: Welcome back mhanl! 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.

bridgekeeper[bot] avatar Jan 10 '24 19:01 bridgekeeper[bot]

@Maran23 Adding additional issue to issue list: 8146406: Unexplainable gap between TableCell inside a TableView.

openjdk[bot] avatar Jan 10 '24 19:01 openjdk[bot]

Webrevs

mlbridge[bot] avatar Jan 10 '24 19:01 mlbridge[bot]

This will need careful review and testing.

/reviewers 2

kevinrushforth avatar Jan 10 '24 21:01 kevinrushforth

@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).

openjdk[bot] avatar Jan 10 '24 21:01 openjdk[bot]

@johanvos : I presume you will want to review this?

kevinrushforth avatar Jan 10 '24 21:01 kevinrushforth

The scrolling works correctly with the fix (tested TableView on macOS (scale=1 and 2) and win11 (scale=200%, 225%). I'll continue testing tomorrow.

It might be a dumb question: would it be possible to avoid creating an intermediate container and keep the existing .css files?

andy-goryachev-oracle avatar Jan 10 '24 23:01 andy-goryachev-oracle

It might be a dumb question: would it be possible to avoid creating an intermediate container and keep the existing .css files?

Not a dumb question, that is what I tried at first. See also my old PR: https://github.com/openjdk/jfx/pull/630. I tried multiple things with the container and snapping, but never managed to fix all the issues with all scales. So I didn't found a way to fix this issue other than having the same container structure as ScrollPane, which works very well and looks like it was structured like that on purpose. And ScrollPane works with whatever you put into it -> reliable, so I think it is not a bad thing (other than the css changed 😐)

Maran23 avatar Jan 11 '24 08:01 Maran23

/csr needed

kevinrushforth avatar Jan 12 '24 13:01 kevinrushforth

@kevinrushforth has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@Maran23 please create a CSR request, with the correct fix version, for at least one of the issues associated with this pull request. This pull request cannot be integrated until all the CSR request are approved.

openjdk[bot] avatar Jan 12 '24 13:01 openjdk[bot]

@Maran23 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Feb 09 '24 15:02 bridgekeeper[bot]

@Maran23 This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

bridgekeeper[bot] avatar Mar 08 '24 18:03 bridgekeeper[bot]

/open

Maran23 avatar Mar 08 '24 18:03 Maran23

@Maran23 This pull request is now open

openjdk[bot] avatar Mar 08 '24 18:03 openjdk[bot]

Note that I found out something interesting which can MAY help us here to solve the problem in another way.

What I found out: If I set the the opacity of the clip rect to something under 1, this bug disappears. image

So something in the low level clip rendering is different when an opacity is set. Will investigate if there could be another solution.

Maran23 avatar Mar 09 '24 20:03 Maran23

Ok, so I found out the following: When a Rectangle is used as clip without any effect or opacity modification, the rendering goes another (probably faster) route with rendering the clip. That's why setting the opacity to 0.99 fixes the issue - another route will be used for the rendering. This happens at the low level (NGNode) side of JavaFX.

See here NGNode: image renderRectClip seems to be doing something wrong.

I see that the clip rect is floored there, which seems to be the cause. Rounding it is fixing this for me. The bug always appears when I scroll and the clip RectBounds are something like: RectBounds { minX:6.999996, minY:37.0, maxX:289.00003, maxY:194.0} (w:282.00003, h:157.0)

while this does not happen when the value is something like: RectBounds { minX:7.000004, minY:37.0, maxX:289.0, maxY:194.0} (w:282.0, h:157.0)

Note that the minX is floored down, that explains the 1px gap. I could track it down to be a typical floating point problem: image In AffineBase, line 860. He is calculating: 79,2 * 1,25 (render scale). Should the value be snapped here as well somehow? Another idea is to use doubles instead of float. We lose information when we convert our JavaFX layout double values to float. A quick test showed that this seems to fix the floating point errors.

Another thing I noticed is that the rect calculation seems to be ... weird in renderRectClip.

And now I fully understand why this only happens for the VirtualFlow: This is the only container and location where the clip is layouted as well! (setLayoutX/setLayoutY). In ScrollPaneSkin, there was the decision, that the clip is set and the content is layouted only, not the clip.

It may still make sense to me to actually improve the VirtualFlow here - it seems like a good choice to just set the clip and never touch it again and only change the underlying content layout, might be even a bit faster.

But there is obviously a bug on the low level NGNode side as well. Not sure where to go from here.

Maran23 avatar Mar 10 '24 13:03 Maran23

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Mar 13 '24 20:03 openjdk[bot]

@Maran23 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Apr 10 '24 21:04 bridgekeeper[bot]

open for discussion still, but there will be a counter PR from me at one point.

Maran23 avatar Apr 10 '24 21:04 Maran23

But there is obviously a bug on the low level NGNode side as well. Not sure where to go from here.

does it mean this PR is not ready, or do we have other issue(s)?

Also, a CSR is needed for this PR to go forward.

andy-goryachev-oracle avatar Apr 10 '24 21:04 andy-goryachev-oracle

@Maran23 this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8218745-snapping-x-y-tableview-scroll-3
git fetch https://git.openjdk.org/jfx.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

openjdk[bot] avatar Apr 10 '24 21:04 openjdk[bot]

@Maran23 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar May 09 '24 01:05 bridgekeeper[bot]

should this PR be closed in favor of #1462 ?

andy-goryachev-oracle avatar May 31 '24 17:05 andy-goryachev-oracle

should this PR be closed in favor of #1462 ?

Either that, or else moved to Draft while #1462 is being reviewed.

kevinrushforth avatar Jun 12 '24 12:06 kevinrushforth

Moving to draft.

Maran23 avatar Jun 25 '24 10:06 Maran23

@Maran23 This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Aug 20 '24 12:08 bridgekeeper[bot]