UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AsyncPackageLoader.cpp File Reference

Classes

class  FEarlyRegistrationEventsRecorder
 
struct  FTrackAsyncLoadRequests
 
struct  FTrackAsyncLoadRequests::FUserData
 
struct  FTrackAsyncLoadRequests::FUserData::FLoadRequest
 

Macros

#define DO_TRACK_ASYNC_LOAD_REQUESTS   (!UE_BUILD_SHIPPING && !UE_BUILD_TEST)
 

Functions

bool IsNativeCodePackage (UPackage *Package)
 
bool CanPostLoadOnAsyncLoadingThread (UObject *Object)
 
IAsyncPackageLoaderGetAsyncPackageLoader ()
 
void SetAsyncLoadingAllowed (bool bAllowAsyncLoading)
 
void InitAsyncThread ()
 
void ShutdownAsyncThread ()
 
bool IsInAsyncLoadingThreadCoreUObjectInternal ()
 
void FlushAsyncLoading (int32 RequestId)
 
void FlushAsyncLoading (TConstArrayView< int32 > RequestIds)
 
EAsyncPackageState::Type ProcessAsyncLoadingUntilComplete (TFunctionRef< bool()> CompletionPredicate, double TimeLimit)
 
int32 GetNumAsyncPackages ()
 
EAsyncPackageState::Type ProcessAsyncLoading (bool bUseTimeLimit, bool bUseFullTimeLimit, double TimeLimit)
 
bool IsAsyncLoadingCoreUObjectInternal ()
 
bool IsAsyncLoadingMultithreadedCoreUObjectInternal ()
 
ELoaderType GetLoaderTypeInternal ()
 
void SuspendAsyncLoadingInternal ()
 
void ResumeAsyncLoadingInternal ()
 
bool IsAsyncLoadingSuspendedInternal ()
 
bool ShouldAlwaysLoadPackageAsync (const FPackagePath &InPackagePath)
 
int32 LoadPackageAsync (const FPackagePath &InPackagePath, FLoadPackageAsyncOptionalParams InOptionalParams)
 
int32 LoadPackageAsync (const FPackagePath &InPackagePath, FName InPackageNameToCreate, FLoadPackageAsyncDelegate InCompletionDelegate, EPackageFlags InPackageFlags, int32 InPIEInstanceID, int32 InPackagePriority, const FLinkerInstancingContext *InstancingContext, uint32 LoadFlags)
 
int32 LoadPackageAsync (const FString &InName, const FGuid *InGuid)
 
int32 LoadPackageAsync (const FString &InName, FLoadPackageAsyncDelegate CompletionDelegate, int32 InPackagePriority, EPackageFlags InPackageFlags, int32 InPIEInstanceID)
 
int32 LoadPackageAsync (const FString &InName, FLoadPackageAsyncOptionalParams InOptionalParams)
 
int32 LoadPackageAsync (const FString &InName, const FGuid *InGuid, const TCHAR *InPackageToLoadFrom, FLoadPackageAsyncDelegate InCompletionDelegate, EPackageFlags InPackageFlags, int32 InPIEInstanceID, int32 InPackagePriority, const FLinkerInstancingContext *InstancingContext)
 
void CancelAsyncLoading ()
 
float GetAsyncLoadPercentage (const FName &PackageName)
 
void NotifyRegistrationEvent (FName PackageName, FName Name, ENotifyRegistrationType NotifyRegistrationType, ENotifyRegistrationPhase NotifyRegistrationPhase, UObject *(*InRegister)(), bool InbDynamic, UObject *FinishedObject)
 
void NotifyScriptVersePackage (Verse::VPackage *Package)
 
void NotifyRegistrationComplete ()
 
void NotifyUnreachableObjects (const TArrayView< FUObjectItem * > &UnreachableObjects)
 
void ResetAsyncLoadingStats ()
 
void IsTimeLimitExceededPrint (double InTickStartTime, double CurrentTime, double LastTestTime, double InTimeLimit, const TCHAR *InLastTypeOfWorkPerformed, UObject *InLastObjectWorkWasPerformedOn)
 

Variables

volatile int32 GIsLoaderCreated
 
TUniquePtr< IAsyncPackageLoaderGPackageLoader
 
bool GAsyncLoadingAllowed = true
 
bool GIoDispatcherInitializedByLoader = false
 
const FName PrestreamPackageClassNameLoad = FName("PrestreamPackage")
 
double GFlushAsyncLoadingTime = 0.0
 
uint32 GFlushAsyncLoadingCount = 0
 
uint32 GSyncLoadCount = 0
 
int32 GWarnIfTimeLimitExceeded = 0
 
float GTimeLimitExceededMultiplier = 1.5f
 
float GTimeLimitExceededMinTime = 0.005f
 

Macro Definition Documentation

◆ DO_TRACK_ASYNC_LOAD_REQUESTS

#define DO_TRACK_ASYNC_LOAD_REQUESTS   (!UE_BUILD_SHIPPING && !UE_BUILD_TEST)

Function Documentation

◆ CancelAsyncLoading()

void CancelAsyncLoading ( )

Cancels all async package loading requests.

◆ CanPostLoadOnAsyncLoadingThread()

bool CanPostLoadOnAsyncLoadingThread ( UObject Object)

Checks if the object can have PostLoad called on the Async Loading Thread

◆ FlushAsyncLoading() [1/2]

void FlushAsyncLoading ( int32  PackageID = INDEX_NONE)

Blocks till all pending package/ linker requests are fulfilled.

Parameters
PackageIDif the package associated with this request ID gets loaded, FlushAsyncLoading returns immediately without waiting for the remaining packages to finish loading.

◆ FlushAsyncLoading() [2/2]

void FlushAsyncLoading ( TConstArrayView< int32 RequestIds)

Blocks till a set of pending async load requests are complete.

Parameters
RequestIdslist of return values from LoadPackageAsync to wait for. An empty list means all requests

◆ GetAsyncLoadPercentage()

float GetAsyncLoadPercentage ( const FName PackageName)

Returns the async load percentage for a package in flight with the passed in name or -1 if there isn't one.

Warning
THIS IS SLOW. MAY BLOCK ASYNC LOADING.
Parameters
PackageNameName of package to query load percentage for
Returns
Async load percentage if package is currently being loaded, -1 otherwise

◆ GetAsyncPackageLoader()

IAsyncPackageLoader & GetAsyncPackageLoader ( )

◆ GetLoaderTypeInternal()

ELoaderType GetLoaderTypeInternal ( )

◆ GetNumAsyncPackages()

int32 GetNumAsyncPackages ( )

Return number of active async load package requests

◆ InitAsyncThread()

void InitAsyncThread ( )

ThreadIndex =

◆ IsAsyncLoadingCoreUObjectInternal()

bool IsAsyncLoadingCoreUObjectInternal ( )

◆ IsAsyncLoadingMultithreadedCoreUObjectInternal()

bool IsAsyncLoadingMultithreadedCoreUObjectInternal ( )

◆ IsAsyncLoadingSuspendedInternal()

bool IsAsyncLoadingSuspendedInternal ( )

◆ IsInAsyncLoadingThreadCoreUObjectInternal()

bool IsInAsyncLoadingThreadCoreUObjectInternal ( )

◆ IsNativeCodePackage()

bool IsNativeCodePackage ( UPackage Package)

◆ IsTimeLimitExceededPrint()

void IsTimeLimitExceededPrint ( double  InTickStartTime,
double  CurrentTime,
double  LastTestTime,
double  InTimeLimit,
const TCHAR InLastTypeOfWorkPerformed,
UObject InLastObjectWorkWasPerformedOn 
)

◆ LoadPackageAsync() [1/6]

int32 LoadPackageAsync ( const FPackagePath InPackagePath,
FLoadPackageAsyncOptionalParams  InOptionalParams 
)

Asynchronously load a package and all contained objects that match context flags. Non-blocking. Use this version to specify the PackagePath rather than having the other versions internally convert the InName to a PackagePath by searching the current package mount points. Use this version if you need to specify a packagename that is different from the packagename on disk; this is useful when loading multiple copies of the same package.

Parameters
InPackagePathPackagePath to load. Must be a mounted path. The package is created if it does not already exist.
InOptionalParamsOptional parameters.
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

◆ LoadPackageAsync() [2/6]

int32 LoadPackageAsync ( const FPackagePath InPackagePath,
FName  InPackageNameToCreate = NAME_None,
FLoadPackageAsyncDelegate  InCompletionDelegate = FLoadPackageAsyncDelegate(),
EPackageFlags  InPackageFlags = PKG_None,
int32  InPIEInstanceID = INDEX_NONE,
TAsyncLoadPriority  InPackagePriority = 0,
const FLinkerInstancingContext InstancingContext = nullptr,
uint32  LoadFlags = LOAD_None 
)

Asynchronously load a package and all contained objects that match context flags. Non-blocking. Use this version to specify the PackagePath rather than having the other versions internally convert the InName to a PackagePath by searching the current package mount points. Use this version if you need to specify a packagename that is different from the packagename on disk; this is useful when loading multiple copies of the same package.

Parameters
InPackagePathPackagePath to load. Must be a mounted path. The package is created if it does not already exist.
InPackageNameToCreateIf not none, this is the name of the package to load the bytes on disk into (and create if not yet existing). If none, the name is taken from PackagePath.
InCompletionDelegateDelegate to be invoked when the packages has finished streaming
InPackageFlagsPackage flags used to construct loaded package in memory
InPIEInstanceIDPlay in Editor instance ID
InPackagePriorityLoading priority
InstancingContextAdditional context to map object names to their instanced counterpart when loading an instanced package
LoadFlagsFlags controlling loading behavior, from the ELoadFlags enum
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

◆ LoadPackageAsync() [3/6]

int32 LoadPackageAsync ( const FString &  InName,
const FGuid InGuid = nullptr 
)

Asynchronously load a package and all contained objects that match context flags. Non-blocking. Use this version for convenience when you just need to load a package without notification and with default behavior from a packagename/filename.

Parameters
InNamePackageName or LocalFilePath of package to load. Must be a mounted name/path. The package is created if it does not already exist.
InGuidGUID of the package to load, or nullptr for "don't care"
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

◆ LoadPackageAsync() [4/6]

int32 LoadPackageAsync ( const FString &  InName,
const FGuid InGuid,
const TCHAR InPackageToLoadFrom,
FLoadPackageAsyncDelegate  InCompletionDelegate,
EPackageFlags  InPackageFlags,
int32  InPIEInstanceID,
int32  InPackagePriority,
const FLinkerInstancingContext InstancingContext 
)

◆ LoadPackageAsync() [5/6]

int32 LoadPackageAsync ( const FString &  InName,
FLoadPackageAsyncDelegate  InCompletionDelegate,
TAsyncLoadPriority  InPackagePriority = 0,
EPackageFlags  InPackageFlags = PKG_None,
int32  InPIEInstanceID = INDEX_NONE 
)

Asynchronously load a package and all contained objects that match context flags. Non-blocking. Use this version when you need to load a package with default behavior from a packagename/filename, and need to be notified when it is loaded.

Parameters
InNamePackageName or LocalFilePath of package to load. Must be a mounted name/path. The package is created if it does not already exist.
InCompletionDelegateDelegate to be invoked when the packages has finished streaming
InPackagePriorityLoading priority
InPackageFlagsPackage flags used to construct loaded package in memory
InPIEInstanceIDPlay in Editor instance ID
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

◆ LoadPackageAsync() [6/6]

int32 LoadPackageAsync ( const FString &  InName,
FLoadPackageAsyncOptionalParams  InOptionalParams 
)

Asynchronously load a package and all contained objects that match context flags. Non-blocking. Use this version when you need to load a package with default behavior from a packagename/filename, and need to be notified when it is loaded.

Parameters
InNamePackageName or LocalFilePath of package to load. Must be a mounted name/path. The package is created if it does not already exist.
InOptionalParamsOptional parameters.
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

◆ NotifyRegistrationComplete()

void NotifyRegistrationComplete ( )

◆ NotifyRegistrationEvent()

void NotifyRegistrationEvent ( FName  PackageName,
FName  Name,
ENotifyRegistrationType  NotifyRegistrationType,
ENotifyRegistrationPhase  NotifyRegistrationPhase,
UObject *(*)()  InRegister,
bool  InbDynamic,
UObject FinishedObject 
)

◆ NotifyScriptVersePackage()

void NotifyScriptVersePackage ( Verse::VPackage Package)

◆ NotifyUnreachableObjects()

void NotifyUnreachableObjects ( const TArrayView< FUObjectItem * > &  UnreachableObjects)

Call back into the async loading code to inform of the destruction of serialized objects

◆ ProcessAsyncLoading()

EAsyncPackageState::Type ProcessAsyncLoading ( bool  bUseTimeLimit,
bool  bUseFullTimeLimit,
double  TimeLimit 
)

Serializes a bit of data each frame with a soft time limit. The function is designed to be able to fully load a package in a single pass given sufficient time.

Parameters
bUseTimeLimitWhether to use a time limit
bUseFullTimeLimitIf true, use the entire time limit even if blocked on I/O
TimeLimitSoft limit of time this function is allowed to consume
Returns
The minimum state of any of the queued packages.

◆ ProcessAsyncLoadingUntilComplete()

EAsyncPackageState::Type ProcessAsyncLoadingUntilComplete ( TFunctionRef< bool()>  CompletionPredicate,
double  TimeLimit 
)

Blocks and runs ProcessAsyncLoading until the time limit is hit, the completion predicate returns true, or all async loading is done

Parameters
CompletionPredicateIf this returns true, stop loading. This is called periodically as long as loading continues
TimeLimitHard time limit. 0 means infinite length
Returns
The minimum state of any of the queued packages.

◆ ResetAsyncLoadingStats()

void ResetAsyncLoadingStats ( )

◆ ResumeAsyncLoadingInternal()

void ResumeAsyncLoadingInternal ( )

◆ SetAsyncLoadingAllowed()

void SetAsyncLoadingAllowed ( bool  bAllowAsyncLoading)

Allows or disallows async loading (for example async loading is not allowed after the final flush on exit)

Parameters
bAllowAsyncLoadingtrue if async loading should be allowed, false otherwise

◆ ShouldAlwaysLoadPackageAsync()

bool ShouldAlwaysLoadPackageAsync ( const FPackagePath InPackagePath)

◆ ShutdownAsyncThread()

void ShutdownAsyncThread ( )

◆ SuspendAsyncLoadingInternal()

void SuspendAsyncLoadingInternal ( )

Variable Documentation

◆ GAsyncLoadingAllowed

bool GAsyncLoadingAllowed = true

◆ GFlushAsyncLoadingCount

uint32 GFlushAsyncLoadingCount = 0

◆ GFlushAsyncLoadingTime

double GFlushAsyncLoadingTime = 0.0

◆ GIoDispatcherInitializedByLoader

bool GIoDispatcherInitializedByLoader = false

◆ GIsLoaderCreated

volatile int32 GIsLoaderCreated

◆ GPackageLoader

◆ GSyncLoadCount

uint32 GSyncLoadCount = 0

◆ GTimeLimitExceededMinTime

float GTimeLimitExceededMinTime = 0.005f

◆ GTimeLimitExceededMultiplier

float GTimeLimitExceededMultiplier = 1.5f

◆ GWarnIfTimeLimitExceeded

int32 GWarnIfTimeLimitExceeded = 0

◆ PrestreamPackageClassNameLoad

const FName PrestreamPackageClassNameLoad = FName("PrestreamPackage")