Calling TextService:GetTextBoundsAsync multiple times leads to requests never completing (thread leaks)

Reproduction Steps

Calling TextService:GetTextBoundsAsync(params) multiple times in a row stops the previous requests from completing. This is problematic because you cannot query for different types of text in a row. For example, if I’m trying to size 2 labels manually, then I would need to make 2 calls at the same time. I expect both to complete.

The following code reproduces this bug:

local TextService = game:GetService("TextService")

for i=1, 5 do
		local params ="GetTextBoundsParams")
		params.Text = "Doors"
		params.Size = 64
		params.Font ="rbxasset://fonts/families/JosefinSans.json", Enum.FontWeight.Light, Enum.FontStyle.Italic)
		params.Width = 10*64
		print("query", i)
		local result = TextService:GetTextBoundsAsync(params)
		print("done with query", result, i)

The following output is what you get

  query 1
  query 2
  query 3
  query 4
  query 5
  done with query 162, 64 5

I expect the following

  query 1
  query 2
  query 3
  query 4
  query 5
  done with query 162, 64 1
  done with query 162, 64 2
  done with query 162, 64 3
  done with query 162, 64 4
  done with query 162, 64 5

Basically, we drop the 4 previous queries somehow.

This only reproduces on a font not already downloaded to Roblox.

Expected Behavior

I expect size queries to always return after querying.

Actual Behavior

All but the last query is cancelled. This is very sad, and kind of annoying.


I’m going to end up with some promise queue as a work-around, but this is not great for performance.

Issue Area: Engine
Issue Type: Other
Impact: Moderate
Frequency: Constantly
Date First Experienced: 2022-12-19 00:12:00 (-08:00)


Thanks for the report! We’ll take a look.