Integrated: JDK-8269921 TextFlow: listeners on bounds can throw NPE while computing text bounds

Florian Kirmaier fkirmaier at openjdk.org
Thu Nov 30 15:02:36 UTC 2023


On Tue, 6 Jul 2021 14:53:24 GMT, Florian Kirmaier <fkirmaier at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: 036d81be
Author:    Florian Kirmaier <fkirmaier at openjdk.org>
Committer: Kevin Rushforth <kcr at openjdk.org>
URL:       https://git.openjdk.org/jfx/commit/036d81be5ab2434863dee2d704967589222176cb
Stats:     113 lines in 2 files changed: 112 ins; 0 del; 1 mod

8269921: TextFlow: listeners on bounds can throw NPE while computing text bounds

Reviewed-by: kcr, angorya

-------------

PR: https://git.openjdk.org/jfx/pull/564


More information about the openjfx-dev mailing list