⚡ Bolt: optimize Sprite component rendering and asset loading#75
Conversation
- Wrap Sprite component in React.memo to prevent redundant re-renders. - Implement WeakMap caching for manifest sheet size calculations to turn O(N) work into O(1) lookups. - Coalesce concurrent network requests for the same manifest file using a pending promise cache. - Replace hardcoded tile size constants with MAP_CONSTANTS.TILE_SIZE for consistency. - Address ESLint warnings for floating promises and dynamic deletes. Co-authored-by: b0x1 <21123655+b0x1@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR implements a set of systemic performance optimizations for the
Spritecomponent, which is used extensively for rendering tiles, units, and resources.💡 What:
Spritecomponent inReact.memoto skip re-renders when props haven't changed.calculateSheetSizeoutside the render loop and used aWeakMapto cache results. Previously, thispendingManifestscache to ensure that if multiple sprites request the same manifest (e.g., during map loading), only onefetchcall is made.🎯 Why:
The
Spritecomponent is a high-frequency leaf component. In screens like the Settlement Screen or during map panning, hundreds ofSpriteinstances can be active. Reducing the per-instance overhead significantly improves UI responsiveness and reduces CPU/Network spikes.📊 Impact:
🔬 Measurement:
pnpm run check(Lint/Type/Test) passes.PR created automatically by Jules for task 2004112129294971924 started by @b0x1