StarterPlayerScripts sometimes appears to not replicate, breaking our client scripts

StarterPlayerScripts seems to not replicate sometimes

In the past few days I have had two reports of the UI not loading, accompanied by the following error (or similar errors)

Infinite yield possible on 'StarterPlayer:WaitForChild("StarterPlayerScripts")'
Stack Begin
Script 'CoreGui.RobloxGui.Modules.Settings.SettingsHub', Line 1161 - function getOverridesPlayerScripts
Script 'CoreGui.RobloxGui.Modules.Settings.SettingsHub', Line 1223 
Stack End

Here is an example stack.

I suspect this issue is not caused by CoreScripts misbehaving, but rather the core scripts also fail to execute the StarterPlayerScripts as they don’t get replicated.

Volume of Infinite Yield Errors

Here are the volume of any error related to InfiniteYield, of which this issue is only one (most are bits on the player’s character.) However, those infinite yields do not break the game as they execute in EventHandlers, so theoretically it should allow the UI code to work as normal.

Other Posts on DevForum

The most similar other report I found on the DevForum is this particular issue from from @Randy_Moss and their game Last To Leave, which had an extremely similar stack trace.
image

Replication Attempts

I have never seen this bug despite playing my game many times a day. I will attempt to use a link conditioner to worsen my network conditions (increase ping, packet loss, reduce speed, etc.) to reproduce this if it is related to the network.

Hypotheses

I think this could be a few things:

  1. The size of our game. We keep our StarterPlayerScripts folder very light, so I’m not sure why that isn’t replicating. One possibility is that our ReplicatedStorage is huge and that we reference ReplicatedStorage scripts from StarterPlayerScripts. If StarterPlayerScripts didn’t replicate with priority versus ReplicatedStorage (or there was some kind of implicit dependency), it might be taking a while to replicate that and that would block other code from running. However, we don’t see infinite yield warnings on the ReplicatedStorage dependencies, so the logs don’t support the hypothesis that the starter player scripts are running, but just waiting on ReplicatedStorage.
  2. Bad network conditions cause this. From the screenshot above, you can see that the average ping was 609ms for the affected user. We were on opposite sides of the planet, and so perhaps being on a server very far away geographically contributes to this.
  3. Some bug with replication or CoreScripts. I don’t think this is the primary cause but could be contributing to it.

Potential ways to further investigate this

I need more metrics on this to investigate. I’m thinking about putting a script in ReplicatedFirst which will time when StarterPlayerScripts replicates and logs some more information, so we can try and deduce patterns. If there are any debugging utilities we can turn on to help figure this out, please let me know!

Thanks for your help in investigating this issue!

Expected behavior

StarterPlayerScripts should replicate and run very quickly, or at least provide an informative error message about why they don’t.

A private message is associated with this bug report

1 Like

Actually, my bad, we figured it out. Upon further investigation, it was a race condition in the following form:

  1. We introduced a loading screen.
  2. When the loading screen determines it should disappear, it fires a BindableEvent which is listened to by our UI client code.
  3. Our loading code didn’t wait for the replication of the UI related code in ReplicatedStorage, so it fired before the client code started to listen to it.
  4. The BindableEvent listener would enable the main ScreenGui which was initially disabled. However, because it started listening after the loading event fired, the event was never received and the GUI was never instantiated.

The fix was to remove the BindableEvent and alter the DisplayOrder of the loading ScreenGui and main ScreenGui to not have the main GUI paint over the loading screen GUI.

If you are seeing a similar error and having issues replicating it, it might be a race condition too.

2 Likes

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