CanUseUnversionedPropertySerialization

CanUseUnversionedPropertySerialization

#Overview

name: CanUseUnversionedPropertySerialization

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CanUseUnversionedPropertySerialization is to determine whether the unversioned property serialization feature can be used in the current context or for a specific target platform. This setting is primarily related to the serialization system within Unreal Engine 5.

CanUseUnversionedPropertySerialization is primarily used in the CoreUObject module, specifically within the serialization subsystem. It affects how properties are serialized and deserialized, particularly for struct data.

The value of this variable is set in the engine configuration file (GEngineIni) under the “Core.System” section. It can be retrieved using the GConfig->GetBool() function or directly from a specific config file using FConfigFile::GetBool().

This variable interacts with other serialization-related functions and systems, such as SerializeUnversionedProperties and FUnversionedHeader. It’s also used in conjunction with platform-specific settings, particularly for server-only configurations.

Developers must be aware that this setting can affect the compatibility and performance of serialized data. Enabling unversioned property serialization may improve performance but could potentially cause issues with backward compatibility if not managed carefully.

Best practices when using this variable include:

  1. Ensure that all target platforms have consistent settings for this variable to avoid unexpected behavior.
  2. When working with serialized data across different engine versions, be cautious about enabling or disabling this feature, as it may affect data compatibility.
  3. Consider the implications on server-only configurations, as there’s a separate check for server-only scenarios.
  4. Use the provided functions (CanUseUnversionedPropertySerialization) to check the status of this setting rather than accessing the configuration directly, as it ensures consistent behavior across the engine.
  5. Be aware of this setting when debugging serialization issues, as it can significantly affect how property data is stored and retrieved.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1439, section: [Core.System]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/UnversionedPropertySerialization.cpp:797

Scope (from outer to inner):

file
function     static bool CanUseUnversionedPropertySerialization

Source code excerpt:

};

static bool CanUseUnversionedPropertySerialization()
{
	bool bTemp;
	static bool bAllow = GConfig->GetBool(TEXT("Core.System"), TEXT("CanUseUnversionedPropertySerialization"), bTemp, GEngineIni) && bTemp;
	return bAllow;
}

static bool CanUseUnversionedPropertySerialization(FConfigFile& TargetIni)
{
	bool bAllow;
	return TargetIni.GetBool(TEXT("Core.System"), TEXT("CanUseUnversionedPropertySerialization"), /* out */ bAllow) && bAllow;
}

static bool CanUseUnversionedPropertySerializationForServerOnly(FConfigFile& TargetIni)

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/UnversionedPropertySerialization.cpp:823

Scope (from outer to inner):

file
function     bool CanUseUnversionedPropertySerialization

Source code excerpt:

GUPSIniValueCache;

bool CanUseUnversionedPropertySerialization(const ITargetPlatform* Target)
{
	if (!Target)
	{
		// Use current platform settings
		return CanUseUnversionedPropertySerialization();
	}

	const bool bIsServerOnly = Target->IsServerOnly();
	const int32 IsServerOnlyBit = bIsServerOnly << 31;
	const int32 TargetID = IsServerOnlyBit | Target->GetPlatformOrdinal();

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/UnversionedPropertySerialization.cpp:844

Scope (from outer to inner):

file
function     bool CanUseUnversionedPropertySerialization

Source code excerpt:

	FConfigFile TargetIni;
	FConfigCacheIni::LoadLocalIniFile(TargetIni, TEXT("Engine"), /* base INI */ true, *Target->IniPlatformName());
	bool bTargetValue = CanUseUnversionedPropertySerialization(TargetIni);
	if (bIsServerOnly)
	{
		bTargetValue = bTargetValue && CanUseUnversionedPropertySerializationForServerOnly(TargetIni);
	}

			

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/UnversionedPropertySerialization.cpp:881

Scope (from outer to inner):

file
function     void SerializeUnversionedProperties

Source code excerpt:

	if (UnderlyingArchive.IsLoading())
	{
		check(CanUseUnversionedPropertySerialization());

		FUnversionedHeader Header;
		Header.Load(StructRecord.EnterStream(TEXT("Header")));

		if (Header.HasValues())
		{

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/UnversionedPropertySerialization.h:7

Scope: file

Source code excerpt:


// Check if unversioned property serialization is configured to be used on target platform
bool CanUseUnversionedPropertySerialization(const ITargetPlatform* Target);

// Serialize sparse unversioned properties for a particular struct
void SerializeUnversionedProperties(const UStruct* Struct, FStructuredArchive::FSlot Slot, uint8* Data, UStruct* DefaultsStruct, uint8* Defaults);

void DestroyUnversionedSchema(const UStruct* Struct);

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/UObject/SavePackage/SaveContext.h:470

Scope (from outer to inner):

file
class        class FSaveContext
function     FSaveContext

Source code excerpt:

		}

		bCanUseUnversionedPropertySerialization = CanUseUnversionedPropertySerialization(SaveArgs.GetTargetPlatform());
		bTextFormat = FString(Filename).EndsWith(FPackageName::GetTextAssetPackageExtension()) || FString(Filename).EndsWith(FPackageName::GetTextMapPackageExtension());
		static const IConsoleVariable* ProcessPrestreamingRequests = IConsoleManager::Get().FindConsoleVariable(TEXT("s.ProcessPrestreamingRequests"));
		if (ProcessPrestreamingRequests)
		{
			bIsProcessingPrestreamPackages = ProcessPrestreamingRequests->GetInt() > 0;
		}