Skip to content

Cut macOS visualizer render cost - #27

Merged
SunkenInTime merged 6 commits into
weaver-mainfrom
agent/macos-visualizer-perf
Aug 3, 2026
Merged

Cut macOS visualizer render cost#27
SunkenInTime merged 6 commits into
weaver-mainfrom
agent/macos-visualizer-perf

Conversation

@SunkenInTime

Copy link
Copy Markdown
Owner

What changed

  • cache registered-image fingerprints instead of hashing unchanged bytes every frame
  • render translucent solid rectangles as direct premultiplied-alpha Metal quads
  • project paint-only immediate Canvas command updates without rebuilding the retained view tree
  • allow applications to choose their production trace default while retaining explicit trace modes

Why

The Weaver audio visualizer was spending CPU in repeated image hashing, raster fallback, full view rebuilds, and per-frame event-journal writes. These changes remove those costs at the Native rendering/runtime seams without introducing a visualizer-specific primitive.

Impact

Canvas widgets with stable structure can update paint commands without re-running layout, semantics, or accessibility projection. Translucent flat rectangles remain on the GPU fast path. Ordinary Native applications retain their existing trace default unless they opt out.

Validation

  • zig build test
  • zig build test-widget-profile
  • zig build test-desktop-canvas-widget
  • zig build test-desktop-ui-shell
  • zig build test-macos-shared-renderer-images
  • zig build -Doptimize=ReleaseFast
  • zig build -Dtarget=x86_64-windows -Doptimize=ReleaseFast

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 50bbf963-6715-4196-8afe-fa5568494301

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown

Greptile Summary

This change reduces retained-canvas rendering overhead by caching registered-image fingerprints, drawing translucent solid rectangles directly with premultiplied Metal blending, adding paint-only immediate-command updates, and allowing apps to choose a default trace mode.

The potential stale-secondary-window failure was disproved: the null-platform UI-shell test exercised a same-revision update initiated from a secondary window and confirmed that the primary canvas remains projected while the installed secondary window rebuilds with the updated model state.

Confidence Score: 5/5

The PR is safe to merge; no blocking failure remains.

The cross-window retained-update behavior was exercised end to end on both the parent revision and this change, with the UI-shell test shard succeeding and the secondary retained tree reflecting the model update.

T-Rex T-Rex Logs

What T-Rex did

  • I inspected the same-revision projection path in src/runtime/ui_app.zig:1121-1129, which shows it updates the primary canvas and then calls applyWindows(runtime) and rebuildWindowSlots(runtime).
  • I ran the build command /tmp/trex-zig/zig-x86_64-linux-0.16.0/zig build test-desktop-ui-shell -Dplatform=null for parent revision 0d2d2ae and PR head ad6172a, and both runs exited successfully.
  • I exercised the secondary retained-tree flow by opening a declared secondary window, installing its canvas, dispatching Bump through that canvas, and verifying the retained layout contains 'bumped 1'.
  • I reviewed the secondary retained-tree rebuild loop at src/runtime/ui_app.zig:1906-1911 and the declared-window reconciliation at 1723-1751 to understand how they participate in the projection.
  • I noted that the real-flow assertion was added in tests under ui_app_window_tests.zig:50-64 and 216-231 to validate projector target behavior.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (3): Last reviewed commit: "Project updates onto the primary canvas" | Re-trigger Greptile

Comment thread src/runtime/ui_app.zig Outdated

Copy link
Copy Markdown
Owner Author

@greptileai

Comment thread src/runtime/ui_app.zig Outdated

Copy link
Copy Markdown
Owner Author

@greptileai

@SunkenInTime
SunkenInTime marked this pull request as ready for review August 3, 2026 07:03
@SunkenInTime
SunkenInTime merged commit 4c5c099 into weaver-main Aug 3, 2026
1 of 2 checks passed
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.

1 participant