CommonLoadingScreen.HoldLoadingScreenAdditionalSecs
CommonLoadingScreen.HoldLoadingScreenAdditionalSecs
#Overview
name: CommonLoadingScreen.HoldLoadingScreenAdditionalSecs
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
How long to hold the loading screen up after other loading finishes (in seconds) to try to give texture streaming a chance to avoid blurriness
It is referenced in 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of CommonLoadingScreen.HoldLoadingScreenAdditionalSecs is to control how long the loading screen is displayed after other loading processes have finished. This additional time is intended to allow texture streaming to complete, reducing the likelihood of blurry textures when the game world is first revealed.
This setting variable is primarily used by the CommonLoadingScreen plugin, which is part of the loading screen management system in Unreal Engine 5. It’s specifically utilized within the LoadingScreenManager module.
The value of this variable is set in multiple places:
- It has a default value of 2.0 seconds in the UCommonLoadingScreenSettings class.
- It can be modified through the Unreal Engine’s configuration system, as indicated by the ‘config’ specifier in the UPROPERTY macro.
- It can be changed at runtime via a console variable, as shown by the FAutoConsoleVariableRef setup.
The associated variable HoldLoadingScreenAdditionalSecs interacts closely with this setting. They share the same value and purpose, with the associated variable being used directly in the code logic.
Developers should be aware of the following:
- This setting affects gameplay experience, as it introduces a delay before dismissing the loading screen.
- It’s not normally applied in the editor for faster iteration, but can be enabled using the HoldLoadingScreenAdditionalSecsEvenInEditor flag.
- The actual hold time may be 0 in the editor unless explicitly enabled.
Best practices for using this variable include:
- Adjust the value based on the specific needs of your game, considering factors like texture complexity and streaming requirements.
- Use the console variable for quick testing and tuning during development.
- Consider enabling it in the editor when working on loading screen visuals or testing the full loading experience.
- Monitor its impact on user experience, balancing between reducing texture pop-in and minimizing perceived loading times.
Regarding the associated variable HoldLoadingScreenAdditionalSecs: This variable serves the same purpose as the setting variable, acting as a runtime representation of the configured value. It’s used directly in the LoadingScreenManager’s logic to determine how long to keep the loading screen visible after other loading processes have completed. The best practices and considerations for its use are essentially the same as for the setting variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/CommonLoadingScreenSettings.h:35
Scope (from outer to inner):
file
class class UCommonLoadingScreenSettings : public UDeveloperSettingsBackedByCVars
Source code excerpt:
// Note: This is not normally applied in the editor for iteration time, but can be
// enabled via HoldLoadingScreenAdditionalSecsEvenInEditor
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s, ConsoleVariable="CommonLoadingScreen.HoldLoadingScreenAdditionalSecs"))
float HoldLoadingScreenAdditionalSecs = 2.0f;
// The interval in seconds beyond which the loading screen is considered permanently hung (if non-zero).
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s))
float LoadingScreenHeartbeatHangDuration = 0.0f;
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp:71
Scope (from outer to inner):
file
namespace LoadingScreenCVars
Source code excerpt:
static float HoldLoadingScreenAdditionalSecs = 2.0f;
static FAutoConsoleVariableRef CVarHoldLoadingScreenUpAtLeastThisLongInSecs(
TEXT("CommonLoadingScreen.HoldLoadingScreenAdditionalSecs"),
HoldLoadingScreenAdditionalSecs,
TEXT("How long to hold the loading screen up after other loading finishes (in seconds) to try to give texture streaming a chance to avoid blurriness"),
ECVF_Default | ECVF_Preview);
static bool LogLoadingScreenReasonEveryFrame = false;
static FAutoConsoleVariableRef CVarLogLoadingScreenReasonEveryFrame(
#Associated Variable and Callsites
This variable is associated with another variable named HoldLoadingScreenAdditionalSecs
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/CommonLoadingScreenSettings.h:33
Scope (from outer to inner):
file
class class UCommonLoadingScreenSettings : public UDeveloperSettingsBackedByCVars
Source code excerpt:
// try to give texture streaming a chance to avoid blurriness
//
// Note: This is not normally applied in the editor for iteration time, but can be
// enabled via HoldLoadingScreenAdditionalSecsEvenInEditor
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s, ConsoleVariable="CommonLoadingScreen.HoldLoadingScreenAdditionalSecs"))
float HoldLoadingScreenAdditionalSecs = 2.0f;
// The interval in seconds beyond which the loading screen is considered permanently hung (if non-zero).
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s))
float LoadingScreenHeartbeatHangDuration = 0.0f;
// The interval in seconds between each log of what is keeping a loading screen up (if non-zero).
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s))
float LogLoadingScreenHeartbeatInterval = 5.0f;
// When true, the reason the loading screen is shown or hidden will be printed to the log every frame.
UPROPERTY(Transient, EditAnywhere, Category=Debugging, meta=(ConsoleVariable="CommonLoadingScreen.LogLoadingScreenReasonEveryFrame"))
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/CommonLoadingScreenSettings.h:51
Scope (from outer to inner):
file
class class UCommonLoadingScreenSettings : public UDeveloperSettingsBackedByCVars
Source code excerpt:
// Force the loading screen to be displayed (useful for debugging)
UPROPERTY(Transient, EditAnywhere, Category=Debugging, meta=(ConsoleVariable="CommonLoadingScreen.AlwaysShow"))
bool ForceLoadingScreenVisible = false;
// Should we apply the additional HoldLoadingScreenAdditionalSecs delay even in the editor
// (useful when iterating on loading screens)
UPROPERTY(Transient, EditAnywhere, Category=Debugging)
bool HoldLoadingScreenAdditionalSecsEvenInEditor = false;
// Should we apply the additional HoldLoadingScreenAdditionalSecs delay even in the editor
// (useful when iterating on loading screens)
UPROPERTY(config, EditAnywhere, Category=Configuration)
bool ForceTickLoadingScreenEvenInEditor = true;
};
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp:66
Scope (from outer to inner):
file
namespace LoadingScreenCVars
Source code excerpt:
//////////////////////////////////////////////////////////////////////
namespace LoadingScreenCVars
{
// CVars
static float HoldLoadingScreenAdditionalSecs = 2.0f;
static FAutoConsoleVariableRef CVarHoldLoadingScreenUpAtLeastThisLongInSecs(
TEXT("CommonLoadingScreen.HoldLoadingScreenAdditionalSecs"),
HoldLoadingScreenAdditionalSecs,
TEXT("How long to hold the loading screen up after other loading finishes (in seconds) to try to give texture streaming a chance to avoid blurriness"),
ECVF_Default | ECVF_Preview);
static bool LogLoadingScreenReasonEveryFrame = false;
static FAutoConsoleVariableRef CVarLogLoadingScreenReasonEveryFrame(
TEXT("CommonLoadingScreen.LogLoadingScreenReasonEveryFrame"),
LogLoadingScreenReasonEveryFrame,
TEXT("When true, the reason the loading screen is shown or hidden will be printed to the log every frame."),
ECVF_Default);
static bool ForceLoadingScreenVisible = false;
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp:421
Scope (from outer to inner):
file
function bool ULoadingScreenManager::ShouldShowLoadingScreen
Source code excerpt:
const double CurrentTime = FPlatformTime::Seconds();
const bool bCanHoldLoadingScreen = (!GIsEditor || Settings->HoldLoadingScreenAdditionalSecsEvenInEditor);
const double HoldLoadingScreenAdditionalSecs = bCanHoldLoadingScreen ? LoadingScreenCVars::HoldLoadingScreenAdditionalSecs : 0.0;
if (TimeLoadingScreenLastDismissed < 0.0)
{
TimeLoadingScreenLastDismissed = CurrentTime;
}
const double TimeSinceScreenDismissed = CurrentTime - TimeLoadingScreenLastDismissed;
// hold for an extra X seconds, to cover up streaming
if ((HoldLoadingScreenAdditionalSecs > 0.0) && (TimeSinceScreenDismissed < HoldLoadingScreenAdditionalSecs))
{
// Make sure we're rendering the world at this point, so that textures will actually stream in
//@TODO: If bNeedToShowLoadingScreen bounces back true during this window, we won't turn this off again...
UGameViewportClient* GameViewportClient = GetGameInstance()->GetGameViewportClient();
GameViewportClient->bDisableWorldRendering = false;
DebugReasonForShowingOrHidingLoadingScreen = FString::Printf(TEXT("Keeping loading screen up for an additional %.2f seconds to allow texture streaming"), HoldLoadingScreenAdditionalSecs);
bWantToForceShowLoadingScreen = true;
}
}
return bNeedToShowLoadingScreen || bWantToForceShowLoadingScreen;
}
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/CommonLoadingScreenSettings.h:33
Scope (from outer to inner):
file
class class UCommonLoadingScreenSettings : public UDeveloperSettingsBackedByCVars
Source code excerpt:
// try to give texture streaming a chance to avoid blurriness
//
// Note: This is not normally applied in the editor for iteration time, but can be
// enabled via HoldLoadingScreenAdditionalSecsEvenInEditor
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s, ConsoleVariable="CommonLoadingScreen.HoldLoadingScreenAdditionalSecs"))
float HoldLoadingScreenAdditionalSecs = 2.0f;
// The interval in seconds beyond which the loading screen is considered permanently hung (if non-zero).
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s))
float LoadingScreenHeartbeatHangDuration = 0.0f;
// The interval in seconds between each log of what is keeping a loading screen up (if non-zero).
UPROPERTY(config, EditAnywhere, Category=Configuration, meta=(ForceUnits=s))
float LogLoadingScreenHeartbeatInterval = 5.0f;
// When true, the reason the loading screen is shown or hidden will be printed to the log every frame.
UPROPERTY(Transient, EditAnywhere, Category=Debugging, meta=(ConsoleVariable="CommonLoadingScreen.LogLoadingScreenReasonEveryFrame"))
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/CommonLoadingScreenSettings.h:51
Scope (from outer to inner):
file
class class UCommonLoadingScreenSettings : public UDeveloperSettingsBackedByCVars
Source code excerpt:
// Force the loading screen to be displayed (useful for debugging)
UPROPERTY(Transient, EditAnywhere, Category=Debugging, meta=(ConsoleVariable="CommonLoadingScreen.AlwaysShow"))
bool ForceLoadingScreenVisible = false;
// Should we apply the additional HoldLoadingScreenAdditionalSecs delay even in the editor
// (useful when iterating on loading screens)
UPROPERTY(Transient, EditAnywhere, Category=Debugging)
bool HoldLoadingScreenAdditionalSecsEvenInEditor = false;
// Should we apply the additional HoldLoadingScreenAdditionalSecs delay even in the editor
// (useful when iterating on loading screens)
UPROPERTY(config, EditAnywhere, Category=Configuration)
bool ForceTickLoadingScreenEvenInEditor = true;
};
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp:66
Scope (from outer to inner):
file
namespace LoadingScreenCVars
Source code excerpt:
//////////////////////////////////////////////////////////////////////
namespace LoadingScreenCVars
{
// CVars
static float HoldLoadingScreenAdditionalSecs = 2.0f;
static FAutoConsoleVariableRef CVarHoldLoadingScreenUpAtLeastThisLongInSecs(
TEXT("CommonLoadingScreen.HoldLoadingScreenAdditionalSecs"),
HoldLoadingScreenAdditionalSecs,
TEXT("How long to hold the loading screen up after other loading finishes (in seconds) to try to give texture streaming a chance to avoid blurriness"),
ECVF_Default | ECVF_Preview);
static bool LogLoadingScreenReasonEveryFrame = false;
static FAutoConsoleVariableRef CVarLogLoadingScreenReasonEveryFrame(
TEXT("CommonLoadingScreen.LogLoadingScreenReasonEveryFrame"),
LogLoadingScreenReasonEveryFrame,
TEXT("When true, the reason the loading screen is shown or hidden will be printed to the log every frame."),
ECVF_Default);
static bool ForceLoadingScreenVisible = false;
#Loc: <Workspace>/Projects/Lyra/Plugins/CommonLoadingScreen/Source/CommonLoadingScreen/Private/LoadingScreenManager.cpp:421
Scope (from outer to inner):
file
function bool ULoadingScreenManager::ShouldShowLoadingScreen
Source code excerpt:
else
{
// Don't *need* to show the screen anymore, but might still want to for a bit
const double CurrentTime = FPlatformTime::Seconds();
const bool bCanHoldLoadingScreen = (!GIsEditor || Settings->HoldLoadingScreenAdditionalSecsEvenInEditor);
const double HoldLoadingScreenAdditionalSecs = bCanHoldLoadingScreen ? LoadingScreenCVars::HoldLoadingScreenAdditionalSecs : 0.0;
if (TimeLoadingScreenLastDismissed < 0.0)
{
TimeLoadingScreenLastDismissed = CurrentTime;
}
const double TimeSinceScreenDismissed = CurrentTime - TimeLoadingScreenLastDismissed;
// hold for an extra X seconds, to cover up streaming
if ((HoldLoadingScreenAdditionalSecs > 0.0) && (TimeSinceScreenDismissed < HoldLoadingScreenAdditionalSecs))
{
// Make sure we're rendering the world at this point, so that textures will actually stream in
//@TODO: If bNeedToShowLoadingScreen bounces back true during this window, we won't turn this off again...
UGameViewportClient* GameViewportClient = GetGameInstance()->GetGameViewportClient();
GameViewportClient->bDisableWorldRendering = false;
DebugReasonForShowingOrHidingLoadingScreen = FString::Printf(TEXT("Keeping loading screen up for an additional %.2f seconds to allow texture streaming"), HoldLoadingScreenAdditionalSecs);
bWantToForceShowLoadingScreen = true;
}
}
return bNeedToShowLoadingScreen || bWantToForceShowLoadingScreen;
}
bool ULoadingScreenManager::IsShowingInitialLoadingScreen() const
{
FPreLoadScreenManager* PreLoadScreenManager = FPreLoadScreenManager::Get();
return (PreLoadScreenManager != nullptr) && PreLoadScreenManager->HasValidActivePreLoadScreen();