perf(engine): rebuild card children only on appearance change #112
Reference in New Issue
Block a user
Delete Branch "fix/card-move-anim-jank"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Rhys reported the card move animation is janky on a Galaxy Fold 7 (not general lag — specifically the slide).
Root cause: every move fires
StateChangedEvent->sync_cards, which rebuilt the full visual for all 52 cards — despawning and respawning every child entity (drop-shadow, border frame, and on Android aText2dcorner label needing a glyph re-layout) even for the ~50 cards that did not move. That ~250 entity despawn/spawns plus 52 text re-layouts in a single frame spikes theStateChangedEventframe and stutters the short slide animation, very visible on a high-resolution display.Fix
Add a
CardChildrenKeycomponent capturing the only inputs the child entities depend on (face_up,card_size,color_blind,high_contrast).update_card_entitynow rebuilds children only when that key changes (a flip, resize/fold, or accessibility toggle); a position-only move just updates theTransform. TheSpriteis still refreshed every sync (a cheap handle swap), so theme/card-back image changes need no child rebuild.Result: a typical move touches children for only the 0-1 cards that actually flipped, instead of all 52.
Adds a regression test asserting an appearance-neutral
StateChangedEventno longer despawns/respawns card label children. Workspace clippy + tests green.Helps universal Android performance; Rhys to confirm the on-device improvement on the Fold 7.
🤖 Generated with Claude Code