Skip to content

perf(mac): reduce idle memory via lazy window lifecycle and overlay texture collapse - #137

Open
doxncwfn wants to merge 1 commit into
darrenprx:mainfrom
doxncwfn:perf/mac-idle-memory
Open

doxncwfn wants to merge 1 commit into
darrenprx:mainfrom
doxncwfn:perf/mac-idle-memory

Conversation

@doxncwfn

Copy link
Copy Markdown

What and why

Reduces background idle memory on macOS from ~170–180 MB down to ~80–90 MB without breaking visual fidelity or input latency:

  • Ephemeral Settings Window: The React/Fluent UI Settings window is no longer pre-allocated or kept hidden in the background. It is instantiated lazily when requested and destroyed immediately on close, freeing ~50–80 MB of V8 and Blink DOM memory while hiding the Dock icon.
  • 1x1 Parked Overlay Framebuffer Collapse: On macOS Retina displays, parked empty overlay windows are collapsed to 1x1 at (-10000, -10000), immediately releasing the ~30 MB Metal IOSurface GPU texture. Monitor bounds are restored synchronously on raising events (wheel-open, ping, emote).
  • Lazy Audio Decoding & Suspension: Sound files decode on demand rather than at startup. Decoded buffers not assigned to active wheel slices are evicted, and AudioContext suspends after 15s of silence.
  • Ephemeral Room Panels: Room roster and vote windows are destroyed when idle or when leaving a room.
  • V8 Ceilings: Appends conservative flags (--max-old-space-size=64, --renderer-process-limit=2).

How I tested it

  1. npm run typecheck (clean)
  2. npm run test:helper (1251 tests passed)
  3. npm test (all 129 Vitest test suites, 2046 tests passed)
  4. Built and installed production package (electron-builder --mac --arm64 --dir) into /Applications/lolPing.app.
  5. Profiled memory via ps and footprint on macOS arm64: idle dirty footprint dropped by ~50%.
  6. Verified Option + drag wheel gestures, audio playback, slice transitions, and Settings window open/close behavior.

Ran by hand on:

  • Windows 11
  • macOS (Apple Silicon)

Checklist

  • npm run typecheck, npm run test:helper and npm test pass
  • New logic has tests; a bug fix has a test that fails without it, or I explained why it can't
  • User-facing text is in both English and Chinese (src/shared/i18n.ts, both READMEs)
  • docs/design.md is updated if the behaviour it describes changed
  • Screenshot attached if something visible changed
  • If I used an AI tool, it had AGENTS.md in context and I read the whole diff. Tool: Antigravity

…exture collapse

- Ephemeral Settings window: instantiate lazily on demand; destroy
  immediately on close to reclaim 50-80 MB V8 and Blink DOM memory.
- Collapse parked empty overlay window to 1x1 offscreen on macOS to
  immediately release fullscreen Metal IOSurface textures while idle.
  Restore full bounds synchronously on raising channels.
- Lazy-load and decode audio buffers on demand, evict unused custom
  emote buffers, and suspend AudioContext after 15s of inactivity.
- Destroy room member and vote panel windows when idle or leaving a room.
- Add conservative V8 heap and renderer limits (--max-old-space-size=64,
  --renderer-process-limit=2).
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