Slate.AllowSlateToSleep
Slate.AllowSlateToSleep
#Overview
name: Slate.AllowSlateToSleep
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether Slate should go to sleep when there are no active timers and the user is idle
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.AllowSlateToSleep is to control whether the Slate UI framework should enter a sleep state when there are no active timers and the user is idle. This setting is part of Unreal Engine’s UI performance optimization system.
This setting variable is primarily used by the Slate subsystem, which is part of Unreal Engine’s UI framework. Based on the callsites, it’s clear that this variable is used within the SlateApplication module, specifically in the TickAndDrawWidgets function.
The value of this variable is set using a TAutoConsoleVariable, which means it can be changed at runtime through console commands. By default, it’s set to GIsEditor, which means it’s on for the editor and standalone programs, but off for games.
This variable interacts closely with other variables and systems:
- It’s used in conjunction with bAnyActiveTimersPending and bIsUserIdle to determine if Slate should sleep.
- It’s also considered alongside bSynthesizedCursorMove and FApp::UseVRFocus() in the sleep decision process.
Developers must be aware that:
- This setting can significantly impact UI performance and responsiveness.
- It behaves differently in editor/standalone mode versus in-game.
- VR applications might have different requirements for this setting.
Best practices when using this variable include:
- In game builds, consider the performance implications of enabling this feature.
- For editor and tools, it’s generally beneficial to keep this enabled for better performance.
- When developing VR applications, pay special attention to how this setting interacts with VR focus.
Regarding the associated variable AllowSlateToSleep, it appears to be the same variable. The two references you’ve provided are actually defining the same TAutoConsoleVariable. This variable is used to expose the Slate.AllowSlateToSleep setting to the console, allowing it to be changed at runtime. The same considerations and best practices apply to this variable as it is effectively the same as Slate.AllowSlateToSleep.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:556
Scope: file
Source code excerpt:
/** Whether Slate should go to sleep when there are no active timers and the user is idle */
TAutoConsoleVariable<int32> AllowSlateToSleep(
TEXT("Slate.AllowSlateToSleep"),
GIsEditor, // Default to on for editor and standalone programs, off for games
TEXT("Whether Slate should go to sleep when there are no active timers and the user is idle"));
/** The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers). */
TAutoConsoleVariable<float> SleepBufferPostInput(
TEXT("Slate.SleepBufferPostInput"),
#Associated Variable and Callsites
This variable is associated with another variable named AllowSlateToSleep
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:555
Scope: file
Source code excerpt:
/** Whether Slate should go to sleep when there are no active timers and the user is idle */
TAutoConsoleVariable<int32> AllowSlateToSleep(
TEXT("Slate.AllowSlateToSleep"),
GIsEditor, // Default to on for editor and standalone programs, off for games
TEXT("Whether Slate should go to sleep when there are no active timers and the user is idle"));
/** The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers). */
TAutoConsoleVariable<float> SleepBufferPostInput(
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:1676
Scope (from outer to inner):
file
function void FSlateApplication::TickAndDrawWidgets
Source code excerpt:
// when the user is not providing any input (ie, animations, viewport rendering, async polling, etc).
bIsSlateAsleep = true;
if (!AllowSlateToSleep.GetValueOnGameThread() || bAnyActiveTimersPending || !bIsUserIdle || bSynthesizedCursorMove || FApp::UseVRFocus())
{
if (!bSynthesizedCursorMove)
{
ForEachUser([](FSlateUser& User) { User.QueueSyntheticCursorMove(); });
}