RFR: JDK-8269921 TextFlow: listeners on bounds can throw NPE while computing text bounds [v6]
Florian Kirmaier
fkirmaier at openjdk.org
Mon Oct 30 15:03:05 UTC 2023
> It's "a bit" complicated.
> In some situations, getRuns get's called because listeners on bounds are set.
> This causes TextFlow to layout to compute the runs.
> Afterward, the bounds of the parents get updated.
> This triggers a call to compute bounds - which cascades up to the children.
> When the geometry of the previous Text gets computed in this big stack - it throws an nullpointer.
> The Text doesn't have its runs, and calling TextFlow.layout is now a noop (it detects repeated calls in the same stack)
>
> In the case it happened - it didn't repair and the application kinda crashed.
> This bug most likely can also be triggered by ScenicView or similar tools, which sets listeners to the bounds.
> It also can cause unpredictable performance issues.
>
> Unit test and example stacktrace are in the ticket.
>
> The suggested fix makes sure that recomputing the geometry of the Text, doesn't trigger the layout of the TextFlow.
> The Textflow should be layouting by the Parent.
> This might change the behavior in some cases, but as far as I've tested it works without issues in TextFlow Heavy applications.
>
> Benefits:
> * Better Tooling Support For ScenicView etc.
> * Fixes complicated but reproducible crashes
> * Might fix some rare crashes, which are hard to reproduce
> * Likely improves performance - might fix some edge cases with unpredictable bad performance
Florian Kirmaier has updated the pull request incrementally with one additional commit since the last revision:
updated test to junit5
improved name for method onEveryNode -> addBoundsListener
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/564/files
- new: https://git.openjdk.org/jfx/pull/564/files/8ab38610..dda1a0c4
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=564&range=05
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=564&range=04-05
Stats: 12 lines in 1 file changed: 1 ins; 1 del; 10 mod
Patch: https://git.openjdk.org/jfx/pull/564.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/564/head:pull/564
PR: https://git.openjdk.org/jfx/pull/564
More information about the openjfx-dev
mailing list