I have been struggling with that issue for so long already thus decided to finally look into that.
I personally use packages to insert scripts into the game and track changes. Since I’ve started using them, editing long scripts became super painful. Each time I type something I have to wait a few seconds for the studio to update script. The same issue happens to the camera, but under different circumstances.
Scripts
Noticed the issue happens when the script has more descendants. I hold the script in ServerScriptService.
In the microprofiler field called “Legacy Lock” causes that.
Dump: microprofile-20200512-115648.html (8.2 MB)
Camera
There are lag spikes when using (moving) a camera and many having models under package which would be in the field of view (They are not visible since the package is parented to ServerScriptService, but if it was parented to the Workspace, they would be visible).
Seems to be issue around “Write Marshalled”.
Dump: microprofile-20200512-115358.html (7.2 MB)
System Specs:
Windows 10 Home OS (x64)
Intel Core i7-7700HQ (x64)
24 GB RAM
NVidia GTX 1050
I don’t have the issue of constant lag in the script editor but Studio does lag spike whenever selecting any item in the Explorer while the Script Editor is open, which it might be a highlight issue since it seems like the entire editor refreshes its colors. The only way for me to fix this is to restart Studio, but it happens quite quickly so I’m having to restart multiple times per day.
The camera lag is probably the most annoying issue as it completely takes out any enjoyment in building, so I’m having to edit in a separate place to avoid it.
My game also has many packages too like yours does.
Here’s a pic of the microprofiler when moving the camera around. (FPS drops to ~15)
And when clicking something in Explorer while in the Script Editor or opening up a script after being in Studio for a few hours…
If you need microprofiler logs I’d be happy to send them in a private DM.
I believe I have found the source of this, at least for me. Let me know if it helps any of you.
So apparently if you have a pretty big package with BillboardGuis in it and Enabled is true, then you will have some very hard lag when moving your camera around in Studio. I am not 100% sure if this is the true cause, as it seems like the lag went away if I either …
Removed most of the instances in the Package (there are 2,000, once it starts to drop below 300-600 the performance will start to be better)
Changed the ‘Enabled’ property of all BillboardGuis to false.
In my case, I had these packages which were storing player armor and about 250 tools under ReplicatedStorage. Moving this to Workspace did not help the issue. I am sure this is 100% an issue with only packages and not BillboardGuis/high count instances in RS in general, because when I disconnected the instance from the package (By pressing Delete over a PackageLink), all of the lag completely went away.