fix: stale auth state poisoning#618
Conversation
c9de48e to
f7031d9
Compare
elementbound
left a comment
There was a problem hiding this comment.
Added some suggestions, excellent stuff otherwise!
f7031d9 to
abe463a
Compare
|
Please don't merge it yet. I found a possible misbehavior caused by this change. I'd like to verify it is safe first :) |
177bed1 to
43cbf42
Compare
43cbf42 to
511dbdb
Compare
UpdateThe first iteration of the fix introduced another regression. Position jittering due to continuous "fighting" of authoritative states and predicted local simulation. The main reason is that clients received incomplete snapshots and tried to extrapolate player position from it:
I tried to plug them all but I don't think it's the right solution anymore. I initially wanted to avoid wasting more memory by a band-aid solution of truncating history and letting local resim reconstruct from there. It doesn't work well. Proper solutionRemember the snapshot that was sent to each peer and calculate diffs against that instead of self-owned state. How much more memory and CPU will this need? YES! There is probably room for optimization there but I think this solution closes a LOT of awkward edge cases instead of trying to work around them. For example, I think it fixes another issue I noticed but haven't attempted to debug yet: under heavy latency (tested via Clumsy, starting at around 250ms TTR), a peer sometimes completely hangs for a fraction of a second. My suspicion is that diff calculation flakes out and doesn't send anything so we're waiting for the next full state. |
79ec9d2 to
ef932ae
Compare
Currently, a stale auth state can poison history preventing local corrections when diff states are enabled.
Failure mode:
This change truncates all local history on receiving auth state from the past. Tested with out of order delivery and did not discover any new failure modes.
This is just one edge case with diff + auth state history. It is probably less risky and easier to maintain if it's truncated to avoid playing whack-a-mole with more edge cases.