[RESOLVED] Severe crash bug: InsertService

Today was a good day! Here’s my story:

A bug has been a plaguing my game since late 2011. I had no single clue what it was, people would just lose connection and get the “Lost connection from server” message after roughly 1 minute. After viewing the game page, it appeared that the entire server just crashed! My game quickly lost popularity, my inbox was being spammed with hundreds of the same complaints.

Over the last month, I decided to battle the impossible. Fix a bug that doesn’t leave any traces. Eventually I found the cause (or at least I’m 95% sure what it was)! My game uses the InsertService to import vehicles and spawn them for the players. I changed the code so it would only import the models once at the start and then take clones to spawn the models. This solved the impossible!

My thesis is that the InsertService (and more specific: the function LoadAsset()) has a chance of 1 in 1000 of fatally crash the running game server! I never managed to reproduce the bug in Studio → test server, but since I changed the insert code and tested on-line with 16 people, it didn’t crash any more!

Here’s a quick fill-in of the details:

  1. Does the bug happen 100% of the time? Yes, when constantly using the LoadAsset function.
  2. If so, are there steps that reproduce the bug? I assume the LoadAsset function is not entirely stable.
  3. Where does the bug happen (www, gametest, etc) Normal on-line game server.
  4. Is it level-specific? Specific to using the InsertService. Tested and proven that it’s not asset-specific.
  5. Would a screenshot or video help describe it to someone? No, the story should be clear, else please ask for more information.
  6. For graphics bugs, it is sometimes helpful to know your system specs, especially graphics card. Not applicable.
  7. When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke. I think since December 2011, when according to the wiki, the InsertService has had its last update.
  8. Anything else that you would want to know about the bug if it were your job to find and fix it. Probably something in the LoadAsset function might throw an uncaught exception and escalates, eventually crashing the server-side of the game session.

Please be aware of this bug, It doesn’t occur often, but is very severe!

1 Like

Maybe it was an issue with the cache?

It seems most of the crashes for this place are caused by spending huge script time when parts are replicated to the server.

Whenever parts are replicated over the network, usual ChildAdded events are fired in the process of adding them to Workspace. Looks like your scripts do a lot of work there, so much that processing one single network packet can take several minutes. We kill server in this condition.

Try doing less work in global Added events.
Any chance you clone or create big models in Local Scripts?

Since today, I import my models using InsertService only once at the start of the game (using a server-side script).
These models contain about 62 to 135 bricks, is this a lot for network operations?

This same script also contains a global function which clones a requested model (one of the initially imported ones above) and returns it. This global function is called by a server-side script in a GUI (Because Local Scripts don’t work well with _G) which then inserts the loaded model into Workspace.

So most cloning and creating happens on server-side scripts. I assume this is the right way?

I appreciate that you take the effort to help me with this, please don’t bother to ask me more. :wink:

Coming back on this topic as it is still unresolved.

Is it advised to clone models using LocalScripts or normal Scripts?

A lot of scripts are controlling the world in my game, this may explain why a handfull of people are frequently disconnected. Also, I use clone() with normal scripts I don’t really see any problems but just incase I try to make all the models that are cloned into workspace under 40 parts.

[quote] Coming back on this topic as it is still unresolved.

Is it advised to clone models using LocalScripts or normal Scripts? [/quote]

Definitely normal Scripts (also known as Game Scripts)

Thank you Simon for being so helpful. This forum was a good decision! :cheer:

Now that I have a sense of heading, I will do my best to resolve the bug.

Bug resolved, thanks for all the help.

Out of curiosity, how did you end up resolving your bug?

The trucks have a custom driving system controlled by a GUI. It used to clone the GUI and put a new copy inside the PlayerGui every time a player sits on the seat.

The bug was solved by changing the code so the GUI would just change parent when a player sits on the seat.