fix: stale archetype edge cache causing entity query dropout#81
fix: stale archetype edge cache causing entity query dropout#81Donach wants to merge 1 commit intocsprance:mainfrom
Conversation
Entities were intermittently "dropping out" of system queries after being processed for only a few frames. Root cause: the archetype edge cache was returning stale archetype instances that were no longer in the world's canonical archetypes dictionary. Changes: - archetype.gd: Add version counter for mutation tracking - system.gd: Check version before/after snapshot to detect mutations - world.gd: Validate edge cache returns canonical archetype instance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughThis PR introduces mutation tracking and defensive snapshot mechanisms to prevent race conditions in the Entity Component System. It adds a Changes
Sequence Diagram(s)sequenceDiagram
participant System as System (Processing)
participant Archetype as Archetype
participant World as World (Cache)
System->>Archetype: snapshot_version = archetype.version
System->>System: duplicate component columns
System->>System: iterate with snapshots
alt Entity mutation occurs mid-frame
Note over Archetype: version incremented
System->>Archetype: check version after process
System-->>System: version changed? emit warning, skip
else No mutation
System->>Archetype: version unchanged
System->>System: continue processing normally
end
alt Archetype cache stale
World->>World: new_archetype from edge cache
World->>World: find canonical archetype
World->>World: reconcile & update edges
World->>Archetype: point to canonical
else Cache valid
World->>Archetype: direct canonical access
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This should be resolved in v7.0.0. Thanks for this I took your idea and went a slightly different direction with it, but I appreciate you pointing out this issue it was not noticed! Great work! |
Entities were intermittently "dropping out" of system queries after being processed for only a few frames. Root cause: the archetype edge cache was returning stale archetype instances that were no longer in the world's canonical archetypes dictionary.
Changes:
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.