Slate.EnableFastWidgetPath

Slate.EnableFastWidgetPath

#Overview

name: Slate.EnableFastWidgetPath

This variable is created as a Console Variable (cvar).

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.EnableFastWidgetPath is to enable a faster method for finding widget paths in the Slate UI framework. This setting is primarily used in the Slate rendering and layout system.

The Slate subsystem within Unreal Engine relies on this setting variable. It’s particularly used in the SlateCore module, as seen in the callsites from SlateCore’s source files.

The value of this variable is initially set to false and can be toggled via a console command. In the SSlateApplication::Create() function, it’s set to true for non-editor builds by default.

This variable directly interacts with GSlateFastWidgetPath, which is the actual boolean variable used throughout the code to check if fast widget pathing is enabled.

Developers must be aware that enabling this feature relies on parent pointers to work correctly. It’s disabled by default in the editor due to its complexity and potential edge cases.

Best practices when using this variable include:

  1. Be cautious when enabling it in the editor environment.
  2. Ensure all parent-child relationships in your UI widgets are correctly set up.
  3. Test thoroughly after enabling to ensure no unexpected behavior in your UI.

Regarding the associated variable GSlateFastWidgetPath:

The purpose of GSlateFastWidgetPath is to serve as the actual boolean flag that controls whether fast widget pathing is enabled.

It’s used across various parts of the SlateCore module, including widget path resolution, application ticking, and trace logging.

The value is set based on the Slate.EnableFastWidgetPath console variable, and it’s also directly set to false for editor builds in the SSlateApplication::Create() function.

This variable interacts closely with other Slate system variables like GSlateEnableGlobalInvalidation and is used in conjunction with them to control Slate’s behavior.

Developers should be aware that this variable affects the performance and behavior of widget path resolution in Slate. Enabling it may improve performance but could lead to unexpected results if widget hierarchies are not properly maintained.

Best practices include:

  1. Ensuring all parent-child relationships in widgets are correctly set up when this is enabled.
  2. Using this in conjunction with profiling tools to verify performance improvements.
  3. Thoroughly testing UI behavior when toggling this setting, especially for complex UI layouts.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/SlateCoreClasses.cpp:37

Scope: file

Source code excerpt:


FAutoConsoleVariableRef CVarSlateFastWidgetPath(
	TEXT("Slate.EnableFastWidgetPath"),
	GSlateFastWidgetPath,
	TEXT("Whether or not we enable fast widget pathing.  This mode relies on parent pointers to work correctly.")
);


bool GSlateEnableGlobalInvalidation = false;

#Loc: <Workspace>/Engine/Source/Developer/SlateReflector/Private/Widgets/SSlateOptions.cpp:58

Scope (from outer to inner):

file
function     void SSlateOptions::Construct
function     static TSharedRef<SWidget> FillToolbar

Source code excerpt:

			FSlateIcon Icon(FWidgetReflectorStyle::GetStyleSetName(), "Icon.Empty");

			AddMenuEntry(MenuBuilder, Icon, LOCTEXT("EnableFastWidgetPath", "Fast Widget Path"), TEXT("Slate.EnableFastWidgetPath"), false);
			AddMenuEntry(MenuBuilder, Icon, LOCTEXT("EnableToolTips", "Enable Tooltips"), TEXT("Slate.EnableTooltips"));
			AddMenuEntry(MenuBuilder, Icon, LOCTEXT("GlobalInvalidation", "Global Invalidation"), TEXT("Slate.EnableGlobalInvalidation"));
			AddMenuEntry(MenuBuilder, Icon, LOCTEXT("DisabledEffect", "Transparent Disabled Effect"), TEXT("Slate.ApplyDisabledEffectOnWidgets"));

			return MenuBuilder.MakeWidget();
		}

#Associated Variable and Callsites

This variable is associated with another variable named GSlateFastWidgetPath. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:714

Scope (from outer to inner):

file
function     void FSlateApplication::Create

Source code excerpt:

void FSlateApplication::Create()
{
	GSlateFastWidgetPath = GIsEditor ? false : true;

	Create(MakeShareable(FPlatformApplicationMisc::CreateApplication()));
}

TSharedRef<FSlateApplication> FSlateApplication::Create(const TSharedRef<class GenericApplication>& InPlatformApplication)
{

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Application/SlateWindowHelper.cpp:94

Scope (from outer to inner):

file
function     bool FSlateWindowHelper::FindPathToWidget

Source code excerpt:

	SCOPE_CYCLE_COUNTER(STAT_FindPathToWidget);

	if (GSlateFastWidgetPath)
	{
		// We have to internally cast this anyway - because the constructed widget path will be of non-const widgets, so if you'll end up with
		// a mutable copy anyway.
		TSharedPtr<SWidget> CurWidget = ConstCastSharedRef<SWidget>(InWidget);
		OutWidgetPath.Widgets.SetFilter(VisibilityFilter);
		while (true)

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Layout/WidgetPath.cpp:300

Scope (from outer to inner):

file
function     FWeakWidgetPath::EPathResolutionResult::Result FWeakWidgetPath::ToWidgetPath

Source code excerpt:

	}

	if (GSlateFastWidgetPath)
	{
		TArray<FWidgetAndPointer> PathWithGeometries;

		// The path can get interrupted if some subtree of widgets disappeared, but we still maintain weak references to it.
		bool bPathUninterrupted = false;

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/SlateCoreClasses.cpp:34

Scope: file

Source code excerpt:

// Enable fast widget paths outside the editor by default.  Only reason we don't enable them everywhere
// is that the editor is more complex than a game, and there are likely a larger swath of edge cases.
bool GSlateFastWidgetPath = false;

FAutoConsoleVariableRef CVarSlateFastWidgetPath(
	TEXT("Slate.EnableFastWidgetPath"),
	GSlateFastWidgetPath,
	TEXT("Whether or not we enable fast widget pathing.  This mode relies on parent pointers to work correctly.")
);


bool GSlateEnableGlobalInvalidation = false;
static FAutoConsoleVariableRef CVarSlateNewUpdateMethod(

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Trace/SlateTrace.cpp:313

Scope (from outer to inner):

file
function     void FSlateTrace::ApplicationTickAndDrawWidgets

Source code excerpt:

		ESlateTraceApplicationFlags LocalFlags = ESlateTraceApplicationFlags::None;
		if (GSlateEnableGlobalInvalidation) { LocalFlags |= ESlateTraceApplicationFlags::GlobalInvalidation; }
		if (GSlateFastWidgetPath) { LocalFlags |= ESlateTraceApplicationFlags::FastWidgetPath; }

		UE_TRACE_LOG(SlateTrace, ApplicationTickAndDrawWidgets, SlateChannel)
			<< ApplicationTickAndDrawWidgets.Cycle(FPlatformTime::Cycles64())
			<< ApplicationTickAndDrawWidgets.DeltaTime(DeltaTime)
			<< ApplicationTickAndDrawWidgets.WidgetCount(SlateTraceDetail::GWidgetCount)
			<< ApplicationTickAndDrawWidgets.TickCount(SlateTraceDetail::GFrameTickCount)

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Public/SlateGlobals.h:60

Scope: file

Source code excerpt:


/** Whether or not we've enabled fast widget pathing which validates paths to widgets without arranging children. */
extern SLATECORE_API bool GSlateFastWidgetPath;

/** Whether or not the SWindow can be an Invalidation Panel (use the fast path update). Normal Invalidation Panel will be deactivated. */
extern SLATECORE_API bool GSlateEnableGlobalInvalidation;

/** Whether or not we currently Painting/Updating the widget from the FastUpdate path (global invalidation). */
extern SLATECORE_API bool GSlateIsOnFastUpdatePath;