Developer Console sometimes fails to display the last line of multiline strings

Certain multiline strings do not get displayed correctly in the Dev Console. Their last line does not get shown at all.

For example:

print("The Beginning\nThe Middle\nThe End\nThe Epilogue")

In Studio or in-game, run the above command and view the result in the developer console. The final line “The Epilogue” will be missing.

Version info:

5 Likes

Here it’s working:


1 Like

I filed a ticket to our internal database. Thanks for the report.

2 Likes

Hi Rio, are you still encountering this issue? We’ve taken some cracks at replicating this behavior and haven’t be able to do so.

1 Like

It’s still happening to me both in Studio and in-game with the string given in the OP.


Edit: I had a look at the CoreGui and CoreScripts. The full text is present in the TextLabel, the TextLabel is just too small to render all of it.

This bug appears to be related to another bug I have complained about: DevConsole does not compute label size correctly for strings with newlines

Using the exact same pieces of code as in that bug report (except LogOutput line 146 instead of line 79), I was able to figure out the issue here.

The LogData module computes the text size like so:

-- LogData, Line 34
local dims = TextService:GetTextSize(fmtMessage, FONT_SIZE, FONT, Vector2.new())

And for the particular buggy string used in this bug report, GetTextSize returns bounds with height ~58.67.

You can check this with the following code (just run it in the command bar):

=game:GetService("TextService"):GetTextSize([[20:43:40 -- > The Beginning
The Middle
The End
The Epilogue]], 15, Enum.Font.SourceSans, Vector2.new())

Now, we then look at the code that uses these dimensions to render the output:

-- LogOutput, Line 146
local msgDimsY = message.Dims.Y
if wordWrap and frameWidth > 0 then
	msgDimsY = message.Dims.Y * math.ceil(message.Dims.X / frameWidth)
end
-- [...]
elements[messageCount] = Roact.createElement("Frame", {
	Size = UDim2.new(1, 0, 0, msgDimsY),
-- [...]
msg = Roact.createElement("TextLabel", {
	Text = fmtMessage,
	TextColor3 = color,
	TextSize = FONT_SIZE,
	Font = FONT,
	TextXAlignment = Enum.TextXAlignment.Left,

	TextWrapped = wordWrap,

	Size = UDim2.new(1, 0, 0, msgDimsY),

The issue here is that the size of the label, when rendered, is being rounded down to 58 (causing the final line to be hidden), instead of rounded up to 59 (which would have enough space for the last line to be rendered, which I tested and confirmed by manually editing the TextLabel’s Size).

So the fix is to make line 148 be:

msgDimsY = math.ceil(message.Dims.Y * math.ceil(message.Dims.X / frameWidth))

Just spitballing here, but I am using a 4k monitor (albeit with 150% DPI scaling). We may be seeing different results because our game viewports have different sizes, and therefore the position of the DevConsole frame on the screen could be fractional on my screen and whole on yours, or something similar which may introduce differences in how fractional TextLabel sizes are rendered.

(e.g. the DevConsoleWindow is currently at AbsolutePosition.Y = 39.4 in the viewport in Studio. But that specific example doesn’t seem to be the issue - changing the Frame’s Position does not fix the issue as far as I can tell).

In my own code I tend to just superstitiously math.ceil() every TextLabel’s size to prevent these kinds of issues.

2 Likes

This is awesome, Rio! Thanks for providing such great detail, I’ll follow up again once we’ve got a fix!

3 Likes

Hey everyone! This should be fixed, is everything working?

1 Like

Yep, it seems to be fixed! Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.