fishfolk / jumpy

Tactical 2D shooter in fishy pixels style. Made with Rust-lang 🦀 and Bevy 🪶
https://fishfolk.org/games/jumpy/
Other
1.6k stars 115 forks source link

Players may start to desync / stutter in networked play #918

Closed MaxCWhitehead closed 4 months ago

MaxCWhitehead commented 4 months ago

Description

I found that after jumping around / moving for a bit in a networked match, I started to see the remote player stutter, on tapping right, they'd move forward a ways then snap back to expected position. It occurs in both directions (each client stutters movement on opposite).

I have local changes testing smoothing net corrections, but when I disable this it still occurs. I'll triple check it's not my local changes by stashing them though. EDIT: confirmed not my local changes, repro'd on main.

Reproduced a few times.

To Reproduce

open network match with two clients, move and jump around for a bit.

Expected Behavior

No response

Additional Context

No response

Log Messages

No response

MaxCWhitehead commented 4 months ago

Here's a video, input given on client on right, stutter on remote player on left.

( Don't mind the eyes bulging out of fish on the right, side effect of interpolation crap I was doing, can see the eyes don't bulge on left as it's disabled on that one).

EDIT: Confirmed not my local changes, repro'd on main. I noticed that sometimes one direction is worse than the other (one snaps big, one small).

https://github.com/fishfolk/jumpy/assets/35712032/3c0e1649-e27b-4ae7-ae11-bd5894c45505

MaxCWhitehead commented 4 months ago

Current theory is that the stutter is due to simulation advancing a few frames with predicted input, and once a confirmed input is received indicating the button was no longer pressed, it corrects and rolls back to expected position.

So this would indicate unreliable network conditions or high latency. I should get the network debug tools back online. I should also really go to bed lmao, but I'll test with a local matchmaking server or LAN tomorrow and see if that helps.

I tested some much older commits, don't think it's a recent bug? I've been in this setup all the time and just started hitting this tonight. I have a fear it'll go away come tomorrow. My laptop could also just be screwy. Either way would be good to understand what conditions cause this or figure out what the bug is if doing something wrong.

EDIT: it does seem like the jump is faster than normal movement, so probably not just predicted inputs in isolation - that should not be so unnatural. it could be predicted input and a combo of a client going from 0 frames predicted -> predicting up to 8 in one frame and then getttign corrected back? maybe a swing in prediction ahead, idk, I should stop spitballing and just debug it.

MaxCWhitehead commented 4 months ago
image

It still reproduces when neither clients are at max predicted frames (not freezing), so can rule that hypothesis out. Will see if it correlates with FPS next probably and that we are not somehow stepping multiple times per network frame or something.

Got network debug menu working (and entirely in bones), so silver linings.

MaxCWhitehead commented 4 months ago

Testing with local docker client seemed to help, I feel like the problem might still be there just on a very small scale. Definitely seems to be exasperated by ping. My ping to match making server seems somewhat unstable, will look into that, not sure if it is the only cause.

MaxCWhitehead commented 4 months ago

So this isn't actually a bug, but an artifact of a double correction when input is tapped. Made worse by large frame difference.

Scenario:

Will think about options here, there are probably gonna be some level of artifacts at 200 ping, maybe this will get better with some of the net correction smoothing stuff I was doing. Think I've gone full circle.

I don't know why I just started hitting this, either my ping got worse, or I started tapping more than I normally do while testing.

MaxCWhitehead commented 4 months ago

I tuned max frames + input delay to help, seems in decent shape 100-150ms ping, gonna close this for now. Can revisit in future if need be.