I have an interesting issue which I think is a bug. Text positioning is very inconsistent with resizetofit = false. If i set resizetofit = true, then i get the error message.
Layout cycle detected in GUI (Control name=MyTextBlockName lc, uniqueId=848)
Here is the text issue when I load my UI in Babylonjs:
(focus on the clumped white lorem ipsum text)
and if I load it for the first time in gui.babylonjs it looks the same. BUT! If you click the “edit UI” pen, the issue is gone, it looks how the snippit was originally designed.
Now before, i would just set the “resizetofit” to true and it would fix this issue, but then my console gets this error
Layout cycle detected in GUI (Control name=MyTextBlockName lc, uniqueId=848)

I dont think the errors are needed, as the resizetofit is working fine for the UI layout. I think it may be over zealous or perhaps there is an issue that I cannot see.
I should mention that this error happens regardless where the text is, if its in the root, parented with a container, parented with a stackpanel, doesn’t matter.
You might “solve” it by using the TextBlock property ‘lineSpacing’ like this blockName.lineSpacing = 6, and avoid the use of resizeToFit property, when space is enough and font is higher than default (18).
It worked for me.
Yes, I’m using zeros everywhere because I actually don’t know what the line height should be because I am exporting from Figma and unfortunately, if the layer is set to automatic, the line height isn’t exposed in the Figma api. I could guesstimate it, but it won’t be right because Figma doesn’t share how they determine line heights. Also, there is a fundamental difference between how Figma judges, lite and Babylon JS does. Figma would judge anything with the line height of zero to have zero lines and everything would just be on the same line where as Figma will just say it has a gap of zero pixels between each line.
Again, this is never been a problem because I just set line heights to zero but allow the height of the text box and the “resize to fit” do the job and it is a one-to-one look alike for what I was expecting. The only issue is I get console errors, which are not nice. Also, even if I have “resized to fit” off, when I go to edit the UI using the built-in editor, it seems to trigger the resize to fit on and off because then it will look correct even when the lineheight is set to zero, but then when I click on it, it will go back to using the line height of zero… Its not right behaviour.
@jamessimo - I tried checking out the playground you linked to, but that playground ID wasn’t found - could you check the link? @georgie or I can take a look once we have the updated playground link. Thanks!
Something odd is going on – I repro’d the error and then while trying to debug that specific text which had the name ‘desc’ i noticed that there were a ton of other items with the same name (complicating my debugging) – so i changed the name of that text block to be ‘TEXT TO DEBUG’ and then I’m not sure what caused this but there are a ton of nodes that got renamed 
Tried again changing the name to be ‘changing name’ and i don’t yet see the other items renamed. but it does seem like there is some odd behavior going on that could perhaps lead to the log for dependency cycle even if UX seems to behave properly. still looking into it!
Update: That seems like a separate bug. I deleted all the other nodes and just kept textBlock, and if i resizeToFit the error remains. Looks like we are hitting this clause in textBlock.ts and setting rebuildLayout to true
, and then control.ts layout function is looping 3 times and hitting this
It does look like 3 is all it needs though, so i may be able to set the limit to 4 and we will see UX working and no error
Hmm actually it seems something may be wrong with the logic around height checking, at first round i see and then next time breakpoint is hit i see the opposite (where newHeight and this._height are swapping)


looks like this isbecause fontOFfset is getting recreated at each layout (since isDirty is true) and thus fontOffset.height gets restored to old value, so newHeight is actually the old height
our GUI expert is out on leave so in the meantime while trying to solve the bug more wholistically i can up the layout cycle error threshold to reduce noise in console since the actual resizing logic is working, (i.e. we are getting th eproper height of 187 at first go) we just need to fix the fact that fontoffset is not updated properly.
Is this fix comming to the 8.22.2 version?
Pretty sure it was yes, the error no longer shows for me using the latest build.
Ok, but the latest downloadable (.zip file) version is still the 8.22.1 not 8.22.2
can you share the link you use ?
Thanks for reporting, I released a new patch as there was a glitch in the matrix.
2 Likes