RFR: 8370498: Improve how Node detects whether a layout property change requires a new layout pass [v4]
John Hendrikx
jhendrikx at openjdk.org
Tue Oct 28 22:36:23 UTC 2025
On Tue, 28 Oct 2025 17:09:38 GMT, Johan Vos <jvos at openjdk.org> wrote:
> > How many pulses are needed to finish the layout? If we ignore for a second some pathological cases when the layout process never ends causing continuous flicker, is there a safe upper limit?
>
> Realistically, I'd say 10 iterations is pretty common, and I wouldn't be surprised if it goes much higher in some common applications. With 10 iterations, I mean the amount of "layout phases" that are chained by a `requestNextPulse` during the previous layout phase. Once there is a layout phase without a `requestNextPulse`, I consider the rendering "stable".
In what software do you get 10 iterations as "common"? That's close to 200 ms @ 60 fps. The software would look and perform worse than decades old software. I'm running quite complex software with FX, and never does a layout take more than 1 pass (not counting the superfluous pass made by FX currently) as that would be absolutely unacceptable for my work that must look absolutely smooth and polished.
> This will have a few other major impacts that are hard to predict:
>
> 1. what about CSS passes? repeat those too? (probably yes -> really expensive)
Ehr, no definitely not. Just like you shouldn't be modifying layout positions during layout, you should not be doing things (during layout) that modify CSS styles because the CSS pass has already completed. Modifying CSS during layout (which changes anything size or position related) is a guaranteed jump of your UI as a next pass is required. This looks flakey and unprofessional.
For example, you also should not be modifying the scene graph during layout, because if you say add a new child (like a list cell or something) that cell will be rendered **without** styles, resulting in things like white flashes on your black background because that's the default background. This kind of stuff must be done in a `Scene::addPreLayoutListener` if you want to ensure your application looks smooth.
> 2. the flow of apps will be completely different. As long as a pulse is running, no Runnables scheduled via Platform.runLater() can be executed. If you do 10 layout passes inside a pulse, the time between the Runnables being executed becomes an order of magnitude more than before, and that will have a major impact for some applications.
Nobody is suggesting running layout passes until the UI settles.
Anyway, the only practical use would be to cover up self created layout problems, and encourage more bad behavior, so perhaps it is better to not even consider this.
You mentioned that FX "promises to handle all edge cases". Do you care to show me where it does so? Because FX would be the first system with complex layouts that would be doing so.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1945#issuecomment-3458829150
More information about the openjfx-dev
mailing list