demo.ForceDisableAsyncPackageMapLoading

demo.ForceDisableAsyncPackageMapLoading

#Overview

name: demo.ForceDisableAsyncPackageMapLoading

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of demo.ForceDisableAsyncPackageMapLoading is to control the asynchronous loading of network assets during demo playback in Unreal Engine 5. This setting variable is primarily used in the demo recording and playback system.

This setting variable is relied upon by the Engine module, specifically within the DemoNetDriver subsystem. The DemoNetDriver is responsible for recording and playing back game sessions, which is crucial for features like replays and spectator modes.

The value of this variable is set through a console variable (CVar) system. It’s defined as a static TAutoConsoleVariable, which means it can be changed at runtime through console commands or configuration files.

The main variable that interacts with demo.ForceDisableAsyncPackageMapLoading is CVarForceDisableAsyncPackageMapLoading. They are essentially the same variable, with demo.ForceDisableAsyncPackageMapLoading being the console-accessible name.

Developers must be aware that enabling this variable (setting it to a value greater than 0) will disable asynchronous loading of network assets during demo playback. This can have performance implications, potentially causing hitches or longer load times, but may be useful for debugging or in specific scenarios where synchronous loading is preferred.

Best practices when using this variable include:

  1. Leaving it disabled (set to 0) for normal operation to benefit from asynchronous loading.
  2. Only enabling it when necessary for debugging or specific use cases.
  3. Testing thoroughly with both settings to ensure your game performs well in both scenarios.
  4. Being aware of the potential performance impact when enabling this setting.

Regarding the associated variable CVarForceDisableAsyncPackageMapLoading:

The purpose of CVarForceDisableAsyncPackageMapLoading is the same as demo.ForceDisableAsyncPackageMapLoading. It’s the actual C++ variable that controls the behavior of asynchronous package map loading.

This variable is used directly in the UDemoNetDriver class, specifically in the InitConnect and TickDemoPlayback functions. When its value is greater than 0, it sets the GuidCache’s async load mode to ForceDisable. Otherwise, it uses the default CVar-based behavior.

The value of this variable is set through the console variable system, just like demo.ForceDisableAsyncPackageMapLoading.

No other variables directly interact with CVarForceDisableAsyncPackageMapLoading, but it does affect the behavior of the GuidCache object.

Developers should be aware that this variable directly impacts the NetGUICache’s async loading behavior, which can affect network performance and asset loading during demo playback.

Best practices for using CVarForceDisableAsyncPackageMapLoading are the same as those for demo.ForceDisableAsyncPackageMapLoading, as they are essentially the same variable.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

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." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));
static TAutoConsoleVariable<int32> CVarDemoFastForwardIgnoreRPCs( TEXT( "demo.FastForwardIgnoreRPCs" ), 1, TEXT( "If true, RPCs will be discarded during playback fast forward." ) );
static TAutoConsoleVariable<int32> CVarDemoLateActorDormancyCheck(TEXT("demo.LateActorDormancyCheck"), 1, TEXT("If true, check if an actor should become dormant as late as possible- when serializing it to the demo archive."));

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

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." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));
static TAutoConsoleVariable<int32> CVarDemoFastForwardIgnoreRPCs( TEXT( "demo.FastForwardIgnoreRPCs" ), 1, TEXT( "If true, RPCs will be discarded during playback fast forward." ) );
static TAutoConsoleVariable<int32> CVarDemoLateActorDormancyCheck(TEXT("demo.LateActorDormancyCheck"), 1, TEXT("If true, check if an actor should become dormant as late as possible- when serializing it to the demo archive."));

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

Scope (from outer to inner):

file
function     bool UDemoNetDriver::InitConnect

Source code excerpt:

	GuidCache->SetNetworkChecksumMode(FNetGUIDCache::ENetworkChecksumMode::SaveButIgnore);

	if (CVarForceDisableAsyncPackageMapLoading.GetValueOnGameThread() > 0)
	{
		GuidCache->SetAsyncLoadMode(FNetGUIDCache::EAsyncLoadMode::ForceDisable);
	}
	else
	{
		GuidCache->SetAsyncLoadMode(FNetGUIDCache::EAsyncLoadMode::UseCVar);

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

Scope (from outer to inner):

file
function     void UDemoNetDriver::TickDemoPlayback

Source code excerpt:

	}

	if (CVarForceDisableAsyncPackageMapLoading.GetValueOnGameThread() > 0)
	{
		GuidCache->SetAsyncLoadMode(FNetGUIDCache::EAsyncLoadMode::ForceDisable);
	}
	else
	{
		GuidCache->SetAsyncLoadMode(FNetGUIDCache::EAsyncLoadMode::UseCVar);