Commit Graph

105 Commits

Author SHA1 Message Date
phillip kavan
9817b53199 Allow TObjectPtr instances to resolve directly to placeholder-typed references when T=UObject.
Notes:
- For placeholder-typed objects, TObjectPtr<UObject> is considered to be type safe since placeholder types are based on UObject.
- This means we can avoid having to check for and indirectly resolve placeholders via the ptr's internal object handle in these cases.

#jira UE-209831
#rb Francis.Hurteau, Zousar.Shaker

[CL 32434610 by phillip kavan in ue5-main branch]
2024-03-22 11:12:08 -04:00
devin doucette
7e47a8cc5e Assert on FPropertyTypeName with too many names and minimize its index waste
#rb Francis.Hurteau
#rnx

[CL 32383199 by devin doucette in ue5-main branch]
2024-03-20 17:39:19 -04:00
devin doucette
f806a8c06c Fixed property bag tests to use the new SetType function on FPropertyTag
#rnx

[CL 32005366 by devin doucette in ue5-main branch]
2024-03-04 18:56:08 -05:00
devin doucette
a4b19dbaef Fixed use of a deprecated variable in PropertyBagTest
#rnx

[CL 31960032 by devin doucette in ue5-main branch]
2024-03-01 17:45:14 -05:00
devin doucette
5e98f213c4 Added functions to FPropertyTypeName to query for structs and enums
These are convenience functions that cover most usage of FPropertyTypeName outside of CoreUObject.

#rb Steve.Robb
#rnx

[CL 31949226 by devin doucette in ue5-main branch]
2024-03-01 13:29:27 -05:00
paul chipchase
a50b673e3c Fix the low level FEditorBulkData tests from failing on runtime platforms.
#rb Per.Larsson
#jira UE-207889
#rnx

- The FEditorBulkData tests should only run on platforms with WITH_EDITORONLY_DATA enabled, this was lost when moving them from automation tests.
- Fixed up some poorly formatted includes.

[CL 31834360 by paul chipchase in ue5-main branch]
2024-02-27 04:20:24 -05:00
paul chipchase
972fca9224 Convert the FEditorBulkData tests to the low level test system
#rb Per.Larsson
#rnx

[CL 31717015 by paul chipchase in ue5-main branch]
2024-02-22 06:16:03 -05:00
devin doucette
379d58366f Changed FPropertyTypeName to use () instead of <> to delimit parameters
We want to use these to contain object path names, for which () is invalid and <> is not technically invalid.

#rb Matt.Peters
#rnx

[CL 31660123 by devin doucette in ue5-main branch]
2024-02-20 18:01:22 -05:00
andrew phillips
1287058a76 Reenable PropertyBagTests after blocking Mac builds.
Issue looks to be differences in memory allocation reuse stratagems between platforms.

#rb Francis.Hurteau

[CL 31612483 by andrew phillips in ue5-main branch]
2024-02-19 10:57:00 -05:00
matt breindel
810632ff12 Build fix for Issue 430822. Disabling PropertyBagTests for now as it is currently failing on horde.
[REVIEW] [at]*francis.hurteau
[FYI] [at]andrew.phillips, [at]devin.doucette
#rb Francis.Hurteau
#tests Verified locally in submit tool and building FoundationTests

[CL 31586086 by matt breindel in ue5-main branch]
2024-02-16 18:33:58 -05:00
devin doucette
fc0ec2ca6a Fixed build error in PropertyBagTest
#rnx

[CL 31578950 by devin doucette in ue5-main branch]
2024-02-16 15:54:45 -05:00
devin doucette
39065bb841 Updated FPropertyTypeName to explicitly support guids and paths
#rb Matt.Peters
#rnx

[CL 31578093 by devin doucette in ue5-main branch]
2024-02-16 15:37:39 -05:00
andrew phillips
c0fe26076b Attempted fix for issue=430784
[CL 31568549 by andrew phillips in ue5-main branch]
2024-02-16 11:54:34 -05:00
andrew phillips
8cf71aed9d Property bag tests 1
First set of tests for the new property bag.
This exercises: Add, LoadFromTag, Remove, Iteration, storage

https://epicgames.slack.com/archives/C05HDDK8VUP/p1706200984745359?thread_ts=1706198804.429209&cid=C05HDDK8VUP

#jira UE-202459
#rb Devin.Doucette

[CL 31560445 by andrew phillips in ue5-main branch]
2024-02-16 06:53:03 -05:00
sebastian thomeczek
1710add64a Fixed TWeakFieldPtr asserting with "const T" template parameters.
Added simple tests to verify this use-case compiles.

[FYI] Steve.Robb

[CL 31483471 by sebastian thomeczek in ue5-main branch]
2024-02-14 13:17:04 -05:00
phillip kavan
91216b7898 [UE]: More revisions to placeholder property bag type import/export serialization support during map asset loads in the editor.
Change summary:
- Modified ObjectPtr_Private::IsObjectPtrEqualToRawPtrOfRelatedType() to include a non-resolving NULL check for LHS. This allows unsafe type object pointers to equate to NULL object pointers (in addition to nullptr) - e.g. for compiled paths that do implicit type conversions from nullptr to TObjectPtr(nullptr). Also updated the unit test to reflect this behavior change.
- Replaced FPropertyBagRepository::IsPropertyBagPlaceholderType() with IsPropertyBagPlaceholderObject().
- No longer setting RF_HasPlaceholderType on placeholder import type CDOs. This allows UObject initializers to evaluate/dereference the CDO ptr normally as a UObject*, even if created with a placeholder type.
- Replaced direct RF_HasPlaceholderType flag queries with FPropertyBagRepository::IsPropertyBagPlaceholderObject() instead for placeholder export object queries in FLinkerLoad. This remains inclusive of the CDO.
- Now appending RF_HasPlaceholderType onto the ObjectFlags member for export entries created from placeholder type imports. The flag will be cleared if/when the correct instance is patched back into the export table (e.g. at reinstancing time).
- Modified FLinkerLoad::TryCreatePlaceholderTypeForExport() to remove the check for 'bSerializeUnknownProperty'. This does not get set until after we've created the placeholder type when we attempt to Preload() the export that's using it.
- Modified FLinkerLoad::Serialize() to virtualize serialization when loading a property bag for an object with a missing type import that was serialized with an asset version older than EUnrealEngineObjectUE5Version::SCRIPT_SERIALIZATION_OFFSET.
- Modified FLinkerLoad::Preload() to include an asset version check for when serialization of placeholder exports can be safely narrowed to SerializeScriptProperties(). For older asset versions, any non-TPS data serialization is now virtualized instead.
- A warning is now emitted by FLinkerLoad::operator<<() when returning NULL for placeholder export object refs in those cases where we are not able to enforce its type safety at runtime. This now includes reflected properties that might serialize a reference to a placeholder type's CDO, which should be an unlikely edge case that we'll now report on here.
- Re-enabled unit tests for object handle/pointer type safety (ObjectHandleTests.cpp).
- Added a "stress test" method for object pointers to assist with A/B testing and perf analysis (ObjectPtrTests.cpp).
- Modified natvis to extend the TObjectPtr format to display as 'nullptr' for pointers to placeholder export types. Intent is to minimize confusion while debugging since object pointers don't allow access to unsafe type objects directly.
- Added a CVar to control whether or not we will create placeholder exports as serialization targets when import types are missing on map load (SceneGraph.EnablePropertyBagPlaceholderObjectSupport). Also can be enabled at launch via command line (-EnablePropertyBagPlaceholderObjects) for iteration purposes. Currently the CVar/feature defaults to off (experimental/WiP).

#jira UE-197358
#rb Francis.Hurteau

[CL 31447968 by phillip kavan in ue5-main branch]
2024-02-13 16:53:52 -05:00
devin doucette
175623ca9b Fixed operator< for FPropertyPathName
#rb Francis.Hurteau
#rnx

[CL 31394379 by devin doucette in ue5-main branch]
2024-02-12 14:59:06 -05:00
phillip kavan
5472821dcd Temporarily disable FObjectHandle placeholder type safety checks in LowLevelTests to allow CIS jobs to pass on Mac/Linux while I fix up an underlying issue.
#rnx

[CL 31310933 by phillip kavan in ue5-main branch]
2024-02-08 18:27:04 -05:00
phillip kavan
91d599b1c4 Create placeholder types/objects for package exports when type imports are missing/unresolved on editor map loads.
Notes:
- This allows the export to deserialize its tagged property stream (TPS) data into a property bag (when enabled), while also keeping references to the object in place.
- The export can still be serialized to the same package on save with its TPS data still intact. In that case, we will serialize the property bag back into the package as a "normal" TPS data stream.
- Serialized references to placeholder objects are resolved as NULL. For FObjectPtr types, the value is resolved as NULL when dereferenced (for type safety), but is still serialized as a non-NULL reference to the original object (even if placeholder).
- Placeholders will not be created on load unless FUObjectSerializeContext::bSerializeUnknownProperty is set to TRUE in the serialization context. Otherwise, we immediately resolve the export as NULL, and its data is lost on load (previous behavior).

Change summary:
- Added FPropertyBagRepository::PropertyBagTypeRegistry (w/ thread-safe implementation). Currently using ARO to manage placeholder type object lifetime.
- Added FPropertyBagRepository::AddPropertyBagPlaceholderType()/IsPropertyBagPlaceholderType().
- Modified FLinkerLoad::CreateExport() to instance a "placeholder" package/object if the export is missing its type import on load. Otherwise falls back to returning NULL (previous behavior).
- Added UE_WITH_OBJECT_HANDLE_TYPE_SAFETY along with IsObjectHandleTypeSafe().
- Added UE::CoreUObject::Private::HasAnyFlags() to ObjectFwd.h (using int32 for the param here as the enum isn't defined at this level). Similar to internal APIs added for late resolve; avoid having to include Object.h.
- Added RF_HasPlaceholderType (reclaimed an unused bit). This allows FObjectPtr to do a faster query at resolve time for type safety when referencing a placeholder object (i.e. it will return NULL).
- Modified FObjectPtr::Get() and IsNull() variants to include an extra check for type safety. Right now this is only enabled in an editor build context.
- Modified FLinkerLoad::Preload() to narrow the serialization scope to the export's TPS data *only* (since the original base type is unknown, we need to skip any natively-serialized data that might also exist in the stream).
- Modified FLinkerLoad serialization of raw UObject* values to return NULL in the case of a placeholder object (for type safety at runtime).
- Modified FLinkerLoad serialization of FObjectPtr values to return NULL in the case of a placeholder object only if type safety features are disabled on FObjectPtr/FObjectHandle.
- Extended the LowLevel core NULL ptr tests to include additional tests for "unsafe type" objects wrapped by an FObjectPtr/TObjectPtr.

#jira UE-197358
#rb Francis.Hurteau

[CL 31258090 by phillip kavan in ue5-main branch]
2024-02-07 10:34:24 -05:00
kevin macaulayvacher
a66f947914 Improves DoesPackageExistEx by enabling it to use the AssetRegistry when it's available
Before Boot -> PIE
FPackageName::DoesPackageExistEx called 191284 times takes 16.45s in total

After Boot -> PIE
FPackageName::DoesPackageExistEx called 191743 times takes 1.61s in total

The majority of the 1.6s (1s) is from calling DoesPackageExistEx before the AssetRegistry has initialized and can provide a fast path. The 180K calls afterwards consume a total of 600ms compared to before, which took 15s.

The original DoesPackageExistEx code checked for package existence on the filesystem, and at the same time found the case matching package name (the casing the file system uses for the package name). This information is known to the AssetRegistry so we can avoid the duplicate work by deferring to the AssetRegistry.

The AssetRegistry needs to initialize itself, and previously did not expose a means to get the Case Matching FNames for Packages which are being used as the keys to AssetPackageData. We add a new overload to IAssetRegistryInterface::TryGetAssetPackageData to allow CoreUObject code to access the another new overload in the AssetRegistry::GetAssetPackageData which returns the case matching FName for the package as an out parameter. Since IAssetRegistryInterface can be used while the AssetRegistry doesn't exist or is still intializing, IAssetRegistryInterface::TryGetAssetPackageData will return UE::AssetRegistry::EExists::Unknown when the asset registry is not yet available. In the Unknown case, we fallback to the original FPackageName::DoesPackageExistEx codepath which reads from disk.

I've made the (Try)GetAssetPackageData methods that only return FAssetPackageData* to use the new implementation that returns a FAssetPackageData* and populates an FName in order to reduce code duplication, however I'm open to changing this if the extra store is a concern. All paths perform the key search in the AssetRegistry's CachedAssetPackageData map.

#jira UE-204062
#rb Matt.Peters

[CL 31055136 by kevin macaulayvacher in ue5-main branch]
2024-01-31 13:06:38 -05:00
devin doucette
efa61fcca3 Added structured serialization of FPropertyTypeName
#rb Francis.Hurteau
#rnx

[CL 31050185 by devin doucette in ue5-main branch]
2024-01-31 11:21:12 -05:00
devin doucette
308d762eb7 Updated FPropertyTypeName to make it more convenient to use
#rb Francis.Hurteau
#rnx

[CL 30862617 by devin doucette in ue5-main branch]
2024-01-24 16:37:36 -05:00
devin doucette
f0b3f1f627 Updated FPropertyPathName to use FPropertyTypeName
#jira UE-197352
#rb Francis.Hurteau
#rnx

[CL 30646449 by devin doucette in ue5-main branch]
2024-01-16 16:49:05 -05:00
devin doucette
b109dd23ad Added FPropertyTypeName to represent the full type name of a property
#jira UE-197352
#rb Francis.Hurteau
#rnx

[CL 30592565 by devin doucette in ue5-main branch]
2024-01-12 09:56:20 -05:00
robert manuszewski
a210b585b6 EInternalObjectFlags cleanup: removed PendingKill and deprecated composite flags
#rb Johan.Torp, Steve.Robb

[CL 30109006 by robert manuszewski in ue5-main branch]
2023-12-05 01:37:45 -05:00