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

Rollback issues in avian3d #795

Open
cBournhonesque opened this issue Jan 10, 2025 · 0 comments
Open

Rollback issues in avian3d #795

cBournhonesque opened this issue Jan 10, 2025 · 0 comments
Labels
A-Prediction C-Example A change/addition to an example

Comments

@cBournhonesque
Copy link
Owner

cBournhonesque commented Jan 10, 2025

  1. We disable the SyncPlugin in FixedPostUpdate and put it in PostUpdate.
    That's because the VisualInterpolation plugin updates Position every frame in PostUpdate, and we want the sync from Position->Transform to happen after that, because some entities depend on the Transform (children, etc.)

Therefore we need to add PostUpdate system ordering as well.
Fixed: #796

  1. How come we have logs like
2025-01-10T06:20:38.865951Z  INFO lightyear::client::prediction::rollback: Rollback check: mismatch for component between predicted and confirmed 40v1#4294967336 on tick Tick(1485) for component "avian3d::dynamics::rigid_body::AngularVelocity".
Current tick: Tick(1496) predicted_exist=true confirmed_exist=true

when the value of AngularVelocity is 0.0 on both server and client

ANSWER: the rollbacks are happening on the block characters, not on the controllable character!
When I remove the blocks completely, there are no rollbacks.

  1. Avian uses some resources that are not rolled back.

After adding a non-networked resource to rollback I have an issue:

  • client connects and sync. Its tick becomes server_tick + X
  • prediction systems start running, in particular the resource gets added to history for server_tick + X. Also components get received for server_tick + X in the PredictionHistory
  • receive an update from the server for tick server_tick for Confirmed entities
  • the PredictionHistory did not have a value for server_tick, so we trigger a rollback
  • During the rollback, we restore the Predicted component values to the Confirmed values (usually this means no change)
  • However we also remove the Resource because it didn't exist at tick server_tick in the ResourceHistory. In general it's not possible to 'disable' a resource to make it ignored. That means that the resource gets removed (because of rollback), which causes the avian plugin to panic

a) When we receive a TickEvent, should we also update the values in the PredictionHistory/InterpolationHistory/ResourceHistory? (TickEvent means that client tick was very out of sync with server tick and we reset the client tick to be close to the server tick). And then we could just start adding stuff in the history before Sync. Maybe instead of storing actual ticks in the histories, we can store the offset compared to the present. I.e. tick -1, tick -2, etc. That way even if the present tick changes (for example on a sync event the present tick could jump from 10 to 1000) it doesn't matter because we still know that the component/resource was updated on tick 10-2 = 8 -> 1000-2 = 998
b) Does change the relative speed on the client change anything? probably not, it just means that we might run more FixedUpdate schedule steps to catch up to the server, but otherwise each FixedUpdate.delta is fixed.
c)

Fixed: #798

  1. Also do we need to rollback Time and Time? See Document components and resources needed for rollback Jondolf/avian#478

  2. Do we need to handle entity sleeping?

  3. Having VisualInterpolation enabled on the server causes issues, probably because the value that is being replicated is the interpolated value. I think we need some system ordering so that VisualInterpolation happens after sending packets!

Fixed: #799

Note:

  • with no Boxes, no Collision rollback, Sleep disabled, ExternalForce/ExternalImpulse full-replicated: NO ROLLBACKS
  • with no Boxes, Collision rollback, Sleeping enabled, ExternalForce/ExternalImpulse full-replicated: ROLLBACKS
  • with no Boxes, no Collision rollback, Sleeping enabled, ExternalForce/ExternalImpulse full-replicated: ROLLBACKS
  • Changing the Block shape from cube to a capsule removes most of the rollbacks. There is some kind of rotation/friction between the floor and the cube that is messing things up

-> It seems like the order of iteration on the contact points is not deterministic, or there is another source of non-determinism based on the order of entities

  • avian's transform interpolation happens in RunFixedMainLoop, so the interpolated value will be sent. This means that avian's transform interpolation should not be used on the server
@cBournhonesque cBournhonesque added A-Prediction C-Example A change/addition to an example labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Prediction C-Example A change/addition to an example
Projects
None yet
Development

No branches or pull requests

1 participant