Serialization.LoadFromTrailer
Serialization.LoadFromTrailer
#Overview
name: Serialization.LoadFromTrailer
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When true FEditorBulkData will load payloads via the package trailer rather than the package itself
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Serialization.LoadFromTrailer is to control how FEditorBulkData loads payloads in Unreal Engine 5. Specifically, when set to true, it instructs FEditorBulkData to load payloads via the package trailer rather than the package itself.
This setting variable is primarily used in the serialization system of Unreal Engine, particularly within the CoreUObject module. It affects how bulk data is loaded and managed, which is crucial for efficient handling of large data sets in the engine.
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.
This variable interacts closely with other serialization-related variables, such as Serialization.AllowSidecarSyncing. It’s also associated with CVarShouldLoadFromTrailer, which is the C++ variable that directly controls this behavior in the code.
Developers must be aware that changing this setting can significantly impact how bulk data is loaded in the engine. When set to true, it changes the data loading mechanism from the main package file to the package trailer. This can affect performance and memory usage, especially for projects with large amounts of bulk data.
Best practices when using this variable include:
- Testing thoroughly when changing its value, as it can affect the entire serialization process.
- Considering the impact on load times and memory usage.
- Using it in conjunction with other serialization settings for optimal performance.
- Documenting any changes to this setting in project configuration to ensure consistency across the development team.
Regarding the associated variable CVarShouldLoadFromTrailer:
The purpose of CVarShouldLoadFromTrailer is to provide a programmatic way to control the Serialization.LoadFromTrailer setting within C++ code.
This variable is used directly in the CoreUObject module, specifically in the FEditorBulkData class. It’s checked in methods like LoadFromDisk and LocationMatches to determine how bulk data should be loaded or compared.
The value of CVarShouldLoadFromTrailer is set when the Serialization.LoadFromTrailer console variable is initialized or changed.
CVarShouldLoadFromTrailer interacts with other variables like CVarShouldLoadFromSidecar, influencing the decision-making process for bulk data loading.
Developers should be aware that this variable directly affects the behavior of FEditorBulkData methods. Changes to this variable will immediately impact how bulk data is handled in the engine.
Best practices for using CVarShouldLoadFromTrailer include:
- Using GetValueOnAnyThread() when accessing its value to ensure thread-safety.
- Considering the performance implications of frequently checking this variable in performance-critical code paths.
- Using it in conjunction with IsStoredInPackageTrailer() for more granular control over bulk data loading behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/EditorBulkData.cpp:59
Scope (from outer to inner):
file
namespace UE::Serialization
Source code excerpt:
*/
static TAutoConsoleVariable<bool> CVarShouldLoadFromTrailer(
TEXT("Serialization.LoadFromTrailer"),
false,
TEXT("When true FEditorBulkData will load payloads via the package trailer rather than the package itself"));
static TAutoConsoleVariable<bool> CVarShouldAllowSidecarSyncing(
TEXT("Serialization.AllowSidecarSyncing"),
false,
#Associated Variable and Callsites
This variable is associated with another variable named CVarShouldLoadFromTrailer
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/EditorBulkData.cpp:58
Scope (from outer to inner):
file
namespace UE::Serialization
Source code excerpt:
* using the in built OffsetInFile member to load from the package file directly.
*/
static TAutoConsoleVariable<bool> CVarShouldLoadFromTrailer(
TEXT("Serialization.LoadFromTrailer"),
false,
TEXT("When true FEditorBulkData will load payloads via the package trailer rather than the package itself"));
static TAutoConsoleVariable<bool> CVarShouldAllowSidecarSyncing(
TEXT("Serialization.AllowSidecarSyncing"),
#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/EditorBulkData.cpp:1320
Scope (from outer to inner):
file
namespace UE::Serialization
function FCompressedBuffer FEditorBulkData::LoadFromDisk
Source code excerpt:
else
{
if (CVarShouldLoadFromTrailer.GetValueOnAnyThread() && IsStoredInPackageTrailer())
{
return LoadFromPackageTrailer();
}
else
{
return LoadFromPackageFile();
#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/Serialization/EditorBulkData.cpp:2169
Scope (from outer to inner):
file
namespace UE::Serialization
function bool FEditorBulkData::LocationMatches
Source code excerpt:
}
if ((HasPayloadSidecarFile() && CVarShouldLoadFromSidecar.GetValueOnAnyThread()) ||
CVarShouldLoadFromTrailer.GetValueOnAnyThread())
{
// Loading from the SidecarFile or PackageTrailer uses the PayloadContentId as
// the identifier to look up the location in the file
return PayloadContentId == Other.PayloadContentId;
}
else