RFR: 8185886: Improve scrolling performance of TableView and TreeTableView

John Hendrikx jhendrikx at openjdk.java.net
Thu Apr 16 08:50:25 UTC 2020

On Thu, 16 Apr 2020 08:24:16 GMT, dannygonzalez <github.com+6702882+dannygonzalez at openjdk.org> wrote:

>> The listeners added by `Node` are apparently internally required for internal properties `TreeShowing` and
>> `TreeVisible`, and are used to take various decisions like whether to play/pause animations.  There is also a couple of
>> listeners registering on these properties in turn (in `PopupWindow`, `SwingNode`, `WebView` and `MediaView`).  A lot of
>> the checks for visibility / showing could easily be done by using the `Scene` property and checking visibility /
>> showing status from there.  No need for so many listeners.  The other classes mentioned might register their own
>> listener, instead of having `Node` do it for them (and thus impacting *every* node).  Alternatively, `Node` may lazily
>> register the listeners for Scene.Window and Window.Showing only when needed (which from what I can see is for pretty
>> specific classes only, not classes that you'd see a lot in a TableView...)
> If it is of any help, I have attached a VisualVM snapshot (v1.4.4) where the ExpressionHelper.removeListener is using
> 61% of the JavaFX thread whilst running our application.
> [snapshot-1587024308245.nps.zip](https://github.com/openjdk/jfx/files/4485728/snapshot-1587024308245.nps.zip)
> If you show only the JavaFX Application thread, press the "HotSpot" and "Reverse Calls" button you can take a look to
> see which classes are calling the removeListener function.
> ![Screenshot 2020-04-16 at 09 16
> 11](https://user-images.githubusercontent.com/6702882/79432046-2f788800-7fc3-11ea-930a-98fed0190628.png)

@dannygonzalez  Could you perhaps debug your application and take a look at how large the following array is: a random
node -> `scene` -> `value` -> `window` -> `readOnlyProperty` -> `helper` -> `changeListeners`.  I just tested this with
a custom control displaying 200 cells on screen at once (each cell consisting of about 30 nodes itself), and I saw
about 20000 change listeners registered on this single Scene Window property.

However, this custom control is not creating/destroying cells beyond the initial allocation, so there wouldn't be any
registering and unregistering going on, scrolling was still smooth >30 fps.


PR: https://git.openjdk.java.net/jfx/pull/108

More information about the openjfx-dev mailing list