Repository navigation
perf(glyph): cache decoded glyph frames and stop ticking still tiles - #16
Conversation
Glyph.image(frame:) read and decoded two PNGs from the bundle on every call, including from SwiftUI body and the menu bar animation. It now caches each decoded glyph frame, which drops a call from about 0.50 ms to well under 0.001 ms (1,000 calls: 504 ms uncached, 0.18 ms cached). The Menu Bar settings tiles also render a static image instead of a 4 Hz TimelineView when motion is off, Reduce Motion is on, or the glyph has a single awake frame.
|
@coderabbitai review |
Walkthrough
Merge Risk:
|
|
|
@coderabbitai review |
✅ Action performed
|
There was a problem hiding this comment.
🔇 Additional comments: 1
Sources/DilatedUI/Glyph.swift-30-30: 1
30-30:Minor · Functional Correctness · Quick win
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Keep caller mutations out of the cache.
If a caller changes the returned image’s
sizeorisTemplate, later callers receive that modified image. Previously, each request returned a fresh image. Cache the decoded representations and return an independent image to each caller; update the identity test accordingly.

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6af7abce-159e-4888-9d59-30f83e06202a
Files selected for processing: 3-
Sources/DilatedUI/Glyph.swiftSources/DilatedUI/Settings/SettingsWindow.swiftTests/DilatedUITests/GlyphTests.swift
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
-
|
Fixed in #110 (f2d4bf5) for the next release. Decoded glyph prototypes stay cached, while callers receive independent images and bitmap representations. The regression changes image size, template state, representation size and pixel bytes, then verifies a fresh request is unchanged. It failed before the fix and passes now. This is on dev/m2, not in the published beta.12. |
Glyph.image(frame:)read and decoded two PNGs from the bundle on every call, with no cache. It runs from the sidebar logo in body, from the menu bar animation, and from four 0.25 s TimelineViews on the Menu Bar settings page. Those tiles also kept ticking with motion off, with Reduce Motion on, or for Cat cans, which only has one awake frame.Decoded frames are now cached per glyph and frame, so repeat calls return the same image. A new
animates(motion:reduceMotion:)decides whether a tile needs the TimelineView at all, and still tiles just draw the still frame.Measured on 1,000 calls of
Glyph.bugEyes.image(frame: "on0"): about 504 ms uncached (around 0.5 ms a call) versus 0.18 ms cached.Done when: decoded glyph frames are cached per frame and static glyphs skip TimelineView.
Verify:
bash scripts/verify.shpasses. New GlyphTests check that repeat calls return the same instance, and thatanimatesis false only whereframe()is constant across elapsed times. SettingsRenderTests still pass.Summary by CodeRabbit