Repository navigation
Don't lose mutations delayed by priority on insertion or removal - #792
Closed
oloflarsson wants to merge 1 commit into
Closed
oloflarsson wants to merge 1 commit into
oloflarsson wants to merge 1 commit into
Conversation
If priority delayed an entity's mutation for a client and the entity had an insertion or removal for that client on the same tick, `update_ticks` moved `system_tick` past the delayed change and it was never sent. Keep the previous `system_tick` in that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Fixed it a bit differently in #794, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #791.
When priority delays an entity's mutation for a client, and the entity has an insertion or a removal for that client on the same tick,
update_ticksmovedEntityTicks::system_tickpast the delayed change, so it was never sent.Now
Mutationsrecords whether a mutation was delayed for the current entity (reset instart_entity, likeentity_location). When it was,collect_changeskeeps the previoussystem_tickwhile still updatingserver_tick, the components and the diff cursors. Priority depends only on the entity and the client, so when a mutation is delayed none of the entity's mutations were written for that client. Keeping the older tick only makes us resend more, so the delayed change stays pending (this would still hold with per-component priority, #698).Trade-offs:
system_tick, so they are sent once more as mutations together with the delayed one. The client gets the same value again, which triggers change detection (and, for immutable components, insertion hooks and observers) a second time, as a resent mutation already does after a lost ack.server_tickis still bumped by the update message, so priority accumulation for the entity restarts from that tick (as it already does today). The delayed mutation therefore goes out up to1 / priorityticks later, and is held back for as long as the entity keeps getting insertions or removals more often than that.An alternative would be to ignore priority for an entity that has an insertion or removal for the client and write its mutations into the update message. That needs to know about insertions before the first mutation is written (removals are known up front, insertions only once their component is reached), so I went with the smaller change. Happy to switch if you prefer that.
Added
priority::with_insertionandpriority::with_removal. Both fail onmasterand pass with the fix. Also added a changelog entry.Tested locally on the PR head:
cargo test --workspace --all-features --all-targets,cargo test --workspace --all-features --doc,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo rustdoc --all-features -- -D warnings(and for the example backend),cargo fmt --all --check,taplo fmt --check,typosandcargo hack check --feature-powerset.server_message::server_bufferingfailed once in my runs on a loaded machine; it fails at a similar rate onmaster(3/30 vs 5/30 interleaved), since the defaultServerPluginticks inFixedPostUpdateon real time, so it looks unrelated.