On Thu, 3 Aug 2023 15:13:09 GMT, Marius Hanl <mh...@openjdk.org> wrote:

>> An IOOBE was thrown when scrolling up via the trough (-> 
>> `VirtualScrollBar#adjustValue`).
>> This happened only when it has bigger cells than the viewport. 
>> If the the uppermost cell with the index 0 is only visible (although not 
>> completely scrolled to the top) and then an attempt is made to scroll up 
>> again, the `VirtualFlow` will try to scroll to the next cell, subtracting 
>> index 0 by 1, resulting in -1 -> IOOBE.
>> 
>> The code now guards against any under or overflow.
>> 
>> This is technically a regression from 
>> https://bugs.openjdk.org/browse/JDK-8173321
>> 
>> Note: While testing with very big cells, I found out that scrolling via the 
>> trough may not work after the first time. 
>> This is because the `VirtualFlow` still creates 2 cells, although only one 
>> can be visible at a time (at least when scrolling to the next cell) (and 
>> `VirtualScrollBar` does this check, which will never be true then: 
>> `firstVisibleCell == lastVisibleCell`). This is unrelated to this fix. I can 
>> create a ticket when I have more information.
>
> Marius Hanl has updated the pull request incrementally with three additional 
> commits since the last revision:
> 
>  - JDK-8311983: remove JUnit5 import
>  - JDK-8311983: improve exception handling
>  - JDK-8311983: More tests

The change looks good, tested with the test app in the ticket and the Monkey 
Tester.

I wonder if we ought to consider some kind of `dirty` flag in the virtual 
layout to ensure that the layout is always performed when needed.  I understand 
this might require a larger change and it's definitely out of the scope for 
this PR.

modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
 line 1790:

> 1788:         // Scroll down.
> 1789:         flow.shim_getVbar().adjustValue(0.9605263157894737);
> 1790:         // Scroll up.

FYI: adding `pulse()` here prevents the exception.

We seem to have a similar situation on line 739 (this particular test is 
ignored, but there quite a few `pulse()`s scattered in the test code:

        // NOTE Run this test without the pulse and it fails!
        pulse();

I wonder if there is something in the virtual flow that can detect when 
`flow.layout()` is needed and do it automatically.

modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
 line 1799:

> 1797:     @Test
> 1798:     public void testScrollBarValueAdjustmentShouldScrollOneDown() {
> 1799:         flow = new VirtualFlowShim<>();

FYI: this test does not fail without the fix.  should it?

-------------

Marked as reviewed by angorya (Reviewer).

PR Review: https://git.openjdk.org/jfx/pull/1194#pullrequestreview-1579016585
PR Review Comment: https://git.openjdk.org/jfx/pull/1194#discussion_r1294877456
PR Review Comment: https://git.openjdk.org/jfx/pull/1194#discussion_r1294877019

Reply via email to