Skip to content

v1.4.2 · 修复菜单点击无响应

Choose a tag to compare

@Azhu9701 Azhu9701 released this 07 Oct 10:53
· 2 commits to main since this release

GT 工具箱 v1.4.2

修复:菜单栏图标经常点了没反应。

根因

点击菜单时,App 在主线程做了同步硬件 I/O,显示器状态不佳时就会卡住整个点击:

  1. 每次打开菜单都同步执行设备重发现(DDCDisplay.discover:遍历 IORegistry、创建 IOAVService,数百毫秒起)
  2. 打开菜单时对 DDC 显示器做同步 I2C 读(音量 + 静音各一次,单次可达数百毫秒)
  3. 每 15 秒的设备轮询同样在主线程同步重发现——点在那一刻就"没反应"
  4. 键盘音量键的静音操作也有一次同步 DDC 读

显示器睡眠唤醒、切换信号源的瞬间,上述调用耗时进一步放大。另外常驻无窗口的菜单栏 App 会被 App Nap 挂起,空闲后的首次点击要等进程唤醒。

修复

  • 菜单构建/滑杆/图标全部改用缓存读数(DDC 用 3 秒轮询快照),点击路径零硬件 I/O
  • 设备重发现移到后台线程,完成后回主线程应用
  • 菜单打开时异步刷新一次 DDC 快照,结果就地更新滑杆与图标
  • 音量/静音写入后乐观更新缓存,界面即时跟上
  • NSAppSleepDisabled:禁用 App Nap,常驻进程不再被挂起

English: Fixes the menu bar icon often feeling unresponsive on click — the menu-open path did synchronous DDC device discovery and blocking I2C volume/mute reads on the main thread (plus a synchronous re-discovery every 15 s), which stalls for hundreds of ms when displays are asleep or switching sources; App Nap also suspended the agent between clicks. The menu now builds purely from cached state, discovery moved to a background queue, and App Nap is disabled.