[Iris] A replicated TArray on a component will replicate all elements with creation info

Hi,

(The following is in the context of a UActorComponent)

I want to expose some design data to BP and then use that design data to influence the fixed size of a replicated TArray. To keep things simple, lets say I want to expose an int32 to design data in BP and then grow my replicated array to that size which is then fixed at that point. I’ve tried setting the size of the array through various means like using PostLoad and PostInitProperties but neither are giving me the behavior I’d expect, which is that the CDO/Archetype ends up with N elements in the replicated array and therefore the diff between the CDO/Archetype and the component instance should produce no deltas for the component actor’s creation info bunch.

I’ve tracked this as far as descriptor creation, which looks to use the correct array length when constructing the default state but the fragment creation doesn’t look to do the same. Any thoughts or help on this would be greatly appreciated as it seems very wasteful to replicate any data with respect to these arrays with creation info since there’s been no changes to them at that time.

Edit: To be more concrete, if I subclass my component in BP and set that BP data to say 100: the archetype ends up with 100 elements when using PostLoad / PostInitProperties to initialize the array but I still see 100 elements get serialized over the network with the owning actor’s creation info batch.

Edit 2: I had been thinking this issue was specific to the use case of setting a fixed size array based on BP data, but I just tested a simpler case which is a replicated array exposed exposed to BP directly. Adding N elements to the array in the BP properties panel results in N elements being replicated with the creation info so it would seem that this is actually a more general issue.

Thanks,

Nick

Hi,

From what you’ve described, I believe this is the expected behavior.

Even if a replicated array has elements added in the class’s C++ constructor, it is expected to see these elements replicated as part of the actor’s initial state with Iris. The initial state is always delta compressed against the archetype/CDO, and since there is not a change mask when the object starts replicating, FArrayPropertyNetSerializer::Serialize will serialize each element.

In most cases, the NetSerializer for the element type will just serialize a bit to indicate if the value is the same or not, so these elements should use minimal data. However, some types can’t be quantized and stored, such as those types that require exports like NetTokens or object references, resulting in data being sent for these elements during the initial replication.

Thanks,

Alex