RFR: 8306447: Adding an element to a long existing list may cause the first visible element to jump

Johan Vos jvos at openjdk.org
Thu Apr 20 07:20:00 UTC 2023


On Wed, 19 Apr 2023 16:33:37 GMT, Marius Hanl <mhanl at openjdk.org> wrote:

>> Calculate position of first visible element before propagating changes.
>> Make sure to restore the position of said element after the changes are done.
>> 
>> Fix JDK-8306447
>
> modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java line 858:
> 
>> 856: 
>> 857:         @Override protected void invalidated() {
>> 858:             int oldIndex = computeCurrentIndex();
> 
> I wonder if we can cache the old index somewhere since the _compute..._ methods can take some time on big tables.

I think an instance variable makes sense, as the current index is a property of a specific VirtualFlow instance.
That won't help with performance though, as we still need to compute the current index in a number of cases. Instead of calling the `computeCurrentIndex()` we would then just update the instance variable. 
To fix the issue, we need to reduce the cases where the current index is recomputed (or bring it to zero in case the current index can't theoretically change) , and this is what #1098 is about -- so your comment probably belongs to #1098?
I'll experiment with instance fields, and try to reduce the computations even more.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1099#discussion_r1172177638


More information about the openjfx-dev mailing list