Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false positives in remote desync detection #64

Merged
merged 12 commits into from
Oct 23, 2023

Conversation

johanhelsing
Copy link
Contributor

@johanhelsing johanhelsing commented Oct 20, 2023

Fixes #63 and also fixes a bug that checksums are removed prematurely if the interval is > MAX_CHECKSUM_HISTORY_SIZE

Confirmed working with the test case for #63

Bonus: Remote checksums are now only checked once (removed once verified).

@johanhelsing
Copy link
Contributor Author

@HeatXD may want to review, because they did the initial implementation #50

@PraxTube
Copy link
Contributor

I keep getting the following panic right after peers connect in my bevy_ggrs project.

thread 'main' panicked at 'cell not found!: frame 100', ggrs-c119670c0a115c50/94604ce/src/sessions/p2p_session.rs:921:44

The frame not found seems to depend on the specified desync interval.

.with_desync_detection_mode(DesyncDetection::On { interval: 100 })

Changing the max prediction window and max frames behind didn't do much either

.with_max_prediction_window()
.with_max_frames_behind()

Is there anything that has to be configured in order for this PR to properly work in
exisiting bevy_ggrs projects, or this not expected to work with bevy_ggrs at all yet?

@johanhelsing
Copy link
Contributor Author

I keep getting the following panic right after peers connect in my bevy_ggrs project.

thread 'main' panicked at 'cell not found!: frame 100', ggrs-c119670c0a115c50/94604ce/src/sessions/p2p_session.rs:921:44

The frame not found seems to depend on the specified desync interval.

.with_desync_detection_mode(DesyncDetection::On { interval: 100 })

Changing the max prediction window and max frames behind didn't do much either

.with_max_prediction_window()
.with_max_frames_behind()

Is there anything that has to be configured in order for this PR to properly work in exisiting bevy_ggrs projects, or this not expected to work with bevy_ggrs at all yet?

It's expected to work with bevy_ggrs. But very possible that I overlooked something.

I tested with box_game_p2p on this branch https://github.com/gschup/bevy_ggrs/compare/main...johanhelsing:bevy_ggrs:trigger-desync-issues?expand=1 and in my own game.

@johanhelsing
Copy link
Contributor Author

johanhelsing commented Oct 20, 2023

@PraxTube are you able to reproduce your panic by modifying this branch? https://github.com/gschup/bevy_ggrs/compare/main...johanhelsing:bevy_ggrs:desync-debug?expand=1

EDIT: Managed to by setting input_delay back to 2. Will look into the issue

@johanhelsing johanhelsing marked this pull request as draft October 20, 2023 13:19
@PraxTube
Copy link
Contributor

PraxTube commented Oct 20, 2023

Ah yeah, for input_delay = 0 I don't get the panic (I had it on 2 in my tests). The desync detection seems to work properly when using 0 delay.

@johanhelsing
Copy link
Contributor Author

johanhelsing commented Oct 21, 2023

I added a test, which is good in itself, but for some reason I don't get the panic there :/

EDIT: managed to repro with a higher input delay :)

@johanhelsing johanhelsing marked this pull request as ready for review October 21, 2023 17:56
@johanhelsing
Copy link
Contributor Author

This is ready for review now. There is one thing that bugs me (see comment above), but I'm giving up trying to understand it for now.

This is a lot more correct than the previous implementation. And has a test case that failed prior to this PR (and another one to make sure the panic reported by @PraxTube is fixed)

@gschup gschup self-requested a review October 21, 2023 18:06
src/network/protocol.rs Outdated Show resolved Hide resolved
src/sessions/p2p_session.rs Show resolved Hide resolved
src/network/protocol.rs Outdated Show resolved Hide resolved
@johanhelsing johanhelsing marked this pull request as draft October 22, 2023 10:15
@johanhelsing johanhelsing marked this pull request as ready for review October 23, 2023 05:54
Copy link
Owner

@gschup gschup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me and everything is structured the same as it was before, so I really can't complain. Nice cleanups here and there :)

I am still baffled that this very obvious detail of comparing checksums only for confirmed frames didn't occur to me in the original PR.

src/sessions/p2p_session.rs Show resolved Hide resolved
src/sessions/p2p_session.rs Show resolved Hide resolved
@gschup gschup merged commit 5c6a0e0 into gschup:main Oct 23, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Desyncs are incorrectly reported for predicted frames
4 participants