Skip to content

Conversation

@Shatur
Copy link
Contributor

@Shatur Shatur commented Nov 2, 2025

Objective

We'll need this for per-component visibility, but this change is useful on its own because it fixes replication for rules with multiple components that were inserted on different ticks.

For example, you have a replication rule for (A, B). You spawn an entity with A, and on the next tick you insert B. Without this change, B is replicated, but A is wrongly considered as sent. I added a test for it.

Implementation details

Inside ClientTicks, we now store a HashSet<ComponentId> for each entity in addition to ticks. To make it look nicer, I wrapped them in an EntityTicks struct. I also renamed mutations to entities because it fits better (it's not only for mutation ticks - it's also updated on insertions and removals). To avoid double hashing for mutations, I switched to using the entry API and made the field mutable. Because of this change, I also had to remove the is_new_for_client helper (in one place I need entry API and in another it's a simple contains check). I adjusted the doc comment and with the new naming it should still be clear.

MutateInfo now stores a Vec<ComponentId> for each entity, and I update the acknowledged components inside EntityTicks.

During removals, we now need to remove components from the acknowledged lists, so I adjusted the logic similarly to how we collect changes.

@Shatur Shatur requested a review from UkoeHB November 2, 2025 18:50
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.79%. Comparing base (394b438) to head (2066211).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/server.rs 93.33% 4 Missing ⚠️
src/server/replication_messages/updates.rs 93.47% 3 Missing ⚠️
src/shared/replication/client_ticks.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #604      +/-   ##
==========================================
- Coverage   91.90%   91.79%   -0.11%     
==========================================
  Files          58       58              
  Lines        3310     3364      +54     
==========================================
+ Hits         3042     3088      +46     
- Misses        268      276       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

We'll need this for per-component visibility, but this change is useful
on its own because it fixes replication for rules with multiple
components that were inserted on different ticks.

For example, you have a replication rule for `(A, B)`. You spawn an
entity with `A`, and on the next tick you insert `B`. Without this
change, `B` is replicated, but `A` is wrongly considered as sent. I
added a test for it.
@Shatur Shatur force-pushed the component-tracking branch from 800f5b6 to 2066211 Compare November 3, 2025 16:11
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