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

Stuttering prevention in Apollon itself #343

Merged
merged 7 commits into from
Feb 23, 2024

Conversation

loreanvictor
Copy link
Contributor

Checklist

  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes (NA)
  • I translated all the newly inserted strings into German and English (NA)

Motivation and Context

With current implementation of realtime collaboration, there is potential for stuttering: the client updating to a state that is quickly overwritten by another state. The phenomena is explained in detail here. This PR refactors the solution to provide it out-of-the-box on Apollon itself.

Stuttering targeted by this PR can happen in the following scenario:

  • Client A issues change X. Client A is on state X.
  • Client B issues change Y. Client B is on state Y.
  • Server sends X to both clients. Both clients go to state X.
  • Server sends Y to both clients. Both clients go to state Y.

Client A has an expected behaviour in this scenario, with the client observing state sequence I -> X -> Y. Client B however observes the sequence I -> Y -> X -> Y, which when happening in quick succession, results in "stuttering" (the state quickly changing and then reverting back). A client can also self-stutter:

  • Client issues change X.
  • Client issues change Y.
  • Server sends X to clients. Client goes to X.
  • Server sends Y to clients. Client goes to Y.

The state sequence observed by the client will be I -> X -> Y -> X -> Y, which is the same stuttering.

Description

This PR brings over the fix from this PR into Apollon itself. With this mechanism, a client stores a hash for each change it issues on a particular address in the state object, and optimistically ignores all other incoming changes on that particular address until the server recognises its own issued change, as it predicts the server will eventually affirm said change and all prior changes to that address will be overwritten by that local change nevertheless. This increases stability of the state sequence and prevents the aforementioned stuttering.

Steps for Testing

See this

Test Coverage

File Branch Line
services/patcher/patcher-verifier.ts 100% 100%
services/patcher/patcher-reducer.ts 100% 100%
services/patcher/patcher.ts 100% 100%

@loreanvictor loreanvictor mentioned this pull request Feb 22, 2024
3 tasks
@matthiaslehnertum matthiaslehnertum merged commit 6f5a797 into develop Feb 23, 2024
5 checks passed
@matthiaslehnertum matthiaslehnertum deleted the feature/stuttering-prevention-in-patcher branch February 23, 2024 18:35
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.

2 participants