SetUseUnversionedPropertySerialization in FDuplicateDataReader (and Writer)

There is this line in the constructor for FDuplicateDataReader (and Writer):

	this->SetUseUnversionedPropertySerialization(((InPortFlags & PPF_DuplicateForPIE) == 0));

The unversioned property serialization is faster than regular property serialization, but it assumes that writing and reading are always going to be perfectly symmetric. That should be a safe assumption when duplicating stuff - wouldn’t necessarily work when saving to disk and reading later, when some code might have changed. Doesn’t this look inverted, though? It’s setting unversioned serialization when the duplicate for PIE flag is not set, right?

For a large world, with a large number of actors, there is a significant performance boost when starting Play In Editor from inverting this condition. Is this just a simple bug? Or am I missing something here?

[Attachment Removed]

Steps to Reproduce
Look at the code for the constructors of FDuplicateDataReader and Writer.

[Attachment Removed]

I introduced the PIE disablement in response to increased instability in PIE duplication after I enabled UPS for duplication in 5.4. I’m unsure about exactly what pattern violates the UPS invariants, but it was relatively widespread and so we opted for the safer default behavior.

Feel free to use the faster path in PIE if it’s working in your project, but keep an eye our for instability. In recent versions of the engine you can use JsonObjectGraph/Stringify.h to validate that the object graph is identical with/without the optimization. That’s usually the procedure I use to hunt for problems when enabling the optimization.

[Attachment Removed]