<div dir="ltr"><div dir="ltr">It appears that my initial email (below) did not make it into the list archive.<div><br></div><div>However, I have now found the relevant issue: <a href="https://bugs.openjdk.org/browse/JDK-8280442">https://bugs.openjdk.org/browse/JDK-8280442</a></div><div><br></div><div>I want to note however that the presented workaround of using getTableRow().isVisible() does not work in general. I find that if one has a context menu on the cell with an action that causes the TreeTableView to be hidden, when one returns to the table the display is incorrect with rows in the wrong place. I have additionally added a check to see if the last time updateItem was called, it was called with the same TreeTableCell object, and to avoid any computation if that is the case - this appears to work.</div><div><br></div>private static EntryCell lastCell;<br><br>@Override<br>protected void updateItem(Entry entry, boolean empty) {<br> super.updateItem(entry, empty);<br><br> //Return immediately to avoid CPU usage when updating the same invisible cell to determine tableview size (see <a href="https://bugs.openjdk.org/browse/JDK-8280442">https://bugs.openjdk.org/browse/JDK-8280442</a>)<br> if(this == lastCell && !getTableRow().isVisible()) {<br> return;<br> }<br> lastCell = this;</div><div dir="ltr"> </div><div> //computation....</div><div dir="ltr">}<br><div><br></div><div>Craig</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 12, 2022 at 4:34 PM Craig Raw <<a href="mailto:craigraw@gmail.com">craigraw@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I'm observing behaviour in TreeTableView (and, I assume, TableView) that is strange and seems to me to be inefficient for tables with many rows.</div><div><br></div><div>On initially displaying the table, the behaviour is as I would expect - a number of instances of TreeTableCell objects are created, and <font face="monospace">updateItem</font> is called on them. There are some repeat calls on the same TreeTableCell object, but the number of calls is small compared to the number of items in the data model.</div><div><br></div><div>However, any interaction, however minor, with the scrollbar of the table (either user or programmatic) causes <font face="monospace">updateItem</font> to be called on the same TreeTableCell object for every item in the underlying data model. With a model with thousands of data rows, this results in several minutes of CPU usage doing nothing of apparent use, creating and overwriting the same text, graphic, tooltip and contextmenu member variables on the same object for each data row.</div><div><br></div><div>Once this is completed, the table seems to revert to normal behaviour - any new rows that are scrolled into view results in a small number of <span style="font-family:monospace">updateItem </span>calls on new TreeTableCell objects commensurate with the number of rows revealed.</div><div><br></div><div>I have reproduced this on MacOS, Linux and Windows using JavaFX 18.</div><div><br></div><div>Is this behaviour expected? If not, are there any workarounds?</div><div><br></div><div>Thanks,</div><div>Craig</div></div>
</blockquote></div></div>