- 
                Notifications
    You must be signed in to change notification settings 
- Fork 16
Additional performance improvements for trackmap #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
         tariknz
  
      
      
      commented
      
            tariknz
  
      
      
      commented
        Jul 15, 2025 
      
    
  
- Precalculate x/y coordinates for track percentage
- Update track direction list
- Hide broken tracks
- Better resize logic to use observer instead
- Reduce complexity around throttling
…culate it at runtime
There was a problem hiding this 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 enhances TrackMap performance by precalculating SVG points, refining direction logic, and improving rendering/resizing behavior.
- Pre-calculate SVG path points and total lengths via a new preCalculatePointsutility.
- Refactor findDirectionto use a dedicatedanticlockwiseTracksarray.
- Introduce a broken-tracks registry and conditional rendering to hide unsupported tracks in production.
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description | 
|---|---|
| tools/svg-utils.ts | Extract anticlockwiseTracksarray infindDirectionand addpreCalculatePoints. | 
| tools/generate-paths-json.ts | Invoke preCalculatePointsand includetotalLengthin generated JSON. | 
| src/frontend/components/TrackMap/tracks/broken-tracks.ts | New module listing broken tracks and helper functions. | 
| src/frontend/components/TrackMap/hooks/useDriverProgress.tsx | Filter out pace car using useSessionStore. | 
| src/frontend/components/TrackMap/TrackDebug.tsx | Add debug component for missing or broken track data. | 
| src/frontend/components/TrackMap/TrackCanvas.tsx | Refactor canvas: remove manual throttling, use ResizeObserver, hide broken tracks. | 
| src/frontend/components/TrackMap/TrackCanvas.stories.tsx | Add stories for single-driver view and a broken-tracks grid. | 
Comments suppressed due to low confidence (2)
tools/svg-utils.ts:111
- The function preCalculatePointsusessvgPathPropertiesbut there is noimport { svgPathProperties }at the top of the file; add the import to prevent a ReferenceError.
export const preCalculatePoints = (pathData: string): { x: number; y: number }[] => {
src/frontend/components/TrackMap/TrackCanvas.stories.tsx:429
- The variable sampleDatais not defined in this scope, which will cause a runtime error; ensure you import or define a valid drivers array for the story.
                  drivers={sampleData} 
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>