RFR: JDK-8269921 TextFlow: listeners on bounds can throw NPE while computing text bounds [v5]

Kevin Rushforth kcr at openjdk.org
Tue Oct 31 14:39:50 UTC 2023


On Tue, 31 Oct 2023 12:30:23 GMT, Florian Kirmaier <fkirmaier at openjdk.org> wrote:

>> I would suggest investigating this a bit further.
>> 
>> The semantics of this method is to return valid Bounds, and it looks like we do not honor this contract.  It is possible that we get the original exception because the listener is being called during layout (just guessing) - will this method be called again and return the valid value second time?  Or do we need to actually call the layout() to ensure that we do, in fact, have a valid layout every time this method is called?
>
> generally speaking - the behavior relating to the bounds is broken.
> 
> Some components behave differently, after setting a listener to the bounds.
>  1.) Groups tend to call layout in the children.
>  2.) And Text seems to call layout on it's parent TextFlow
> Both cases are serious problems in my opinion - and this should be designed somehow differently.
> 
> But for now, i would be happy if the affected applications don't crash by this bug here.

As long as we have some understanding of how `runs` can become null at this point (which I think we do), then the current proposed fix seems fine to me.

Let's also file a follow-up bug to investigate whether we can make the computation of bounds during layout more robust so that we don't have transiently wrong results.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/564#discussion_r1377695843


More information about the openjfx-dev mailing list