Skip to content

Conversation

@tariknz
Copy link
Owner

@tariknz tariknz commented Jun 28, 2025

  • Fixes the blurriness when resizing canvas
  • Improves performance by throttling telemetry updates to 2Hz and interpolating changes
  • Memoizing some frequently called functions
  • Added a story to view all tracks easily

Copilot AI review requested due to automatic review settings June 28, 2025 11:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the TrackCanvas component by adding throttled updates, memoization of heavy objects (SVG paths, Path2D, colors, constants), and high-DPI canvas scaling, and also adds an “AllTracksGrid” Storybook preview of every track.

  • Throttle driver position updates to 2 fps and skip redraws when data hasn’t changed
  • Memoize SVG/Path2D objects, color lookups, and calculation functions
  • Improve canvas resizing for high-DPI displays and maintain aspect ratio
  • Add an AllTracksGrid Storybook story to view all tracks at once

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/frontend/components/TrackMap/TrackCanvas.tsx Added throttling logic, memoization, high-DPI scaling, optimized draw loop
src/frontend/components/TrackMap/TrackCanvas.stories.tsx Imported tracks.json and added “AllTracksGrid” story
Comments suppressed due to low confidence (2)

src/frontend/components/TrackMap/TrackCanvas.tsx:56

  • [nitpick] The variable name line is ambiguous—consider renaming it to something like svgPathElement or svgPath to clarify its purpose.
  const line = useMemo(() => {

src/frontend/components/TrackMap/TrackCanvas.tsx:39

  • [nitpick] The new throttling logic around POSITION_UPDATE_INTERVAL would benefit from unit tests to verify that position updates occur at the correct intervals and under the correct change thresholds.
const POSITION_UPDATE_INTERVAL = 500;

@tariknz tariknz merged commit b3194e3 into main Jun 28, 2025
1 check passed
@tariknz tariknz deleted the chore/track-map-performance branch June 28, 2025 22:58
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