RelevantTimeout

RelevantTimeout

#Overview

name: RelevantTimeout

The value of this variable can be defined or overridden in .ini config files. 3 .ini config files referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of RelevantTimeout is to manage the relevancy of actors in networked gameplay within Unreal Engine 5. It is primarily used in the networking system to determine how long an actor should be considered relevant after its last update.

This setting variable is utilized by the Unreal Engine’s networking subsystem, specifically within the NetDriver and DemoNetDriver modules. It’s also used in the OnlineSubsystemOculus plugin, indicating its importance in various networking scenarios, including VR applications.

The value of RelevantTimeout is typically set in configuration files, as indicated by the UPROPERTY(Config) decorator in the NetDriver.h file. If not set, it defaults to 5.0 seconds in both the OculusNetDriver and DemoNetDriver.

RelevantTimeout interacts with other variables such as LastNetUpdateTimestamp, RelevantTime, and ElapsedTime to determine an actor’s relevancy status.

Developers must be aware that this variable directly affects network performance and gameplay experience. A too-short timeout might cause actors to become irrelevant too quickly, while a too-long timeout could unnecessarily increase network traffic.

Best practices when using this variable include:

  1. Carefully tuning the value based on the specific needs of your game to balance network performance and gameplay smoothness.
  2. Monitoring its impact on network traffic and adjusting as necessary.
  3. Considering different timeout values for different types of actors or game modes.
  4. Ensuring it’s properly set in configuration files to avoid unexpected behavior.
  5. Being cautious when modifying it at runtime, as it could affect ongoing network communications.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1637, section: [/Script/OnlineSubsystemUtils.IpNetDriver]

Location: <Workspace>/Engine/Config/BaseEngine.ini:2264, section: [/Script/SteamSockets.SteamSocketsNetDriver]

Location: <Workspace>/Engine/Plugins/Experimental/WebSocketNetworking/Config/BaseWebSocketNetDriver.ini:17, section: [/Script/WebSocketNetworking.WebSocketNetDriver]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemOculus/Source/Private/OculusNetDriver.cpp:70

Scope (from outer to inner):

file
function     bool UOculusNetDriver::InitBase

Source code excerpt:

	}

	if (RelevantTimeout == 0.0)
	{
		UE_LOG(LogNet, Warning, TEXT("RelevantTimeout was set to %f"), RelevantTimeout);
		RelevantTimeout = 5.0;
	}

	if (ServerTravelPause == 0.0)
	{
		UE_LOG(LogNet, Warning, TEXT("ServerTravelPause was set to %f"), ServerTravelPause);
		ServerTravelPause = 4.0;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/NetDriver.h:886

Scope (from outer to inner):

file
class        class UNetDriver : public UObject, public FExec

Source code excerpt:

	/** @todo document */
	UPROPERTY(Config)
	float RelevantTimeout;

	/** @todo document */
	UPROPERTY(Config)
	float KeepAliveTime;

	/** Amount of time to wait for a new net connection to be established before destroying the connection */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:869

Scope (from outer to inner):

file
function     bool UDemoNetDriver::InitBase

Source code excerpt:

		RecordDestructionInfoReplicationTimeSlice = DemoNetDriverRecordingPrivate::CVarDemoMaximumRecDestructionInfoTime.GetValueOnAnyThread();

		if (RelevantTimeout == 0.0f)
		{
			RelevantTimeout = 5.0f;
		}

		ResetDemoState();

		if (URL.HasOption(TEXT("MaxDesiredReplayRecordTimeMS")))
		{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:2020

Scope (from outer to inner):

file
function     void UDemoNetDriver::TickDemoRecordFrame

Source code excerpt:


					// We check ActorInfo->LastNetUpdateTime < KINDA_SMALL_NUMBER to force at least one update for each actor
					const bool bWasRecentlyRelevant = (ActorInfo->LastNetUpdateTimestamp < UE_KINDA_SMALL_NUMBER) || ((GetElapsedTime() - ActorInfo->LastNetUpdateTimestamp) < RelevantTimeout);

					bool bIsRelevant = !bUseNetRelevancy || Actor->bAlwaysRelevant || Actor == ClientConnection->PlayerController || (ActorInfo->ForceRelevantFrame >= ReplicationFrame);

					if (!bIsRelevant)
					{
						// Assume this actor is relevant as long as *any* viewer says so

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:5180

Scope (from outer to inner):

file
function     int32 UNetDriver::ServerReplicateActors_PrioritizeActors

Source code excerpt:

					// NOTE - We won't close the channel if any connection has a NULL view target.
					//	This is to give all connections a chance to own it
					if ( !bHasNullViewTarget && Channel != NULL && ElapsedTime - Channel->RelevantTime >= RelevantTimeout )
					{
						Channel->Close(EChannelCloseReason::Relevancy);
					}

					// This connection doesn't own this actor
					continue;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:5343

Scope (from outer to inner):

file
function     int32 UNetDriver::ServerReplicateActors_ProcessPrioritizedActorsRange

Source code excerpt:


			// if the actor is now relevant or was recently relevant
			const bool bIsRecentlyRelevant = bIsRelevant || ( Channel && ElapsedTime - Channel->RelevantTime < RelevantTimeout ) || (ActorInfo->ForceRelevantFrame >= Connection->LastProcessedFrame);

			if ( bIsRecentlyRelevant )
			{
				FinalRelevantCount++;

				TOptional<FScopedActorRoleSwap> SwapGuard;