Control is using height in percentage mode inside a vertical StackPanel Warnings after update to 6.25.0

Hi,
after updating babylonjs from 6.24.0 to 6.25.0 I’m getting some warnings in the console:
Control (Name:text1, UniqueId:101) is using height in percentage mode inside a vertical StackPanel
I’m using resizeToFit=true, so I think this shouldn’t happen, and it’s only showing after the latest update.
Looking at the inspector, I can see that the control has a height in pixel and it is also shown correctly on screen.
Manually setting the height to some random pixel value removes the warning and the real size remains the same.

Here is small playground example with two text blocks inside a vertial stack panel:

But setting panel.isVertical = false does not show any warnings:

Adding another stack panel with text blocks inside also shows the warning for the new stack panel:

Using an older babylonjs version in the playground also doesn’t show the warning.

Is this intended or is it a bug?

Thanks :slight_smile:

Let me add @carolhmj our GUI expert to the thread

So, investigating this matter, what I found out is that in 6.24 this line: https://github.com/BabylonJS/Babylon.js/blob/965d7f4c38c1dea98011f5e244c5e33b2ff4576f/packages/dev/gui/src/2D/controls/textBlock.ts#L394, which sets the size of the GUI to be in pixels when resizeToFit = true, is executed before this line: https://github.com/BabylonJS/Babylon.js/blob/965d7f4c38c1dea98011f5e244c5e33b2ff4576f/packages/dev/gui/src/2D/controls/stackPanel.ts#L170, which checks if the child container of the panel has a height in percentage mode, while in 6.25 their execution order is inverted, so we check if the child is in percentage BEFORE we set it to pixel.

This check shouldn’t depend on evaluation order anyways, so I’ll add a check for the resizeToFit: Fix stack panel giving a warning for children with resizeToFit. by carolhmj · Pull Request #14452 · BabylonJS/Babylon.js (github.com)

1 Like

Using a vertical stackpanel with adaptHeightToChildren=true and therefore also having a height set in pixels still shows the warning message (see the third playground link of my original post for an example).

Thanks for the previous fixes, but I think I’ve found another one:

Adding a vertical stackpanel inside another vertical stack panel also shows the warning, although the height of stackpanel2 is set in pixel automatically. This doesn’t happen when both stack panels are set to isVertical=false.

Thanks for the careful checking :slight_smile: I have another PR to address this in a (hopefully) more consistent way: Better handling of StackPanel layout warning by carolhmj · Pull Request #14549 · BabylonJS/Babylon.js (github.com)

3 Likes

You are the best @carolhmj

1 Like