perf: reduce per-frame allocations and fix memory leaks#40
Open
genebean wants to merge 1 commit into
Open
Conversation
- Cache computed theme colors in set hass so drawing functions do not call getComputedStyle on every animation frame - Bind animation callback once (_boundDrawClock) instead of allocating a new closure on every requestAnimationFrame call - Replace manual ctx.rotate undo math with ctx.save/ctx.restore in all drawing functions, eliminating floating-point drift risk - Replace DOM div creation in drawNumbers with ctx.measureText for font height, eliminating forced reflow on every frame - Fix clearRect: was only clearing top-left quadrant; now clears full canvas (canvas.width/2, canvas.height/2 → canvas.width, canvas.height) - Fix CSS property name typo: '--primary-background-color:' → without ':' - Store ResizeObserver as instance variable and add disconnectedCallback to disconnect it (and cancel pending rAF/timeout) when card is removed - Move resize debounce timeout to per-instance (_resizeTimeout) so multiple clock cards on the same dashboard don't clobber each other's timers; remove module-level resizeTimeout/resizeDelay/debouncedOnResize No behavior changes — VERSION remains 0.9.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I really like this card but the bugs were bothering me so I got Claude Code to help me make things better. This is the first of a set of 3 PRs that when combined are what I am now using at home.
No behavior changes — VERSION remains 0.9.0.