fix: reduce macOS popup compositing cost

This commit is contained in:
2026-08-18 02:30:05 +08:00
parent 13bdc0c9ba
commit 0f761f33b3
5 changed files with 233 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
# Task: Diagnose macOS popup lag
## Identity
- Task ID: 20260818-macos-popup-lag-7c4e
- Mode: Feature
- Branch: codex/20260818-macos-popup-lag-7c4e-macos-popup-lag
- Worktree: D:\Datas\OthersProjects\makelore-macos-popup-lag
- Base commit: 13bdc0c9bab656aa9ff6c990bf6359f7d3210750
- Owner: developer
- Status: Completed
## Scope
- Diagnose the reported macOS-wide popup lag in the Electron client, with emphasis on the shared Renderer Dialog/Sheet and transient popup compositing path.
- Build a repeatable Electron E2E frame-budget/computed-style probe, minimize it to the shared popup seam, implement the smallest platform-safe rendering fix, and add a regression check.
- Do not change firmware, cloud contracts, authentication, provider/runtime behavior, or the unowned primary worktree.
## Intent And Constraints
- Preserve the single Makelore light visual system and existing popup behavior, focus management, accessibility, and Main-owned boundaries.
- The available environment is Windows, so macOS behavior must be simulated through the exposed Electron platform marker; real signed macOS physical/package validation remains unverified.
- Keep the existing global hardware-acceleration policy unchanged unless a reproducible seam proves it is the cause; prefer removing only the expensive transient popup filter path.
- The shared popup regression owns only its test file and the platform/compositing files assigned during implementation; unrelated peer work remains isolated.
## Outcome
- Diagnosis isolated the shared Renderer popup compositing seam: the real Settings
Dialog rendered `backdrop-filter: blur(3px)` on its overlay and
`blur(18px) saturate(1.35)` on its glass surface. A repeatable probe observed a
62.5 ms maximum frame gap and one frame over 32 ms before the filter-only
intervention; disabling those filters reduced the observed gap to about 31.4
ms with no frame over 32 ms in this environment.
- Implemented a platform-scoped fix. Renderer startup writes
`html[data-platform]` from the existing Electron platform value. On Darwin,
transient popup roots and their `glass-surface` descendants disable both
standard and WebKit backdrop filters and use an opaque background. Win32 and
other platforms retain the existing glass material.
- Main/IPC, hardware-acceleration policy, native vibrancy, and unrelated popup
behavior were left unchanged. The fix is limited to the assigned Renderer
platform/style seam and its regression test.
## Verification
- `corepack pnpm@10.33.4 run build:vite` — passed (existing chunk-size and
dynamic-import warnings only).
- `corepack pnpm@10.33.4 run typecheck` — passed.
- `corepack pnpm@10.33.4 exec eslint src/main.tsx tests/e2e/popup-performance.spec.ts`
— passed.
- `corepack pnpm@10.33.4 exec vitest run tests/unit/modal-layering.test.tsx` —
passed (2 tests).
- `corepack pnpm@10.33.4 test` — passed (176 files, 2,109 tests).
- `corepack pnpm@10.33.4 exec node ./node_modules/@playwright/test/cli.js test
tests/e2e/popup-performance.spec.ts --reporter=line` — passed (1 test).
- `git diff --check` — passed.
- The E2E regression confirms the actual Electron platform marker, Darwin
computed filters are `none`, and non-Darwin computed filters remain enabled.
It intentionally does not enforce a hard RAF budget because shared CI
scheduling is not a stable compositor benchmark.
- Real signed macOS package/physical GPU-vibrancy A/B validation was not
available on this Windows host and remains required before claiming measured
macOS frame-time improvement.
## Follow-ups
- Run the popup E2E and a short Performance trace against a signed macOS x64 and
arm64 package, including a Sheet and nested Dialog path.
- If popups remain slow with computed filters disabled, A/B the existing
`app.disableHardwareAcceleration()` and Darwin transparent/vibrancy window
material on real hardware before changing either global policy.
## Promotion Candidates
- No canonical architecture or product decision is proposed. Keep the
platform-scoped rendering rule and the evidence topic task-scoped until real
macOS measurements confirm the compositor result.