Skip to content

perf(menubar): cache native images - #547

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-menubar-native-image-cache-pr
Closed

perf(menubar): cache native images#547
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-menubar-native-image-cache-pr

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What Changed

  • Added a bounded main-process NativeImage cache for MenuBarExtra tray and menu item icons.
  • Reused cached decode/resize results across accepted payload updates while keying by source, logical size, bitmap scale, resize quality, and template state.
  • Preserved SVG fallback, retina PNG iconBitmapScale, template-image behavior, emoji title fallback, and menu item click routing.
  • Avoided the initial double tray icon resolution when creating a new tray.
  • Added focused mocked-native-image regression coverage with before/after counters.

Why

Extensions with ticking menu-bar titles or item labels can still send accepted updates where icon sources are unchanged. Previously the main process rebuilt NativeImage objects and resized icons on every accepted payload, which could add visible menu-bar lag.

The new focused metric covers 20 repeated accepted updates with 1 tray icon and 36 item/submenu icons: native decode/read/resize operations drop from 1620 before caching to 81 after caching.

Compatibility Impact

Behavior should stay compatible with current MenuBarExtra rendering. Path icons refresh when file size or mtime changes, SVG fallbacks are still used when native path decoding returns empty, template images are cached separately from non-template images, and the cache is bounded and cleared on quit.

How Tested

  • node --no-warnings --test scripts/test-menubar-native-image-cache.mjs
  • pnpm run build:main
  • Codex LSP diagnostics for src/main/menubar-native-image-cache.ts
  • Codex LSP diagnostics for src/main/main.ts

Stack Validation

Clean PR branch codex/perf-menubar-native-image-cache-pr was created from origin/main and contains only the menubar native image cache fix.

@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated runtime lifecycle/icon churn PR #558: #558

@JustYannicc JustYannicc closed this Jul 3, 2026
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