PraxTube / ace-of-the-heavens

Fast paced online 1vs1 action game in an arcade-like, 2D top-down style
https://praxtube.itch.io/ace-of-the-heavens
MIT License
12 stars 0 forks source link

REPORT: Desync Bug Hunting #18

Closed PraxTube closed 1 year ago

PraxTube commented 1 year ago

The aim of this report is to figure out where and how desyncs happen. To this end I am first going to see what the actual latest release build is in terms of non desyncs (if one even exists!).

To start, I check the commit 3d2d49be0a676f3dd284d6f7acf54fd75be64060, it desyncs when played with a ping of 50ms. The issue as far as I can tell, is that if one player spams Left-Right (triggering a bunch of rollbacks because the other peer is constantly mispredicting), the bullets get rolledback (as they should) but if they despawn and get rolledback after that, they will NOT get respawned (EDIT: I believe the bulelts are working correctly, see below comments, and the actual issue I am refering to here is probably #20). This is exactly what I observed with the rockets on the current main (c631d5bf2944a114cfa54fe457920467f943a469).

PraxTube commented 1 year ago

Next was 5605d127182fd7eb2489cc4d37242336b1617aa3. Here we didn't see desyncs with 50ms and Left-Right spamming. However we did see desyncs with 150ms. Although I coudn't trigger the bullet respawn issue as I could in the above. There are much worse issues here (with the rematch) which make testing quite challenging. Either case, if I am desperate and don't know what to do, I should come back to this and further test to see if the bullet despawn issue appears here as well.

PraxTube commented 1 year ago

Commit fbfceb74f30653c5c98ee13210337017b4bd9aa1 seems to be the most promising one. I couldn't get any actual desyncs to happen (one where different players are alive). I do get desync errors, however I am assuming that this is simply because whenever we have to rollback, we get desync errors. So when we desync, we rollback, and we are synced again. However we get the desync errors for the time that we are unsynced.

This is a relief, as it means that desync errors don't automatically mean there are actual desyncs (which is exactly what I was expecting, but it's good to have this confirmation). The reason I am so sure this is the case is because the desync errors actually stop once you don't input anything. This wouldn't make any sense if there were actual desyncs happening.

Also note, when testing really high pings (>200ms), you must set the following

let mut session_builder = ggrs::SessionBuilder::<GgrsConfig>::new()
    .with_max_prediction_window(40)
    .with_max_frames_behind(42)
    .expect("couldn't set max frames behind")

otherwise the peers won't even connect.

PraxTube commented 1 year ago

Seems like 71c3e724b684d4f906ecfdc43aa7f2790b870231 is also working, at least in terms of bullet desyncs. There are some other issues, related to #20, but as far as the health and bullet syncing is concerned it's working.

PraxTube commented 1 year ago

Same for fe884bcef72e218c77d54c3dda4f84a719ba7255.

PraxTube commented 1 year ago

There are bullet desyncs in 369c5300566a5ef2fb01a579372f4e4235cfea53 (just shooting can trigger desyncs, so you don't even have to spam Left-Right, just be close enough to the other player and tap shooting slightly and you will rollback while not respawning the bullets).

PraxTube commented 1 year ago

33cc8956ba06aa70c3325b4251ee5d830bb83dec is also bugged (same thing with the bullets as above).

PraxTube commented 1 year ago

43105f6d24b297b4119b324a6a82aa1fa04f6813 is NOT bugged! At least not in the bullet desync sense.

PraxTube commented 1 year ago

3d2d49be0a676f3dd284d6f7acf54fd75be64060 also seems to be working.

PraxTube commented 1 year ago

The issue was the CollisionEntity. On a side branch I fixed it here 9d23e860e1d077171152789d7b98aaee4a92eb51. I am going to apply the same changes to master now.