Godot Version
Godot 4.4
Question
After updating my game from 4.3 to 4.4, LoadThreadRequest occassionally stalls while trying to load a large scene. I’ve had it get stuck at 50%, 83%, etc…
However, it occasionally just works, which makes this whole situation a lot more complicated to debug. This doesn’t seem to happen on small simple scenes.
Has this happened to anybody else after updating to 4.4 and does anybody know a fix?
This is my code if needed:
private void StartLoad(bool syncLoad)
{
if(syncLoad)
{
waitingForSyncLoad = true;
announcedSuccessfulLoad = false;
syncLoadConfirmation = 0;
}
Error state = ResourceLoader.LoadThreadedRequest(incomingScenePath, "", useSubThread);
if(state == Error.Ok)
{
loadingScreen.SetLoadingScreenStatus(true);
GD.Print("=====================================================================");
GD.Print("Attempting to load the following scene: " + incomingScenePath);
GD.Print("=====================================================================");
SetProcess(true);
}
}
public override void _Process(double delta)
{
ResourceLoader.ThreadLoadStatus status = ResourceLoader.LoadThreadedGetStatus(incomingScenePath, progress);
if((int) status == 0 || (int) status == 2) // Load Fail.
{
GD.Print("=====================================================================");
GD.Print("ERROR: Failed to load the following scene: " + incomingScenePath);
GD.Print(status);
GD.Print("=====================================================================");
loadingScreen.SetLoadingScreenStatus(false);
SetProcess(false);
return;
}
else if((int) status == 1) // Loading...
{
GD.Print("LOADING: " + (float) progress[0] * 100f + "%");
}
else if((int) status == 3) // Load Success!
{
if(waitingForSyncLoad)
{
if(!announcedSuccessfulLoad)
{
Rpc("LoadConfirmation");
announcedSuccessfulLoad = true;
syncLoadConfirmation++;
GD.Print("Load was succesful!");
GD.Print("Waiting for all players to load...");
}
else
{
if(MultiplayerManager.instance.GetClientLobby().Count <= syncLoadConfirmation)
{
GD.Print("=====================================================================");
GD.Print("Switching to the following scene: " + incomingScenePath);
GD.Print("=====================================================================");
PackedScene scene = (PackedScene)ResourceLoader.LoadThreadedGet(incomingScenePath);
GetTree().ChangeSceneToPacked(scene);
loadingScreen.SetLoadingScreenStatus(false);
SetProcess(false);
}
}
}
else
{
GD.Print("=====================================================================");
GD.Print("Switching to the following scene: " + incomingScenePath);
GD.Print("=====================================================================");
PackedScene scene = (PackedScene)ResourceLoader.LoadThreadedGet(incomingScenePath);
GetTree().ChangeSceneToPacked(scene);
loadingScreen.SetLoadingScreenStatus(false);
SetProcess(false);
}
}
}
[Rpc(MultiplayerApi.RpcMode.AnyPeer, TransferMode = MultiplayerPeer.TransferModeEnum.Reliable)]
private void LoadConfirmation()
{
syncLoadConfirmation++;
}