Type Solver / Checker breaks indefinitely as it starts scanning Huge scripts meant for data and makes studio closing process infinite

I made a tool that is effective at encoding any video format (supported by ffmpeg) and a player to unpack that bufferized string data at stable 60 fps using EditableImages;

During benchmarking, with scripts holding strings for a total of > 60 MB the Roblox Studio type checker would start scanning these scripts in the background and stop indefinitely, the autocomplete becomes disabled and confusing type errors show up in normal scripts. The scripts with data were not required directly, the type checker and autocomplete just break for all scripts in the game.

Tried to fix this by adding --!nocheck and an :: any typecast into the generated files and their return value, the scanning still starts in the background, I could deduce that by autocomplete becoming completely off and confusing type errors appearing. I believe the threshold for this happening is much lower, somewhere around 10 MB (it’s a guess, idk for sure). The reproduction files contain the full 60.2MB of data that first made this happen.

When closing a place with such case of broken type checker and autocomplete, the place would not close for 30 minutes, then I just used Alt+F4, it was much more effective. This only affects the place closing, you can still Save To Roblox as usual before you close the place. I always save before closing, so I don’t know whether any data could be lost because of this.

Visual Aids: autocomplete does not show up, type errors out of place show up.

This happens when your studio session is about 30-60 minutes old since the moment you opened the place. It is guaranteed to happen. At least one script must be open and regularly receive edits through the Roblox Studio script editor.

I believe this happens in every place and isn’t specifically tied to anything.

For staff, the System Information, Beta Features and Reproduction Files are available in the private content part of this Bug report.

Expected behavior

Something like: --!nocheck scripts (or scripts that are never required) should not be analysed, or analysis should give up on very large sources without breaking autocomplete in other scripts.

There should be a way (e.g. a Setting) to disable the type checking / scan for files by path or if they are over X bytes big. And a way to kill the type checker / scan process + restart it anytime.

A private message is associated with this bug report

Hello! Sorry to hear you’re running into this. We are hopefully rolling out a fix for an issue that sounds similar to what you’re running into. I’ll check back in on this once that goes out :slightly_smiling_face:

I’ve been testing the place further, made a new discovery, this can happen with as little as about 9 MB total for all script contents given that one of the scripts alone takes 8.41 MB (8825729 Characters, of which 8824361 are purely string data, or 8823688 without string close/open, tab and comma characters 8824361 - 42 * 4 * 4 - 1)

Here’s the structure of the code by the way:
(it is also present in the Reproduction Files in the private message)

--!nocheck
-- Coffilhg (Roblox UserId 517222346) | CoffeEncoder | https://github.com/Coffilhg/CoffeEncoder
--[[CoffeEncoder {"CoffeEncoder":1,"VideoId":"bf888099-dc25-4ac2-bcfd-665c86e57449","Name":"Fumo_touhouproject_touhoumemes_cirnofumo_touhoufum","Part":1,"PartCount":1,"FirstChunk":1,"ChunkCount":42,"Continues":false,"Options":{"FormatVersion":2,"Codec":"PaletteTileXorZstd","Width":196,"Height":199,"Fps":30,"FrameCount":686,"ChunkFrames":63,"TileSize":16,"ChunkFrameCounts":[8,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,17,16,18],"Source":"Fumo_touhouproject_touhoumemes_cirnofumo_touhoufumo_cirnofumo_2.mp4"},"Metadata":{"Author":"@crymoonbv (CryMoøn) | TikTok | 15-1-2024"}}]]
-- Generated by CoffeEncoder. Import it with the CoffeEncoder Studio plugin.
return {
	Options = {
		FormatVersion = 2,
		Codec = "PaletteTileXorZstd",
		Width = 196, Height = 199,
		Fps = 30, FrameCount = 686,
		ChunkFrames = 63, TileSize = 16,
		ChunkFrameCounts = { 8, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 17, 16, 18 },
		Source = "Fumo_touhouproject_touhoumemes_cirnofumo_touhoufumo_cirnofumo_2.mp4",
	},
	Part = 1, PartCount = 1, -- this file holds chunks 1 to 42
	Data = {
		[[...]],
		[[...]],
		... 38 more entries between,
		[[...]],
		[[...]],
	},
} :: any

The amount of entries in the Data array is variable, the files output by CoffeEncoder encoder part are always 10 or less MB. The project is not yet Open-Source as I’m still testing it.

More info (Hopefully this helps resolve the bug)! Data around 0.38 MB can stay and the type checker won’t break. Later when I had roughly about 22 MB of Data the type checker broke again, I decided to try deleting the scripts that hold the data, that worked and the type checker has fixed itself.

Hello again! Would you mind testing if you’re still running into this bug? We’ve just rolled out a fix that should help with memory consumption here.

Hello, thanks for coming back to this, I really appreciate you keeping an eye on it!

I’ve tested it out and the bug still persists because of the big data scripts. Deleting and importing them back is what helps re-alive the type solver and autocomplete in the cases where this is caused by the big data scripts.

I’ve also discovered this bug may happen for two further reasons, in those cases deleting the big data scripts does nothing, because it wasn’t the first to cause the bug. i.e. the type-checker got broken for a different reason so it won’t even reach the big data.


The first reason for this has to do with the string type.

The first reason for this has to do with Go to Declaration (Ctrl+click) on a variable that holds a function value.

I first ran into it with the Reaction package. Its Reaction.V<T> is declared as V<T>(val: T | any): V<T>, so V("Hello World") is always inferred as V<unknown>, no matter how the string is written ("", '', ` ` or [[]]). To get V<string> I typecast the argument, V("Hello World" :: string).

Steps:

  1. Paste one of the snippets below into a ModuleScript.
  2. Check that autocomplete works.
  3. Hold Ctrl and click the source variable where it’s used (StringSource inside the table t, or NumberSource inside print).

Expected result: the cursor jumps to the variable’s declaration.

Actual result: the cursor stays where it is, and the type solver and autocomplete die across all scripts, the same way they did with the big data scripts. The place won’t close afterwards, so Studio has to be killed with Alt+F4. There were no big data scripts in the place while I made these reproductions. (Each reproduction was tested in a brand new place created using image)

Using the Reaction package:

--!strict
--!optimize 2

const Reaction = require(`./Packages/Reaction`)
const V, O, Copy, rmV, ifV, fiV = Reaction:Unpack()

const StringSource = V("Hello World" :: string)

const t = {
	Text = StringSource,
}

The same thing without the package, with V copied in with the same signature:

--!strict

type V<T> = (T?) -> T

const function V<T>(val: T | any): V<T>
	return function(...)
		if select(`#`, ...) > 0 then
			val = select(1, ...)
		end
		return val
	end
end

const StringSource = V("Hello World" :: string)

const t = {
	Text = StringSource,
}

return nil

Through further attempts I found that removing the | any part makes the typecast unnecessary: V("Hello World") is then correctly inferred as V<string>. It also turns out the typecast isn’t what causes the trouble. It was only needed because of Reaction’s T | any, and the reproduction breaks without any cast. It doesn’t need a table either: using the variable in a print call is enough. It isn’t specific to string at all, since a number breaks it the same way. The smallest reproduction I’ve got:

--!strict

type V<T> = (T?) -> T

const function V<T>(val: T): V<T>
	return function(...)
		if select(`#`, ...) > 0 then
			val = select(1, ...)
		end
		return val
	end
end

const NumberSource = V(5)

print(NumberSource)

return nil

As far as I can tell, this is the same bug as with the big data scripts. The symptoms are identical: autocomplete stops showing up, out-of-place type errors appear, Ctrl+Click stops working, and the place won’t close until Studio is killed with Alt+F4. The difference is that this one can be triggered on purpose in a few seconds, in a brand new place, with a 20-line script, while the big data case takes 30 to 60 minutes of editing.
That should make this reproduction much easier to debug: whatever leaves the type solver stuck here is likely the same thing that leaves it stuck with the big data scripts and possibly with ClassNameTypePairs (read below). Tracking down where it happens with this snippet could fix all three cases at once.


The second possible reason may be that Coffilhg/CreateInstanceReaction uses Coffilhg/ClassNameTypePairs

(ClassNameTypePairs is a huge list of all ClassNames as types to be used in type functions), so frequent use of it may overwhelm the type-solver. I think, that is partially on my side, so I started working on Coffilhg/ClassNameTypePairsClientInGameCreatable (the list that contains only the ClassNames that can be created using Instance.new(ClassName), Client-Side, In-Game) - so that’s solved, as long as this list (roughly 63% smaller) doesn’t overwhelm the type-solver. This reason is not confirmed as I do not have a 100% working reproduction ready for it.

That example you provided is interesting! I can confirm that’s a bug and it seems like the fix is pretty straightforward on our end.