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

Andy Goryachev angorya at openjdk.org
Tue Oct 31 15:02:51 UTC 2023


On Tue, 31 Oct 2023 14:37:15 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> 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.

I've had a similar problem - solved by explicitly recomputing the layout if it was "dirty".
In this case, it might be ok if the call to getSpanBounds with null runs is followed by another where runs are not null so the client code gets the valid bounds eventually.

But if it's not, the caller ends up with incorrect bounds.

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

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


More information about the openjfx-dev mailing list