> The commit 1b12c8a490 introduced two performance issues in VirtualFlow:
>
> 1. Calling requestLayout() on all cells in the pile on every layout pass This
> causes unnecessary layout calculations for 50-100 recycled cells per frame
> during scrolling.
>
> 2. Using sheetChildren.removeAll(pile) which has O(n*m) time complexity This
> becomes extremely slow with large cell pools.
>
> These changes caused severe scrolling lag in ListView/TableView with many
> items (e.g., 100+ items, even less). The fix removes both problematic code
> blocks while preserving the getViewportBreadth() visibility change needed by
> TableRowSkinBase.
>
> Tested with ListView containing 1000 items - scrolling is now smooth again,
> matching JavaFX 24 performance.
>
> The sample project has been uploaded:
> [demo-javafx.zip](https://github.com/user-attachments/files/24561207/demo-javafx.zip)
>
> My system environment is:
> - Apple M1
> - macOS 26.2
>
> Installed and used JDKs from the following vendors via SDKMAN:
> - 25.0.1-graalce
> - 25.0.1.fx-nik
> - 25.0.1-tem
>
> Without exception, the lists are all somewhat laggy when scrolling. But if I
> downgrade the FX version to 24, only "25.0.1.fx-nik" still shows lag — the
> other two are very smooth!
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>com.example</groupId>
> <artifactId>demo-javafx</artifactId>
> <version>1.0-SNAPSHOT</version>
> <packaging>jar</packaging>
>
> <name>JavaFX ListView Demo</name>
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <java.version>25</java.version>
> <javafx.version>25</javafx.version>
> <javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
> </properties>
>
> <dependencies>
>
> <dependency>
> <groupId>org.openjfx</groupId>
> <artifactId>javafx-controls</artifactId>
> <version>${javafx.version}</version>
> </dependency>
>
>
> <dependency>
> <groupId>org.openjfx</groupId>
> <artifactId>javafx-fxml</artifactId>
> <version>${javafx.version}</version>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
>
> <plugin>
> <groupId>org.apache.maven.plugins</g...
youngledo has updated the pull request incrementally with one additional commit
since the last revision:
8185887: Optimize VirtualFlow performance by avoiding cell removal
This change optimizes the cleanPile() method to avoid O(n*m) complexity
by NOT removing cells from sheetChildren. Instead, cells in the pile are
simply set to invisible. This provides significant performance improvement
during scrolling.
The test testSheetChildrenAreAlwaysTheAmountOfVisibleCells() has been
updated to count only visible cells in sheetChildren, as invisible cells
from the pile may still be present.
Performance improvement:
- Before: 10-20 FPS with stuttering
- After: 60 FPS smooth scrolling
Changes:
1. cleanPile() no longer removes cells from sheetChildren
2. Cells in pile are only set to invisible
3. Test updated to count only visible cells
4. Preserves all other optimizations:
- No requestLayout() calls on pile cells
- Proper focus handling with doesCellContainFocus()
- Cell visibility management in getAvailableCell()
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/2030/files
- new: https://git.openjdk.org/jfx/pull/2030/files/43ff258b..ec7897cc
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=2030&range=04
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=2030&range=03-04
Stats: 20 lines in 2 files changed: 8 ins; 6 del; 6 mod
Patch: https://git.openjdk.org/jfx/pull/2030.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/2030/head:pull/2030
PR: https://git.openjdk.org/jfx/pull/2030