tick.SecondsBeforeEmbeddedAppSleeps

tick.SecondsBeforeEmbeddedAppSleeps

#Overview

name: tick.SecondsBeforeEmbeddedAppSleeps

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of tick.SecondsBeforeEmbeddedAppSleeps is to control the behavior of embedded applications in Unreal Engine, specifically determining how long the engine should run before allowing the embedded application to sleep.

This setting variable is primarily used in the Launch module of Unreal Engine, as evidenced by its presence in the LaunchEngineLoop.cpp file. It’s particularly relevant for embedded applications, which are typically resource-constrained environments where efficient power management is crucial.

The value of this variable is set using a TAutoConsoleVariable, which allows it to be modified at runtime through console commands. Its default value is set to 1 second.

The associated variable CVarSecondsBeforeEmbeddedAppSleeps interacts directly with tick.SecondsBeforeEmbeddedAppSleeps. They share the same value and purpose, with CVarSecondsBeforeEmbeddedAppSleeps being the C++ variable that holds and provides access to the value set by tick.SecondsBeforeEmbeddedAppSleeps.

Developers must be aware that this variable affects the performance and power consumption of embedded applications. Setting it too low might cause frequent sleep cycles, potentially impacting performance, while setting it too high might waste power by keeping the application active unnecessarily.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of the embedded application.
  2. Monitoring its impact on performance and power consumption.
  3. Using it in conjunction with other embedded-specific optimizations.

Regarding the associated variable CVarSecondsBeforeEmbeddedAppSleeps:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:333

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSecondsBeforeEmbeddedAppSleeps(
	TEXT("tick.SecondsBeforeEmbeddedAppSleeps"),
	1,
	TEXT("When built as embedded, how many ticks to perform before sleeping")
);

/** Task that executes concurrently with Slate when tick.DoAsyncEndOfFrameTasks is true. */
class FExecuteConcurrentWithSlateTickTask

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:332

Scope: file

Source code excerpt:

	);

static TAutoConsoleVariable<float> CVarSecondsBeforeEmbeddedAppSleeps(
	TEXT("tick.SecondsBeforeEmbeddedAppSleeps"),
	1,
	TEXT("When built as embedded, how many ticks to perform before sleeping")
);

/** Task that executes concurrently with Slate when tick.DoAsyncEndOfFrameTasks is true. */

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:6229

Scope: file

Source code excerpt:

	static double LastSleepTime = FPlatformTime::Seconds();
	double TimeNow = FPlatformTime::Seconds();
	if (LastSleepTime > 0 && TimeNow - LastSleepTime >= CVarSecondsBeforeEmbeddedAppSleeps.GetValueOnAnyThread())
	{
		LastSleepTime = 0;
		FEmbeddedCommunication::AllowSleep(TEXT("FirstTicks"));
	}
#endif
}