perf(menubar): 隔离卡片动效并推进 1.1 低开销版本
This commit is contained in:
@@ -9,6 +9,19 @@
|
||||
- 依据当前源码重写功能说明、架构、指标口径与开发指南,集中维护测试命令和验收边界。
|
||||
- 清理旧阶段方案、路线图、设计参考图及过程验收记录,历史保留在 Git 中。
|
||||
|
||||
## [1.1] - 2026-11-07
|
||||
|
||||
### 性能
|
||||
|
||||
- 资源卡片使用独立原生宿主,缩小数字动画和局部状态更新影响的呈现范围;保留系统数字滚动、平滑曲线和圆环插值。
|
||||
- 常规采样允许系统合并定时唤醒,原生动画共用一次性收尾调度;暂停、隐藏和卸载仍立即取消。
|
||||
- 复用网络计数读取缓冲,保持 64 位计数、地址格式和接口变化时的差分基线规则。
|
||||
|
||||
### 验证
|
||||
|
||||
- 新增卡片宿主的真实窗口检查,覆盖数字动画中间帧、环境继承、状态保留、尺寸和卸载;扩展动画重定向与连续网络读取检查。
|
||||
- 本地测试包版本为 1.1(2);资源对照条件、结果与剩余验收见 `docs/v1.1-efficiency-plan.md`。
|
||||
|
||||
## [0.1.0] - 2026-10-29
|
||||
|
||||
### 新增
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
|
||||
<key>CFBundleName</key><string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key><string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key><string>1.0</string>
|
||||
<key>CFBundleVersion</key><string>1</string>
|
||||
<key>CFBundleShortVersionString</key><string>1.1</string>
|
||||
<key>CFBundleVersion</key><string>2</string>
|
||||
<key>XPCService</key><dict><key>ServiceType</key><string>Application</string></dict>
|
||||
</dict></plist>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
| [测试与验证](testing.md) | 独立检查程序、执行方式和人工验收边界 |
|
||||
| [极致轻量化与进程能耗方案](extreme-efficiency-plan.md) | 实施中:性能预算、逻辑浪费审查、真实能量列表、包体积收敛及分阶段验收 |
|
||||
| [同类开源工具 CPU 与功耗调研](open-source-efficiency-research.md) | Stats、MenuMeters、eul、macmon 的源码机制、与 Kymo 的差异及待验证优化方向 |
|
||||
| [1.1 低开销实施计划](v1.1-efficiency-plan.md) | 保留默认动效的卡片宿主隔离、唤醒合并、缓冲复用与本轮验证 |
|
||||
|
||||
首批实施证据见[轻量化实施记录](efficiency-first-batch.md);第二批见[能量列表与纯文字对照记录](efficiency-second-batch.md)。第三批见[原生绘制与进程表记录](efficiency-third-batch.md);第四批见[动效与效率排查](motion-and-efficiency-plan.md);其淡入实现已由[保留原动效的优化](motion-preservation-plan.md)替代。进程内存显示修正见[footprint 口径与单位对齐](process-memory-alignment-plan.md)。包体积已收敛,真实 CPU 能量列表已实现;内存与长期性能预算仍待通过。
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
SMARTService(XPC)──→ 温度 / 风扇 / SMART 客户端 ──→ 慢任务缓存
|
||||
```
|
||||
|
||||
`MetricsStore` 是 MainActor 上的可观察状态。新配置默认隐藏时不启动采样 Task,展开使用前台间隔;显式启用后台趋势时,隐藏使用后台间隔(新配置 30 秒)。旧配置中存在合法后台间隔且没有显式开关时保留启用状态与间隔,显式关闭优先。无后台需求时隐藏停止采样,重开重置速率基线并标记历史断点。周期以单调时钟按每轮开始时间安排,不补跑错过的批次;间隔修改按上次发布时间调整下一轮。
|
||||
`MetricsStore` 是 MainActor 上的可观察状态。新配置默认隐藏时不启动采样 Task,展开使用前台间隔;显式启用后台趋势时,隐藏使用后台间隔(新配置 30 秒)。旧配置中存在合法后台间隔且没有显式开关时保留启用状态与间隔,显式关闭优先。无后台需求时隐藏停止采样,重开重置速率基线并标记历史断点。周期以单调时钟按每轮开始时间安排,不补跑错过的批次;间隔修改按上次发布时间调整下一轮。等待显式允许周期 10% 的调度容差,前台最多 200ms、后台最多 1 秒;资源速率仍按实际经过时间差分,容差不改变配置值。
|
||||
|
||||
`SystemSampler` actor 持有 CPU、网络、磁盘 IO 差分基线。CPU / 内存每次 Mach 查询取得的 host 发送权在调用结束(含失败路径)释放。卷列表与进程读取放入 utility detached Task;温度、磁盘健康、电池健康独立更新缓存,各类慢任务最多一个在途;隐藏后台趋势不新发起传感器、卷或慢报告读取。慢指标可晚于快照更新,周期详见[监控指标](monitoring.md)。
|
||||
|
||||
@@ -68,11 +68,11 @@ CPU / GPU / 风扇合并为一次只读 XPC 请求,按到期类别选择读取
|
||||
|
||||
面板和资源卡片使用颜色资产中的不透明背景,顶部操作组使用低透明度静态胶囊背景;不再以全窗口液态玻璃概念图作为实现依据。品牌图标与颜色以 Assets 为运行时来源。
|
||||
|
||||
固定 frame 的面板宿主关闭 NSHostingView 自动尺寸协商。趋势图的坐标、图例、悬浮与业务投影继续由 SwiftUI 管理;曲线 / 网格 / 悬浮标记与百分比圆环分别由 UI 层的 NativePanelCurve、NativeMetricRing 使用 Core Graphics 绘制,静态输入、尺寸或外观变化时失效;默认短过渡由 MetricMotion 向原生 layer 添加有限 CATransition(250 ms),应用不建立逐帧计时器,使用 kCATransition 固定键,结束或取消时移除;每次仅安排一个可取消的 250 ms 清理截止,避免 AppKit backing layer 保留已结束对象,不逐帧更新几何。保留既有 PanelCurveGeometry 的真实时间、缺失值与断点规则。
|
||||
固定 frame 的面板宿主关闭 NSHostingView 自动尺寸协商。每张 ResourceCard 通过 UI 层 NativeContentHost 获得独立、固定尺寸的 NSHostingView,数字动画和局部状态更新在卡片宿主内处理;父层仍负责列数、卡片尺寸和窗口布局。完整 SwiftUI 环境注入子宿主,保留字体、前景样式、语言、外观与动效策略;更新沿用原有挂载身份,卸载时清空子宿主内容。坐标、图例、悬浮偏好与提示层都保留在同一卡片宿主内,不跨原生边界传递锚点。趋势图的业务投影继续由 Features 管理;曲线 / 网格 / 悬浮标记与百分比圆环分别由 UI 层 NativePanelCurve、NativeMetricRing 绘制。保留 PanelCurveGeometry 的真实时间、缺失值与断点规则。
|
||||
|
||||
进程表使用 MenuBar 的 NativeProcessTable(view-based NSTableView),继续消费 ProcessTableProjection 的搜索 / 排序 / 冻结投影。仅创建可见单元格,行数改变时增删尾行,刷新时原地修改可见文本与图像;选择以完整 ProcessIdentity 同步,用户选择 / 排序延后到委托回调之外写回 SwiftUI。原生 Esc 转发至原有分层退出逻辑,右键菜单保留复制能力。共享 ProcessIconCache 将 NSWorkspace 原图绘制为 30×30 像素、15pt 的单一位图,不保留原图;最多 128 项 / 1 MiB 解码像素,30 秒过期、LRU 淘汰、内存压力清空,不启动轮询。其预算不代表系统图标服务内部缓存已受控。
|
||||
|
||||
外观偏好保存独立的 reduceMotion(默认 false),设置提供减弱动画;MenuPanelView 根据手动 / 系统减弱动态效果、实际可见、暂停和睡眠计算并注入 UI 动效策略。默认数字沿用原系统 numericText 滚动 / 模糊与 0.35 秒无回弹 spring;曲线按原时间域公式预计算 61 个横向变换关键帧,由 Core Animation 做 0.35 秒 easeInOut 移动;网格与悬浮层独立,路径仅在数据 / 几何改变时构建。满 60 点保留一个出界点,渐变覆盖出界区。圆环由 CAShapeLayer.strokeEnd 做 0.35 秒 easeInOut 弧长插值,中断从 presentation 值继续。有限属性动画配一次性清理截止,不使用 opacity 替代,不设逐帧 CPU 定时器。数字相同值由 Equatable 子视图跳过重复求值;首次挂载直接显示,真实断点不插值。减弱动画使用静态数字 / 曲线 / 进度条。原生控件在策略禁用或离开窗口时取消过渡;风扇没有持续旋转或 TimelineView。后台记录仍只由 SamplingPreferences 控制,动效偏好不改变采样间隔和历史。此措施不代表面板内存预算已通过;剩余峰值与 CPU 未达标情况见[第三批记录](efficiency-third-batch.md)和[动效与第四批排查](motion-and-efficiency-plan.md);恢复原动效后的对照见[保留动效的优化记录](motion-preservation-plan.md)。
|
||||
外观偏好保存独立的 reduceMotion(默认 false),设置提供减弱动画;MenuPanelView 根据手动 / 系统减弱动态效果、实际可见、暂停和睡眠计算并注入 UI 动效策略。默认数字沿用原系统 numericText 滚动 / 模糊与 0.35 秒无回弹 spring;曲线按原时间域公式预计算 61 个横向变换关键帧,由 Core Animation 做 0.35 秒 easeInOut 移动;网格与悬浮层独立,路径仅在数据 / 几何改变时构建。满 60 点保留一个出界点,渐变覆盖出界区。圆环由 CAShapeLayer.strokeEnd 做 0.35 秒 easeInOut 弧长插值,中断从 presentation 值继续。有限属性动画共用一个一次性收尾定时器,弱引用注册、按到期时间清理并合并邻近截止;所有动画结束 / 取消后不保留周期定时器。替换动画更新自身截止,旧截止不会停止新动画;清理聚合窗口不改变 0.35 秒运动时长。不使用 opacity 替代,不设逐帧 CPU 定时器。数字相同值由 Equatable 子视图跳过重复求值;首次挂载直接显示,真实断点不插值。减弱动画使用静态数字 / 曲线 / 进度条。原生控件在策略禁用或离开窗口时取消过渡;风扇没有持续旋转或 TimelineView。后台记录仍只由 SamplingPreferences 控制,动效偏好不改变采样间隔和历史。历史失败记录见[第三批记录](efficiency-third-batch.md)和[动效与第四批排查](motion-and-efficiency-plan.md),恢复原动效后的对照见[保留动效的优化记录](motion-preservation-plan.md),1.1 改动与本轮验收见[1.1 计划](v1.1-efficiency-plan.md)。
|
||||
|
||||
`PanelResourceAudit` 与纯文字对照渲染器仅在 Debug 或显式 `KYMO_AUDIT` 编译条件下包含实现;普通 Release 不包含诊断驱动与文字列表实现。测试构建还需设置 `KYMO_RESOURCE_AUDIT=1` 才驱动真实面板测试生命周期,App 只装配调用。正常启动不创建测试任务;该入口不是鼠标 / AX 交互验证。诊断日志仍需 `KYMO_DIAGNOSTICS=1` 显式开启;实际启用动效的曲线数量以 animatedPlots 记录;审计标记附带原生图区数量 / 尺寸、悬浮状态和指针是否在面板内,窗口编号只在可见时读取。
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## 适用范围
|
||||
|
||||
当前产物:Kymo 1.0(build 1),macOS 27.0 及以上、Apple silicon arm64。Intel 或较低系统不在该产物支持范围。软件使用 ad-hoc 本地签名,未经过 Apple 公证,不是 Developer ID 官方分发包;下载后的系统提示取决于接收方安全策略。
|
||||
当前产物:Kymo 1.1(build 2),macOS 27.0 及以上、Apple silicon arm64。Intel 或较低系统不在该产物支持范围。软件使用 ad-hoc 本地签名,未经过 Apple 公证,不是 Developer ID 官方分发包;下载后的系统提示取决于接收方安全策略。
|
||||
|
||||
## 构建与校验
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
python3 tools/package_release.py
|
||||
```
|
||||
|
||||
默认输出:`dist/kymo-1.0-1-arm64-adhoc.zip` 和同名 `.sha256`。首次打包前会通过签名、Hardened Runtime、权限和包内容检查,ZIP 解压后再次检查。再次构建不覆盖已存在同名产物,可用 `--output` 另选目录。校验下载文件:
|
||||
默认输出:`dist/kymo-1.1-2-arm64-adhoc.zip` 和同名 `.sha256`。首次打包前会通过签名、Hardened Runtime、权限和包内容检查,ZIP 解压后再次检查。再次构建不覆盖已存在同名产物,可用 `--output` 另选目录。校验下载文件:
|
||||
|
||||
```bash
|
||||
shasum -a 256 -c kymo-1.0-1-arm64-adhoc.zip.sha256
|
||||
shasum -a 256 -c kymo-1.1-2-arm64-adhoc.zip.sha256
|
||||
```
|
||||
|
||||
SHA-256 用于核对文件是否与发布者给出的文件一致,不等同于 Apple 身份认证;校验值应从可信渠道获取。
|
||||
|
||||
+3
-1
@@ -18,7 +18,7 @@
|
||||
| SMART | `DiskHealthMonitor` → XPC → `diskutil info -plist` | 主目录所在卷关联报告中的寿命和通电时间;剩余寿命 = 100 − PERCENTAGE_USED(下限 0),通电小时要求高位为 0,多物理存储拒绝合并;不代表所有卷或磁盘 |
|
||||
| 电池 | `BatteryMonitor`,IOPowerSources 与 AppleSmartBattery | 电量、充电 / 外接电源、循环和功率;功率取电压 × 电流的绝对值,非整机功耗;区分无内置电池和读取失败 |
|
||||
| 电池健康 | `SystemBatteryHealthMonitor`,`system_profiler SPPowerDataType -json` | 使用系统报告的最大容量百分比,不用当前充电容量推算 |
|
||||
| 网络 | `NetworkMonitor`,`NET_RT_IFLIST2` 64 位计数与 `getifaddrs` | 累计收发计数不属于应用会话流量;速率按实际经过时间差分,回退或接口身份 / 地址变化时重建基线;本地地址保持系统 numeric formatter(含 scope),每轮共用缓冲、每接口最终排序一次 |
|
||||
| 网络 | `NetworkMonitor`,`NET_RT_IFLIST2` 64 位计数与 `getifaddrs` | 累计收发计数不属于应用会话流量;速率按实际经过时间差分,回退或接口身份 / 地址变化时重建基线;计数缓冲在采样器内复用,容量不足时扩容,仅解析本轮实际返回字节;本地地址保持系统 numeric formatter(含 scope),每轮共用地址缓冲、每接口最终排序一次 |
|
||||
| 网络路径 | `NetworkPathObserver`,NWPathMonitor | 可用 / 不可用 / 需连接;代码取 `availableInterfaces.first` 作为主接口候选,并非独立解析系统默认路由;路径可用不保证公网可达 |
|
||||
| 公网 IP | `PublicIPAddressService`,`https://api.ipify.org` | 外部 HTTPS 服务看到的出口地址,可受代理 / VPN 影响;不是所选接口的公网地址。请求会向该服务暴露出口 IP |
|
||||
| 进程 | `ProcessMonitor` + 只读 XPC,sysctl、`proc_pidinfo`、`proc_pidpath`、`proc_pid_rusage` | 进程身份用 PID + 启动时间防复用;CPU 用累计 user + system Mach tick 差分并换算纳秒,内存使用 physical footprint,权限受限字段留空 |
|
||||
@@ -48,6 +48,8 @@
|
||||
|
||||
传感器、卷与慢报告只在可见采样轮次检查是否到期;后台趋势不启动这些慢读取。快照中的慢指标可能来自之前的缓存;磁盘 / 电池健康快照带读取日期。暂停停止发布,不保证取消已进入系统调用的工作。
|
||||
|
||||
常规周期允许系统在配置周期 10% 的容差内合并唤醒,前台最多 200ms、后台最多 1 秒;不是严格实时截止。差分的时间分母始终取实际经过的单调时间,历史保留真实采样日期,配置周期不被改写。
|
||||
|
||||
## 兼容性边界
|
||||
|
||||
AppleSMC 和 GPU 驱动字段不是稳定公开的跨机型指标接口,缺失时应降级。磁盘报告、电池报告与进程读取受系统版本、硬件和沙盒权限影响。新增支持必须有实际采样和合理性核对,不从核心数、总利用率或其他传感器推导不存在的读数。
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
调研日期:2026-11-07。范围是 macOS 菜单栏监控工具 Stats、MenuMeters、eul,以及可借鉴采集实现的 Apple Silicon 命令行工具 macmon。本轮只增加调研文档,不修改采样、动效或应用架构。
|
||||
|
||||
后续改造与验证记录见 [1.1 低开销实施计划](v1.1-efficiency-plan.md);本文保留调研时的版本和判断边界。
|
||||
|
||||
最值得借鉴的机制是:按实际消费者决定是否采集和绘制、局部更新原生控件、复用采集状态、给周期任务调度容差,以及让两次数据更新之间真正空闲。Kymo 已实现其中多项;当前更值得优先核查的是数字动画与视图更新传播,而不是再次全面替换采集 API。
|
||||
|
||||
本轮结论来自固定版本源码与项目说明,**不是这四个工具在本机的 CPU / 瓦数排行榜**。同类项目也有高开销路径,不能把开源、原生或 Rust 等同于低功耗。本文将源码事实、Kymo 既有实测和待验证建议分开。
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
## 当前测试形态
|
||||
|
||||
1.1 新增 `NativeContentHostChecks`(`--gui`):在真实窗口检查系统数字滚动的中间帧、父级颜色 / 语言 / 动效环境继承、更新不重新挂载、固定尺寸和卸载。`NativeMetricDrawingChecks` 另覆盖多个动画合并收尾时的取消及重新定向,不把旧截止应用到新动画;`NetworkAddressChecks` 连续读取 30 轮,核对缓冲复用后的有效速率和地址格式。
|
||||
|
||||
`kymoTests/` 包含可独立编译的 Swift 检查程序和 Python 字符串检查,工程未创建 XCTest / UI 测试 Target;`kymoUITests/` 目前仅占位。以下命令在仓库根目录执行,每次只编译一个检查入口。需要实际应用包的命令必须传入本轮构建产物的绝对路径。
|
||||
|
||||
本页保留当前检查入口和验收边界,不沿用旧阶段报告中的“通过”结论。源码存在、命令可编译、独立程序通过、正式应用实测是不同层次的证据,每轮应记录实际执行项。
|
||||
|
||||
@@ -45,9 +45,53 @@
|
||||
|
||||
- [x] 检查工作区、架构、调研与实际调用链;开始时工作区干净。
|
||||
- [x] 在实施前建立本计划。
|
||||
- [ ] 本轮 Release 基线与组件归因。
|
||||
- [ ] 局部呈现优化及同视觉验证。
|
||||
- [ ] 调度 / 采集复用改动及回归。
|
||||
- [ ] 版本、文档、真实交互、Release 对照与本地测试包。
|
||||
- [x] 本轮 Release 短时基线与数字 / 曲线 / 圆环隔离;多轮最终复测仍待完成。
|
||||
- [x] 卡片宿主保留系统动画、环境和挂载身份;真实窗口中间帧检查通过,主观观感仍待用户验收。
|
||||
- [x] 调度容差、动画批次收尾和网络缓冲复用;相关及完整回归通过。
|
||||
- [x] 版本、文档、三轮 Release 对照与本地测试包;外部鼠标 / 键盘交互受工具阻碍,明确列为待验收。
|
||||
|
||||
本节在实施时记录最终保留 / 拒绝的决策、测量条件和剩余风险。
|
||||
|
||||
### 初步归因(实施中)
|
||||
|
||||
同机独立签名审计 Release、前台 2 秒、后台关闭,打开 30 秒后隐藏 8 秒。主程序 CPU 取打开第 10–30 秒,以 `proc_pid_rusage` CPU 差分经本机 Mach timebase 换算,单逻辑核 100%。完整默认约 16.47%;诊断中仅静态数字、保留曲线和圆环约 4.53%;仅保留数字动画约 17.54%。这些是顺序单轮,不是严格可相加的因果分解。
|
||||
|
||||
每个数字独立 NSHostingView 的试验约 20.26%,没有净收益,拒绝合入。继续验证按资源卡片隔离的宿主边界;不为了减小 CPU 直接将默认数字改静态。XPC 保持原安全校验,测试中的能量状态为 partial / waiting,不能声称全进程能量覆盖完整。
|
||||
|
||||
### 最终保留的宿主与构建检查
|
||||
|
||||
卡片宿主使用稳定的 `NSHostingView<AnyView>` 根节点,直接包装原有卡片内容和环境。带可选内容条件层的泛型根节点试验约 15.63–16.35% CPU,未复现较轻原型的收益;回到直接包装后复核约 9.48%。该差异为本机观察,不将其泛化为 AnyView 总比泛型快。
|
||||
|
||||
最终实现的独立真实窗口检查确认 numericText 中间帧、22pt 字体 / 红色前景 / 语言 / 动效策略继承、更新不重新挂载、尺寸跟随,以及宿主即使被外部保留也会释放卸载内容。Debug 构建和普通 Release 打包通过;完整入口实际运行 37 项 Swift 检查、211 条三语目录和主程序权限检查,包含真实 GUI、沙盒 HTTPS 和包内 XPC 服务。
|
||||
|
||||
普通 Release 为 1.1(2),主程序和 XPC 版本一致。测试 ZIP:`dist/kymo-1.1-2-arm64-adhoc.zip`,1,088,419 字节;SHA-256:`84d55db8f1ed3d3f5d6b451a9da2e03fe36445674cfc15e47bc6d0ce557ea807`。原包与解压副本的深层严格签名、Hardened Runtime、权限与内容检查通过。仍是本地 ad-hoc、未公证、arm64 / macOS 27+ 测试包,不上传、不替换已安装应用。
|
||||
|
||||
### 最终三轮 Release 对照
|
||||
|
||||
环境:Apple M4 Pro / 48 GiB / macOS 27.2,签名 arm64 Release;原版为 `c5fc4bb`,1.1 为本次保留实现。前台配置 2 秒、后台关闭、保留全部采样 / XPC / 进程 / 公网策略和默认动效;每轮独立启动,隐藏 3 秒、打开 30 秒、关闭 8 秒。按“1.1、原版、原版、1.1、1.1、原版”交错运行,测量期间没有并行构建或 GUI 检查。
|
||||
|
||||
审计副本使用独立测试 bundle ID,缩短显式诊断驱动,并加入用于组件隔离的静态数字 / 曲线 / 圆环开关;本表全部关闭这些静态诊断开关,不修改用户安装版及持久偏好。外部采集器每 200ms 读取主程序与其实际路径对应 XPC 的 `proc_pid_rusage`,CPU 以本机 Mach timebase 换算、单逻辑核 100%;CPU 归属功率使用 V6 `ri_energy_nj` 差分。打开区间取第 10–30 秒,足迹取区间中位数;峰值为进程截至该区间的累计峰值,关闭足迹为关闭后观测中位数。其余用户工作负载、鼠标与系统刷新策略未锁定,所以这些是本轮观察,不承诺固定收益。
|
||||
|
||||
| 版本 / 轮次 | 主 CPU % | 主 CPU 归属 W | 中断唤醒 / s | 展开足迹 MiB | 累计峰值 MiB | 关闭足迹 MiB | XPC CPU % | 实际平均采样 s |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| 原版 1 | 18.822 | 0.37869 | 18.06 | 166.05 | 201.53 | 196.20 | 0.464 | 2.097 |
|
||||
| 原版 2 | 18.396 | 0.36864 | 9.56 | 178.24 | 215.39 | 210.06 | 0.494 | 2.107 |
|
||||
| 原版 3 | 17.739 | 0.33676 | 15.04 | 189.86 | 225.63 | 220.30 | 0.511 | 2.079 |
|
||||
| 1.1 1 | 10.498 | 0.12004 | 4.94 | 61.00 | 64.14 | 53.69 | 0.454 | 2.120 |
|
||||
| 1.1 2 | 10.348 | 0.13483 | 7.07 | 61.08 | 64.17 | 53.14 | 0.467 | 2.140 |
|
||||
| 1.1 3 | 10.204 | 0.12749 | 13.20 | 60.61 | 63.06 | 55.81 | 0.484 | 2.158 |
|
||||
|
||||
三轮主进程中位数:CPU 18.396% → 10.348%(约下降 43.8%);CPU 归属平均功率 0.36864 W → 0.12749 W(约下降 65.4%);展开物理足迹 178.24 MiB → 61.00 MiB。主进程累计峰值从本组最高 225.63 MiB 降至 64.17 MiB;关闭后的本组足迹中位数约 53–56 MiB。XPC CPU 约 0.45–0.51%,并未被排除在观测之外。
|
||||
|
||||
容差会使实际刷新稍晚,本表明确报告实际周期;速率仍按真实时间计算。唤醒存在较大跨轮波动,中断唤醒与 package idle wakeups 也不是同一指标,不据此宣布长期唤醒预算通过。测试能量榜为 partial / waiting,候选覆盖不全不伪造完整榜单。
|
||||
|
||||
以上 W 仅是系统归属的 CPU 能量口径,未覆盖完整 GPU / WindowServer / 屏幕 / 网络 / 整机电池。不能称整机省电 65.4%,也未证明原极致轻量化预算全部通过。100 次同进程开关、8 小时、真实多显示器 / 刘海屏与主观观感仍需后续验收。
|
||||
|
||||
### 能力边界与交付验收
|
||||
+
|
||||
+- **通过**:最终 Debug / 普通 Release 构建;37 项独立 Swift 检查、三语目录、权限、真实原生窗口、沙盒 HTTPS 和包内服务。收尾补充有限尺寸防护后,重建 Debug / Release 并再次通过卡片宿主 GUI 检查。采样与 SwiftUI Instruments 轨道可附加到本轮测试 PID;本次短轨道仅用于验证工具可用,未用于数字热点归因,热点判断来自组件隔离与完整面板对照。
|
||||
+- **外部 UI 工具受阻**:CUA 分别按测试包路径与独立 bundle ID 读取,两次均返回 timeoutReached;随后应用清单未返回该副本。原因尚未确认,不推断为辅助功能权限缺失,也不将其他工具验证能力一并否定。没有取得可用元素索引,未执行 AX 点击、坐标点击、截图或键盘关闭;这些外部输入路径保持未验证。
|
||||
+- **整机功耗未验证**:本机 `powermetrics` 明确要求 superuser,本轮未提升权限或改变应用安全配置。只报告已取得的 rusage CPU 归属能量,不以它替代完整功耗。
|
||||
+- **用户验收操作**:自行退出旧版后从测试 ZIP 解压启动 1.1,检查左键开关 / 右键菜单、固定与解除、暂停 / 恢复、网络接口选择、图表悬浮、进程搜索与多次 Esc 关闭;比较默认数字滚动、曲线和圆环观感。真实多显示器 / 刘海屏、100 次同进程开关和 8 小时资源表现仍待验收。
|
||||
+
|
||||
+本轮不退出用户原有 PID 13241 / 13243,不安装、替换或推送。测试源码副本、进程、脚本、采样日志、轨道与临时构建在取证完成后清理;dist 保留本地 1.1 ZIP 和校验文件。
|
||||
|
||||
@@ -425,7 +425,7 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES;
|
||||
@@ -438,7 +438,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = cn.airnan.kymo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
REGISTER_APP_GROUPS = YES;
|
||||
@@ -458,7 +458,7 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
@@ -472,7 +472,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = cn.airnan.kymo;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
REGISTER_APP_GROUPS = YES;
|
||||
|
||||
@@ -18,6 +18,7 @@ nonisolated struct NetworkMonitor {
|
||||
private var previous: [String: (UInt64, UInt64)] = [:]
|
||||
private var timestamp: TimeInterval?
|
||||
private var identities: [String: String] = [:]
|
||||
private var counterBuffer: [UInt8] = []
|
||||
|
||||
static func rate(current: UInt64, previous: UInt64?, elapsed: TimeInterval) -> Double? {
|
||||
guard let previous, elapsed.isFinite, elapsed > 0, current >= previous else { return nil }
|
||||
@@ -25,7 +26,7 @@ nonisolated struct NetworkMonitor {
|
||||
}
|
||||
|
||||
mutating func sample() -> [NetworkInterfaceMetrics]? {
|
||||
guard let counters = Self.counters() else { previous = [:]; timestamp = nil; return nil }
|
||||
guard let counters = counters() else { previous = [:]; timestamp = nil; return nil }
|
||||
let now = ProcessInfo.processInfo.systemUptime
|
||||
let elapsed = timestamp.map { now - $0 } ?? 0
|
||||
let metadata = Self.interfaces()
|
||||
@@ -78,19 +79,19 @@ nonisolated struct NetworkMonitor {
|
||||
}
|
||||
|
||||
/// NET_RT_IFLIST2 exposes 64-bit counters, avoiding getifaddrs' 4 GB wrap.
|
||||
private static func counters() -> [String: (UInt64, UInt64)]? {
|
||||
private mutating func counters() -> [String: (UInt64, UInt64)]? {
|
||||
var mib: [Int32] = [CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST2, 0]
|
||||
// The interface list can grow between size and data queries.
|
||||
for _ in 0..<3 {
|
||||
var count = 0
|
||||
guard sysctl(&mib, u_int(mib.count), nil, &count, nil, 0) == 0 else { return nil }
|
||||
guard count > 0 else { return [:] }
|
||||
var bytes = [UInt8](repeating: 0, count: count)
|
||||
let success = bytes.withUnsafeMutableBytes { raw in
|
||||
if counterBuffer.count < count { counterBuffer = [UInt8](repeating: 0, count: count) }
|
||||
let success = counterBuffer.withUnsafeMutableBytes { raw in
|
||||
sysctl(&mib, u_int(mib.count), raw.baseAddress, &count, nil, 0)
|
||||
}
|
||||
if success != 0 { if errno == ENOMEM { continue }; return nil }
|
||||
return bytes.withUnsafeBytes { raw -> [String: (UInt64, UInt64)]? in
|
||||
return counterBuffer.withUnsafeBytes { raw -> [String: (UInt64, UInt64)]? in
|
||||
var result: [String: (UInt64, UInt64)] = [:]
|
||||
var offset = 0
|
||||
while offset < count {
|
||||
|
||||
@@ -16,6 +16,10 @@ final class MetricsStore {
|
||||
private var panelDemand: Bool { isPanelVisible && !isDisplaySleeping }
|
||||
var effectiveMilliseconds: Int { panelDemand ? sampling.panelMilliseconds : sampling.backgroundMilliseconds }
|
||||
private var hasSamplingDemand: Bool { !isSystemSleeping && (panelDemand || sampling.backgroundEnabled) }
|
||||
// Permit timer coalescing without changing the requested cadence or delta timestamps.
|
||||
private var schedulingTolerance: Duration {
|
||||
.milliseconds(min(effectiveMilliseconds / 10, panelDemand ? 200 : 1_000))
|
||||
}
|
||||
@ObservationIgnored private var generation = 0
|
||||
@ObservationIgnored private var visibilityGeneration = 0
|
||||
@ObservationIgnored private var task: Task<Void, Never>?
|
||||
@@ -59,7 +63,7 @@ final class MetricsStore {
|
||||
task = Task { [weak self, sampler] in
|
||||
guard !Task.isCancelled else { return }
|
||||
if initialDelay > .zero {
|
||||
do { try await Task.sleep(for: initialDelay) } catch { return }
|
||||
do { try await Task.sleep(for: initialDelay, tolerance: self?.schedulingTolerance) } catch { return }
|
||||
}
|
||||
if reset { await sampler.reset() }
|
||||
while !Task.isCancelled {
|
||||
@@ -98,7 +102,7 @@ final class MetricsStore {
|
||||
let interval = self?.effectiveMilliseconds ?? 5_000
|
||||
// Start-to-start cadence; missed deadlines do not trigger catch-up bursts.
|
||||
let deadline = sampledAt.advanced(by: .milliseconds(interval))
|
||||
do { try await Task.sleep(until: max(deadline, .now), clock: .continuous) }
|
||||
do { try await Task.sleep(until: max(deadline, .now), tolerance: self?.schedulingTolerance, clock: .continuous) }
|
||||
catch { return }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ extension EnvironmentValues {
|
||||
static let duration: TimeInterval = 0.35
|
||||
static let key = "kymo.metric.movement"
|
||||
private weak var layer: CALayer?
|
||||
private var deadline: DispatchSourceTimer?
|
||||
private static let cleanup = MotionCleanup()
|
||||
var isRunning: Bool { layer?.animation(forKey: Self.key) != nil }
|
||||
|
||||
func start(on layer: CALayer?, animation: CAAnimation) {
|
||||
@@ -28,11 +28,7 @@ extension EnvironmentValues {
|
||||
animation.isRemovedOnCompletion = true
|
||||
layer.add(animation, forKey: Self.key)
|
||||
// Backing layers may retain completed animations. Bound their lifetime explicitly.
|
||||
let deadline = DispatchSource.makeTimerSource(queue: .main)
|
||||
deadline.schedule(deadline: .now() + Self.duration, leeway: .milliseconds(10))
|
||||
deadline.setEventHandler { [weak self] in MainActor.assumeIsolated { self?.stop() } }
|
||||
self.deadline = deadline
|
||||
deadline.resume()
|
||||
Self.cleanup.register(self)
|
||||
}
|
||||
/// Cubic timing curve used by the original SwiftUI easeInOut animation.
|
||||
static func easeInOut(_ time: Double) -> Double {
|
||||
@@ -48,8 +44,62 @@ extension EnvironmentValues {
|
||||
}
|
||||
|
||||
func stop() {
|
||||
deadline?.cancel(); deadline = nil
|
||||
Self.cleanup.remove(self)
|
||||
finish()
|
||||
}
|
||||
|
||||
fileprivate func finish() {
|
||||
layer?.removeAnimation(forKey: Self.key); layer = nil
|
||||
}
|
||||
deinit { deadline?.cancel() }
|
||||
}
|
||||
|
||||
/// One one-shot timer serves the whole visible batch, retaining neither views nor motions.
|
||||
@MainActor private final class MotionCleanup {
|
||||
private struct Entry {
|
||||
weak var motion: MetricMotion?
|
||||
let deadline: DispatchTime
|
||||
}
|
||||
private var entries: [ObjectIdentifier: Entry] = [:]
|
||||
private var timer: DispatchSourceTimer?
|
||||
private var scheduled: UInt64?
|
||||
|
||||
func register(_ motion: MetricMotion) {
|
||||
entries[ObjectIdentifier(motion)] = Entry(motion: motion, deadline: .now() + MetricMotion.duration)
|
||||
schedule()
|
||||
}
|
||||
|
||||
func remove(_ motion: MetricMotion) {
|
||||
guard entries.removeValue(forKey: ObjectIdentifier(motion)) != nil else { return }
|
||||
schedule()
|
||||
}
|
||||
|
||||
private func schedule() {
|
||||
guard let first = entries.values.map(\.deadline.uptimeNanoseconds).min() else {
|
||||
timer?.cancel(); timer = nil; scheduled = nil
|
||||
return
|
||||
}
|
||||
// Core Animation ends at 350 ms. Group nearby cleanup deadlines 10 ms later.
|
||||
let deadline = first + 10_000_000
|
||||
guard scheduled != deadline else { return }
|
||||
scheduled = deadline
|
||||
let newTimer = timer == nil
|
||||
if newTimer {
|
||||
let source = DispatchSource.makeTimerSource(queue: .main)
|
||||
source.setEventHandler { [weak self] in MainActor.assumeIsolated { self?.complete() } }
|
||||
timer = source
|
||||
}
|
||||
timer?.schedule(deadline: DispatchTime(uptimeNanoseconds: deadline), leeway: .milliseconds(10))
|
||||
if newTimer { timer?.resume() }
|
||||
}
|
||||
|
||||
private func complete() {
|
||||
let now = DispatchTime.now().uptimeNanoseconds
|
||||
let expired = entries.filter { $0.value.motion == nil || $0.value.deadline.uptimeNanoseconds <= now }
|
||||
for (id, entry) in expired {
|
||||
entries.removeValue(forKey: id)
|
||||
entry.motion?.finish()
|
||||
}
|
||||
scheduled = nil
|
||||
schedule()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
/// Keeps local animation rendering inside a fixed-size child host.
|
||||
struct NativeContentHost<Content: View>: NSViewRepresentable {
|
||||
let content: Content
|
||||
|
||||
func makeNSView(context: Context) -> NSHostingView<AnyView> {
|
||||
let host = NSHostingView(rootView: root(context))
|
||||
// The parent owns the card frame, including its responsive column width.
|
||||
host.sizingOptions = []
|
||||
return host
|
||||
}
|
||||
|
||||
func updateNSView(_ host: NSHostingView<AnyView>, context: Context) {
|
||||
host.rootView = root(context)
|
||||
}
|
||||
|
||||
func sizeThatFits(_ proposal: ProposedViewSize, nsView: NSHostingView<AnyView>, context: Context) -> CGSize? {
|
||||
CGSize(width: proposal.width.flatMap { $0.isFinite ? max(0, $0) : nil } ?? 10,
|
||||
height: proposal.height.flatMap { $0.isFinite ? max(0, $0) : nil } ?? 10)
|
||||
}
|
||||
|
||||
static func dismantleNSView(_ host: NSHostingView<AnyView>, coordinator: ()) {
|
||||
// AppKit may cache a detached view. Release its mounted content immediately.
|
||||
host.rootView = AnyView(EmptyView())
|
||||
}
|
||||
|
||||
private func root(_ context: Context) -> AnyView {
|
||||
AnyView(content.environment(\.self, context.environment))
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,10 @@ struct ResourceCard<Content: View>: View {
|
||||
@ViewBuilder var content: () -> Content
|
||||
|
||||
var body: some View {
|
||||
NativeContentHost(content: cardBody)
|
||||
}
|
||||
|
||||
private var cardBody: some View {
|
||||
GeometryReader { bounds in
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(alignment: .center, spacing: 6) {
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
@main struct NativeContentHostChecks {
|
||||
@MainActor static func main() {
|
||||
_ = NSApplication.shared
|
||||
NSApp.setActivationPolicy(.accessory)
|
||||
Task { @MainActor in
|
||||
let probe = Probe()
|
||||
let window = NSWindow(contentRect: NSRect(x: 50, y: 50, width: 240, height: 80),
|
||||
styleMask: [.borderless], backing: .buffered, defer: false)
|
||||
window.isReleasedWhenClosed = false
|
||||
window.level = .floating
|
||||
let host = NSHostingView(rootView: Example(value: "128", probe: probe))
|
||||
host.sizingOptions = []
|
||||
window.contentView = host
|
||||
window.orderFrontRegardless()
|
||||
try? await Task.sleep(for: .milliseconds(250))
|
||||
let ideal = host.fittingSize
|
||||
precondition(ideal.width.isFinite && ideal.height.isFinite, "Unconstrained fitting must stay finite")
|
||||
let before = bitmap(host)
|
||||
precondition(probe.appearances == 1 && probe.animates && probe.locale == "en_US" && probe.font == .system(size: 22, weight: .medium))
|
||||
precondition(redPixels(before) > 30, "Foreground style must cross the native boundary")
|
||||
let originalLifetime = ObjectIdentifier(probe.lifetime!)
|
||||
host.rootView = Example(value: "345", probe: probe)
|
||||
try? await Task.sleep(for: .milliseconds(140))
|
||||
let middle = bitmap(host)
|
||||
try? await Task.sleep(for: .milliseconds(600))
|
||||
let after = bitmap(host)
|
||||
precondition(before.bitmapData != nil && after.bitmapData != nil)
|
||||
precondition(pixels(before) != pixels(after), "Changed values must reach the retained child host")
|
||||
precondition(pixels(middle) != pixels(before) && pixels(middle) != pixels(after),
|
||||
"The system numeric transition must still have an intermediate frame")
|
||||
precondition(probe.appearances == 1 && probe.lifetime.map(ObjectIdentifier.init) == originalLifetime,
|
||||
"Sampling must update mounted content, not remount it")
|
||||
host.rootView = Example(value: "345", probe: probe, reduced: true, locale: "zh_CN")
|
||||
try? await Task.sleep(for: .milliseconds(100))
|
||||
precondition(!probe.animates && probe.locale == "zh_CN")
|
||||
window.setContentSize(NSSize(width: 360, height: 100))
|
||||
try? await Task.sleep(for: .milliseconds(100))
|
||||
@MainActor func childHost(_ view: NSView) -> NSHostingView<AnyView>? {
|
||||
if let child = view as? NSHostingView<AnyView> { return child }
|
||||
return view.subviews.lazy.compactMap(childHost).first
|
||||
}
|
||||
let child = childHost(host)
|
||||
precondition(child?.bounds.size == host.bounds.size, "The parent must remain the sole frame owner")
|
||||
host.rootView = Example(value: "345", probe: probe, visible: false)
|
||||
try? await Task.sleep(for: .milliseconds(150))
|
||||
precondition(probe.disappearances == 1)
|
||||
let releaseDeadline = ContinuousClock.now.advanced(by: .seconds(1))
|
||||
while probe.lifetime != nil && ContinuousClock.now < releaseDeadline {
|
||||
try? await Task.sleep(for: .milliseconds(20))
|
||||
}
|
||||
precondition(probe.lifetime == nil, "A cached native view must release detached content")
|
||||
window.orderOut(nil)
|
||||
window.contentView = nil
|
||||
window.close()
|
||||
print("PASS: card host preserves system numeric intermediate frames, inherited font/style/locale/motion, child state, resize and unmount")
|
||||
fflush(stdout)
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
NSApp.run()
|
||||
}
|
||||
|
||||
@MainActor private final class Lifetime {}
|
||||
@MainActor private final class Probe {
|
||||
var appearances = 0
|
||||
var disappearances = 0
|
||||
var animates = false
|
||||
var locale = ""
|
||||
var font: Font?
|
||||
weak var lifetime: Lifetime?
|
||||
}
|
||||
private struct Example: View {
|
||||
let value: String
|
||||
let probe: Probe
|
||||
var reduced = false
|
||||
var locale = "en_US"
|
||||
var visible = true
|
||||
var body: some View {
|
||||
Group {
|
||||
if visible { NativeContentHost(content: Content(value: value, probe: probe)) }
|
||||
}
|
||||
.font(.system(size: 22, weight: .medium))
|
||||
.foregroundStyle(.red)
|
||||
.environment(\.locale, Locale(identifier: locale))
|
||||
.environment(\.metricAnimationsEnabled, !reduced)
|
||||
}
|
||||
}
|
||||
private struct Content: View {
|
||||
let value: String
|
||||
let probe: Probe
|
||||
@Environment(\.metricAnimationsEnabled) private var animates
|
||||
@Environment(\.locale) private var locale
|
||||
@Environment(\.font) private var font
|
||||
@State private var lifetime = Lifetime()
|
||||
var body: some View {
|
||||
AnimatedMetricText(value: value)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.onAppear {
|
||||
probe.appearances += 1; probe.lifetime = lifetime
|
||||
recordEnvironment()
|
||||
}
|
||||
.onDisappear { probe.disappearances += 1 }
|
||||
.onChange(of: animates) { recordEnvironment() }
|
||||
.onChange(of: locale) { recordEnvironment() }
|
||||
}
|
||||
private func recordEnvironment() {
|
||||
probe.animates = animates; probe.locale = locale.identifier; probe.font = font
|
||||
}
|
||||
}
|
||||
@MainActor private static func bitmap(_ view: NSView) -> NSBitmapImageRep {
|
||||
view.layoutSubtreeIfNeeded()
|
||||
let bitmap = view.bitmapImageRepForCachingDisplay(in: view.bounds)!
|
||||
view.cacheDisplay(in: view.bounds, to: bitmap)
|
||||
return bitmap
|
||||
}
|
||||
private static func pixels(_ bitmap: NSBitmapImageRep) -> Data {
|
||||
var data = Data()
|
||||
let width = bitmap.pixelsWide * bitmap.bitsPerPixel / 8
|
||||
for row in 0..<bitmap.pixelsHigh {
|
||||
data.append(bitmap.bitmapData!.advanced(by: row * bitmap.bytesPerRow), count: width)
|
||||
}
|
||||
return data
|
||||
}
|
||||
private static func redPixels(_ bitmap: NSBitmapImageRep) -> Int {
|
||||
var count = 0
|
||||
for x in 0..<bitmap.pixelsWide {
|
||||
for y in 0..<bitmap.pixelsHigh {
|
||||
if let color = bitmap.colorAt(x: x, y: y)?.usingColorSpace(.deviceRGB),
|
||||
color.redComponent > color.greenComponent + 0.2 && color.redComponent > color.blueComponent + 0.2 {
|
||||
count += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,30 @@ import QuartzCore
|
||||
precondition(!ring.isAnimating && ring.displayedValue == 0.8)
|
||||
ring.configure(NativeMetricRing.Input(value: 0.2, color: .red, lineWidth: 3, trackOpacity: 0.17, inset: 2, animates: true))
|
||||
ring.removeFromSuperview(); precondition(!ring.isAnimating && ring.displayedValue == 0.2)
|
||||
// Shared cleanup must not stop a different motion or a newer replacement.
|
||||
let firstMotion = MetricMotion(), secondMotion = MetricMotion()
|
||||
let firstLayer = CALayer(), secondLayer = CALayer()
|
||||
root.wantsLayer = true
|
||||
for target in [firstLayer, secondLayer] {
|
||||
target.frame = CGRect(x: 10, y: 10, width: 20, height: 20)
|
||||
target.backgroundColor = NSColor.red.cgColor
|
||||
root.layer?.addSublayer(target)
|
||||
}
|
||||
func makeMovement() -> CABasicAnimation {
|
||||
let animation = CABasicAnimation(keyPath: "position.x")
|
||||
animation.fromValue = 0; animation.toValue = 10
|
||||
return animation
|
||||
}
|
||||
firstMotion.start(on: firstLayer, animation: makeMovement())
|
||||
secondMotion.start(on: secondLayer, animation: makeMovement())
|
||||
try? await Task.sleep(for: .milliseconds(180))
|
||||
firstMotion.stop()
|
||||
secondMotion.start(on: secondLayer, animation: makeMovement())
|
||||
try? await Task.sleep(for: .milliseconds(210))
|
||||
precondition(!firstMotion.isRunning && secondMotion.isRunning,
|
||||
"An old batch deadline must not remove a restarted animation")
|
||||
try? await Task.sleep(for: .milliseconds(250))
|
||||
precondition(!secondMotion.isRunning, "The replacement must also finish and release its animation")
|
||||
window.orderOut(nil); window.close()
|
||||
print("PASS: native curve pixels, real gaps, missing series, hover, appearance, duplicate-input invalidation zero/quarter/full ring pixels and finite transitions/gap/policy/unmount cancellation")
|
||||
fflush(stdout); NSApp.terminate(nil)
|
||||
|
||||
@@ -38,6 +38,15 @@ import Darwin
|
||||
count += 1
|
||||
}
|
||||
precondition(count > 0)
|
||||
var monitor = NetworkMonitor()
|
||||
for _ in 0..<30 {
|
||||
guard let interfaces = monitor.sample() else { preconditionFailure("Live counter read failed") }
|
||||
for item in interfaces {
|
||||
precondition(item.download.map { $0.isFinite && $0 >= 0 } ?? true)
|
||||
precondition(item.upload.map { $0.isFinite && $0 >= 0 } ?? true)
|
||||
precondition(item.addresses == item.addresses.sorted())
|
||||
}
|
||||
}
|
||||
print("PASS: sandbox IPv4/IPv6, known/unknown scopes, mapped addresses, empty buffer and canonical equivalence for", count, "live addresses (values omitted)")
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -31,6 +31,8 @@ CHECKS.update({
|
||||
"PublicIPAddressChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
||||
"NativeMetricDrawingChecks": ["kymo/UI/Charts/NativePanelCurve.swift", "kymo/UI/Charts/PanelCurveFrame.swift",
|
||||
"kymo/UI/Charts/PanelCurveGeometry.swift", "kymo/UI/Components/NativeMetricRing.swift", "kymo/UI/Components/MetricMotion.swift"],
|
||||
"NativeContentHostChecks": ["kymo/UI/Components/NativeContentHost.swift", "kymo/UI/Components/AnimatedMetricText.swift",
|
||||
"kymo/UI/Components/MetricMotion.swift"],
|
||||
"ProcessCPULiveChecks": ["kymo/Core/Models/ProcessMetrics.swift", "kymo/Core/Monitors/ProcessMonitor.swift"],
|
||||
"MotionPreferencesChecks": ["kymo/Core/Services/AppearancePreferences.swift", "kymo/Core/Services/SamplingPreferences.swift"],
|
||||
"NetworkAddressChecks": ["kymo/Core/Monitors/NetworkMonitor.swift"],
|
||||
@@ -58,7 +60,7 @@ CHECKS.update({
|
||||
"kymo/UI/Components/IntervalControl.swift"],
|
||||
"SandboxNetworkChecks": ["kymo/Core/Services/PublicIPAddressService.swift"],
|
||||
})
|
||||
GUI = {"NativeMetricDrawingChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks"}
|
||||
GUI = {"NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "LanguageScopeChecks", "SettingsWindowChecks", "PanelWindowChecks"}
|
||||
NETWORK = {"SandboxNetworkChecks"}
|
||||
SERVICES = {"ReleaseServiceChecks"}
|
||||
|
||||
@@ -92,7 +94,7 @@ def test_bundle(work, name, executable, host_entitlements=None, resources=None,
|
||||
(contents / "Info.plist").write_bytes(plistlib.dumps({
|
||||
"CFBundleIdentifier": "cn.airnan.kymo.checks." + uuid.uuid4().hex,
|
||||
"CFBundleExecutable": name, "CFBundlePackageType": "APPL",
|
||||
"LSUIElement": name in {"PanelWindowChecks", "NativeMetricDrawingChecks", "NativeProcessTableChecks", "NetworkAddressChecks", "SandboxNetworkChecks"},
|
||||
"LSUIElement": name in {"PanelWindowChecks", "NativeMetricDrawingChecks", "NativeContentHostChecks", "NativeProcessTableChecks", "NetworkAddressChecks", "SandboxNetworkChecks"},
|
||||
}))
|
||||
if resources:
|
||||
shutil.copytree(resources, contents / "Resources")
|
||||
|
||||
Reference in New Issue
Block a user