Serious issue with RepNotify and Struct UPROPERTY's
Have sought out Epic support on this issue, but am reposting here to make users aware of the bug and workaround for now.
I've found what I believe to be a severe bug with RepNotify functions when used with struct UPROPERTY's, when specifying the optional 'Previous' value parameter. The parameter provided to "Previous Value" is always out-of-date. This is 100% reproducible and I'm surprised this hasn't been picked up before.
Given the following USTRUCT():
And a member variable of this struct in an Actor class, with the following RepNotify function:
'OldValue' is always out of date when the Server calls 'MarkActive()', then 'MarkInactive()'. This occurs whether they are called in the same frame, or after significant time between the calls. The output from visual studio yields the following results:
This is clearly incorrect. The second Client: Previous entry should have an activation value of 1, and a time of 9.32.
If however, I provide a manual implementation of NetSerialize() for the struct. which mimics what the serializer does anyway:
The RepNotify is called with the correct OldValue, as shown again by the log. Note that the only difference here is the manual inclusion of the NetSerialize() function - but the log now shows the correct (expected) output:
I've done some digging and found a (very old and unanswered) answerhub post which alludes to the same behaviour, indicating that the shadow data stored by the replicator is out-of-date when only single properties of the struct are modified. I'm surprised this hasn't been noticed and fixed already as it is quite a severe issue - but perhaps it's only noticeable when monitoring changes more closely.
asked Dec 17 '18 at 05:43 PM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here