RFR: 8359599: Calling refresh() for all virtualized controls recreates all cells instead of refreshing the cells [v5]

Marius Hanl mhanl at openjdk.org
Wed Oct 29 23:05:20 UTC 2025


> When calling `refresh()` on virtualized Controls (`ListView`, `TreeView`, `TableView`, `TreeTableView`), all cells will be recreated completely, instead of just refreshing them.
> 
> This is because `recreateCells()` of the `VirtualFlow` is called when `refresh()` was called. This is not needed, since refreshing the cells can be done much cheaper with `rebuildCells()`.
> 
> This will reset all cells (`index = -1`), add them to the pile and fill them back in the viewport with an index again. This ensures `updateItem()` is called.
> 
> The contract of `refresh()` is also a big vague, stating:
> 
> Calling {@code refresh()} forces the XXX control to recreate and repopulate the cells 
> necessary to populate the visual bounds of the control.
> In other words, this forces the XXX to update what it is showing to the user. 
> This is useful in cases where the underlying data source has changed in a way that is not observed by the XXX itself.
> 
> 
> As written above, recreating is not needed in order to fulfull the contract of updating what is shown to the user in case the underlying data source changed without JavaFX noticing (e.g. calling a normal Setter without any Property and therefore listener involved).
> 
> ----
> 
> Benchmarks
> -
> 
> Setup:
> - `TableView`
> - `100 TableColumns`
> - `1000 Items`
> 
> Code is in `tests/performance`.
> 
> Calling `refresh()` with a `Button` press.
> 
> | WHAT | BEFORE WITHOUT JDK-8360940 | BEFORE | WITH FIX | WITH FIX WITH JDK-8370498 |
> | - | - | - | - | - |
> | Init | 0ms | 0 ms | 0 ms | 0 ms |
> | Init | 0ms | 0 ms | 0 ms | 0 ms |
> | Init | 195 ms | 209 ms | 211 ms | 217 ms |
> | Init | 42 ms | 47 ms | 41 ms | 10 ms |
> | Init | 2 ms | 6 ms | 6 ms | - |
> | Refresh Nr. 1 | 204 ms | 227 ms -> 23 ms -> 0 ms | 42 ms -> 0ms | 48 ms -> 0ms |
> | Refresh Nr. 2 | 201 ms | 145 ms -> 27 ms -> 0 ms | 31 ms -> 0ms | 35 ms -> 0ms |
> | Refresh Nr. 3 | 207 ms | 153 ms -> 25 ms | 33 ms -> 0ms | 31 ms -> 0ms |
> | Refresh Nr. 4 | 148 ms | 168 ms -> 20 ms -> 0 ms | 30 ms -> 0ms | 31 ms -> 0ms |
> | Refresh Nr. 5 | 136 ms | 183 ms -> 31 ms -> 0 ms | 46 ms -> 0ms | 29 ms -> 0ms |

Marius Hanl has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:

 - Merge branch 'master' of https://github.com/openjdk/jfx into 8359599-refresh-recreates-all
 - javadoc and performance test
 - Improve javadoc
 - remove newline from imports
 - assert row creation count as well
 - Merge branch 'master' of https://github.com/openjdk/jfx into 8359599-refresh-recreates-all
 - Calling refresh() for all virtualized controls recreates all cells instead of refreshing the cells

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

Changes:
  - all: https://git.openjdk.org/jfx/pull/1830/files
  - new: https://git.openjdk.org/jfx/pull/1830/files/0575d6fb..ba5a9bab

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1830&range=04
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1830&range=03-04

  Stats: 2090 lines in 126 files changed: 1437 ins; 199 del; 454 mod
  Patch: https://git.openjdk.org/jfx/pull/1830.diff
  Fetch: git fetch https://git.openjdk.org/jfx.git pull/1830/head:pull/1830

PR: https://git.openjdk.org/jfx/pull/1830


More information about the openjfx-dev mailing list