demo.AsyncLoadWorld

demo.AsyncLoadWorld

#Overview

name: demo.AsyncLoadWorld

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 demo.AsyncLoadWorld is to control asynchronous loading of the replay world in Unreal Engine’s demo system. This setting variable is part of the networking and replay functionality of the engine.

This setting variable is primarily used by the DemoNetDriver subsystem, which is responsible for handling network demo recordings and playback in Unreal Engine. It’s defined in the Engine module, specifically in the DemoNetDriver.cpp file.

The value of this variable is set as a console variable (CVarDemoAsyncLoadWorld) with a default value of 0. It can be changed at runtime through console commands or programmatically.

The main variable that interacts with demo.AsyncLoadWorld is CVarDemoAsyncLoadWorld, which is the actual TAutoConsoleVariable that stores and provides access to the setting’s value.

Developers should be aware that:

  1. When set to 1, the engine will use seamless server travel to load the replay world asynchronously.
  2. The value can be overridden via a command-line option “AsyncLoadWorldOverride”.
  3. This setting affects the behavior of the InitConnectInternal function in the UDemoNetDriver class.

Best practices when using this variable include:

  1. Consider the performance implications of asynchronous world loading in your specific use case.
  2. Use the command-line override option for testing different configurations without changing the code.
  3. Be aware of potential interactions with other async loading settings in the engine.

Regarding the associated variable CVarDemoAsyncLoadWorld:

The purpose of CVarDemoAsyncLoadWorld is to provide a programmatic interface to the demo.AsyncLoadWorld setting. It’s the actual TAutoConsoleVariable that stores and manages the value of the setting.

This variable is used directly in the DemoNetDriver subsystem to determine whether to use asynchronous world loading for replays.

The value is set when the console variable is initialized, but can be changed at runtime using console commands or programmatically using the SetValueOnGameThread method.

CVarDemoAsyncLoadWorld interacts closely with the demo.AsyncLoadWorld setting, effectively serving as its storage and access mechanism.

Developers should be aware that:

  1. This is a static variable, so its value is shared across all instances of the game.
  2. It’s an int32 type, typically used as a boolean (0 for false, non-zero for true).

Best practices for using CVarDemoAsyncLoadWorld include:

  1. Use GetValueOnGameThread() to safely read the current value.
  2. Consider using this variable for runtime checks rather than the raw console variable name.
  3. Be cautious about changing this value during gameplay, as it could affect ongoing demo playback or recording.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static TAutoConsoleVariable<int32> CVarDemoQueueCheckpointChannels( TEXT( "demo.QueueCheckpointChannels" ), 1, TEXT( "If true, the driver will put all channels created during checkpoint loading into queuing mode, to amortize the cost of spawning new actors across multiple frames." ) );
static TAutoConsoleVariable<int32> CVarUseAdaptiveReplayUpdateFrequency( TEXT( "demo.UseAdaptiveReplayUpdateFrequency" ), 1, TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay" ) );
static TAutoConsoleVariable<int32> CVarDemoAsyncLoadWorld( TEXT( "demo.AsyncLoadWorld" ), 0, TEXT( "If 1, we will use seamless server travel to load the replay world asynchronously" ) );
TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds( TEXT( "demo.CheckpointUploadDelayInSeconds" ), 30.0f, TEXT( "" ) );
static TAutoConsoleVariable<int32> CVarDemoLoadCheckpointGarbageCollect( TEXT( "demo.LoadCheckpointGarbageCollect" ), 1, TEXT("If nonzero, CollectGarbage will be called during LoadCheckpoint after the old actors and connection are cleaned up." ) );
TAutoConsoleVariable<float> CVarCheckpointSaveMaxMSPerFrameOverride( TEXT( "demo.CheckpointSaveMaxMSPerFrameOverride" ), -1.0f, TEXT( "If >= 0, this value will override the CheckpointSaveMaxMSPerFrame member variable, which is the maximum time allowed each frame to spend on saving a checkpoint. If 0, it will save the checkpoint in a single frame, regardless of how long it takes." ) );
TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame( TEXT( "demo.ClientRecordAsyncEndOfFrame" ), 0, TEXT( "If true, TickFlush will be called on a thread in parallel with Slate." ) );
static TAutoConsoleVariable<int32> CVarForceDisableAsyncPackageMapLoading( TEXT( "demo.ForceDisableAsyncPackageMapLoading" ), 0, TEXT( "If true, async package map loading of network assets will be disabled." ) );
TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

static TAutoConsoleVariable<int32> CVarDemoQueueCheckpointChannels( TEXT( "demo.QueueCheckpointChannels" ), 1, TEXT( "If true, the driver will put all channels created during checkpoint loading into queuing mode, to amortize the cost of spawning new actors across multiple frames." ) );
static TAutoConsoleVariable<int32> CVarUseAdaptiveReplayUpdateFrequency( TEXT( "demo.UseAdaptiveReplayUpdateFrequency" ), 1, TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay" ) );
static TAutoConsoleVariable<int32> CVarDemoAsyncLoadWorld( TEXT( "demo.AsyncLoadWorld" ), 0, TEXT( "If 1, we will use seamless server travel to load the replay world asynchronously" ) );
TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds( TEXT( "demo.CheckpointUploadDelayInSeconds" ), 30.0f, TEXT( "" ) );
static TAutoConsoleVariable<int32> CVarDemoLoadCheckpointGarbageCollect( TEXT( "demo.LoadCheckpointGarbageCollect" ), 1, TEXT("If nonzero, CollectGarbage will be called during LoadCheckpoint after the old actors and connection are cleaned up." ) );
TAutoConsoleVariable<float> CVarCheckpointSaveMaxMSPerFrameOverride( TEXT( "demo.CheckpointSaveMaxMSPerFrameOverride" ), -1.0f, TEXT( "If >= 0, this value will override the CheckpointSaveMaxMSPerFrame member variable, which is the maximum time allowed each frame to spend on saving a checkpoint. If 0, it will save the checkpoint in a single frame, regardless of how long it takes." ) );
TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame( TEXT( "demo.ClientRecordAsyncEndOfFrame" ), 0, TEXT( "If true, TickFlush will be called on a thread in parallel with Slate." ) );
static TAutoConsoleVariable<int32> CVarForceDisableAsyncPackageMapLoading( TEXT( "demo.ForceDisableAsyncPackageMapLoading" ), 0, TEXT( "If true, async package map loading of network assets will be disabled." ) );
TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );

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

Scope (from outer to inner):

file
function     bool UDemoNetDriver::InitConnectInternal

Source code excerpt:

	
	// Default async world loading to the cvar value...
	bool bAsyncLoadWorld = CVarDemoAsyncLoadWorld.GetValueOnGameThread() > 0;

	// ...but allow it to be overridden via a command-line option.
	const TCHAR* const AsyncLoadWorldOverrideOption = ReplayHelper.DemoURL.GetOption(TEXT("AsyncLoadWorldOverride="), nullptr);
	if (AsyncLoadWorldOverrideOption)
	{
		bAsyncLoadWorld = FCString::ToBool(AsyncLoadWorldOverrideOption);