Comfy-Org / Comfy-Org/ComfyUI_frontend
Reuse one minimap data source per redraw
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 702
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 512
Description
## Summary
Reuse one minimap data source for each minimap redraw.
The current redraw path constructs one data source while updating viewport bounds and another data source while rendering the minimap canvas. `AbstractMinimapDataSource.cachedNodes` is scoped to one instance. The node-list memoization therefore reduces three builds to two builds per redraw, not one.
## Required changes
Thread a single `IMinimapDataSource` instance through the minimap redraw flow:
- Create the data source once in `updateMinimap`.
- Pass it to `updateBounds(...)`.
- Pass it to `renderMinimapToCanvas(...)`.
- Update the related renderer and viewport interfaces as needed.
- Use `layoutStore.layoutVersion` as the invalidation key if a future change extends the data-source lifetime beyond one redraw.
## Rationale
This change removes the remaining duplicate node-list build in each redraw. It also makes the data-source lifetime explicit before culling or LOD work hoists data sources outside the render loop.
## Affected areas
- `src/renderer/extensions/minimap/data/AbstractMinimapDataSource.ts`
- `src/renderer/extensions/minimap/composables/useMinimapRenderer.ts`
- `src/renderer/extensions/minimap/composables/useMinimapViewport.ts`
- `src/renderer/extensions/minimap/minimapCanvasRenderer.ts`
- Minimaps tests that cover node construction and redraw behavior
## Acceptance criteria
- Each minimap redraw creates one data source instance.
- Bounds calculation and canvas rendering use that same instance.
- Node data is built at most once per redraw.
- Existing minimap rendering and bounds behavior remains unchanged.
- Tests verify that the data source is reused during one redraw.
## Backlinks
- Requested by @christian-byrne.
- Pull request: https://github.com/Comfy-Org/ComfyUI_frontend/pull/15029
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/15029#discussion_r3778403494
Contributor guide
Assessment
This issue has not been assessed yet.