<div dir="ltr">Update: I had a quick look, downloaded the code and for a single scroll event, there are 74 calls to updateItem. However, 69 of those are invoked via <div>`com.jfoenix.skins.JFXListViewSkin.estimateHeight` which calls `com.jfoenix.adapters.VirtualFlowHelper.forEach` which calls into `VirtualFlow.setCell` itself.</div><div><br></div><div>This sounds like something to discuss with the maintainers of the library (jfoenix I believe). Maybe that library tries estimating the height of the flow as well?</div><div><br></div><div>- Johan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 22, 2022 at 5:00 PM Johan Vos <<a href="mailto:johan.vos@gluonhq.com">johan.vos@gluonhq.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 Craig,<div><br></div><div>That boils down to the same issue I described earlier in this thread, and that is also mentioned on <a href="https://bugs.openjdk.org/browse/JDK-8280442" target="_blank">https://bugs.openjdk.org/browse/JDK-8280442</a>. I agree the workaround does not look pretty (I suggested it myself), but the fact that it works is not by accident. There is indeed a difference between calling updateItem on a visible versus an invisible cell. </div><div>The boilerplate code required by the developer to distinguish between those cases should be avoided. We can do that by e.g. passing an additional boolean to the updateItem method, indicating if this is the accumCell or not. But the signature of `updateItem(Object, boolean)` is already hard to explain, especially combined with the requirement that `super.updateItem(...)` must be called.</div><div><br></div><div>- Johan</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 22, 2022 at 1:22 PM Craig Raw <<a href="mailto:craigraw@gmail.com" target="_blank">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">I encountered the same problem and described my solution here: <a href="https://mail.openjdk.org/pipermail/openjfx-dev/2022-July/034764.html" target="_blank">https://mail.openjdk.org/pipermail/openjfx-dev/2022-July/034764.html</a><div><br></div><div>It's not pretty but it does seem to work.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 22, 2022 at 1:18 PM Glavo <<a href="mailto:zjx001202@gmail.com" target="_blank">zjx001202@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"><div dir="ltr">We created an advanced list with titles, subtitles, icons, and tags, and updated these contents in the updateItem.<br><div><br></div><div>I took a screenshot of it and uploaded it as a comment to GitHub next to the relevant code:<br></div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div dir="ltr"><div><a href="https://github.com/huanghongxun/HMCL/pull/1849/commits/4f8cde63acf959d85416b706acf22f9b3c80ec63#r1029184905" target="_blank">https://github.com/huanghongxun/HMCL/pull/1849/commits/4f8cde63acf959d85416b706acf22f9b3c80ec63#r1029184905</a></div><div><br></div></div></blockquote>It worked well in the past, but in JavaFX 17, it was so slow that it blocked the UI thread for a few seconds, making the operating system think that the program did not respond.‘<div><br></div><div>I improved the updateItem to make it ten times faster, but even so, it is still not as smooth as before, and there will be an obvious FPS drop.</div><div><br></div><div>If possible, please check our code on GitHub through the above link. <br><div><br></div><div>It is difficult to continue to optimize the updateItem method. Even if I use a Map to cache nodes created for elements, it will not become faster.<br></div><div>Are we using it in the wrong way?<br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 22, 2022 at 4:48 PM Johan Vos <<a href="mailto:johan.vos@gluonhq.com" target="_blank">johan.vos@gluonhq.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 Glavo,<div><br></div><div>There are more frequent calls to updateItem() since the VirtualFlow tries to gradually improve its estimation how large the total list size is (rather than assuming all cells have the same size). The major point is that if you override updateItem, it should not do more than strictly needed (e.g. don't create a Node etc). That method should return as fast as possible.</div><div><br></div><div>There are many completely different usecases for VirtualFlow in general, and it's not trivial to come up with a single implementation that deals "best" with all usecases. Therefore, I recently solicited for feedback and it might be good if you can give yours too? </div><div>See <a href="https://mail.openjdk.org/pipermail/openjfx-dev/2022-September/035851.html" target="_blank">https://mail.openjdk.org/pipermail/openjfx-dev/2022-September/035851.html</a> for the start of the discussion.</div><div><br></div><div>- Johan</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 22, 2022 at 9:24 AM Glavo <<a href="mailto:zjx001202@gmail.com" target="_blank">zjx001202@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, <div><br></div><div>I'm one of the maintainers of the open source project HMCL (Hello! Minecraft Launcher<i>)</i>. This is a Minecraft launcher based on JavaFX. <div><div><br></div><div>In the past year, we have received a lot of feedback on performance problems. Through performance analysis, I noticed that from JavaFX 17 ea+8, the performance of list scrolling is terrible.<br></div><div><br></div><div>I analyzed the method calls and noticed that the updateItem method of ListCell is called 8 times more frequently in JavaFX 17 than in JavaFX 16.<br></div><div><br></div><div>I guess this is due to the following commit:<br></div><div><br></div><div> <a href="https://github.com/openjdk/jfx/commit/8e547571fb3d40df843c27fc11921b5d4765c481" target="_blank">https://github.com/openjdk/jfx/commit/8e547571fb3d40df843c27fc11921b5d4765c481</a></div><div><br></div><div>I wonder if this is a bug? <br></div></div><div><br></div><div>Best regards,<br>Glavo</div><div><br></div></div></div>
</blockquote></div>
</blockquote></div></div></div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>