AirStats 1.7 started with GitHub issue #39, a screenshot of a blurry globe icon in the menu bar's Icon & Text style, which draws an SF Symbol beside the number.
MenuBarContentView rasterises SF Symbols into an NSBitmapImageRep and caches bitmaps by scale. It read context.ctm.a, which I expected to be 2 on a 2x Retina screen.
Twelve draws at 1x, seven at 2x
A probe status item on a Retina screen logged 12 draws at CTM scale 1 and 7 at scale 2. One pass draws into a recording context with an identity CTM, a == 1, while userSpaceToDeviceSpaceTransform.a is 2. Keying the cache by context.ctm.a saved that 1x bitmap and drew SF Symbols at half resolution.
window?.backingScaleFactor returns nil during offscreen screenshot renders, and hardcoding 2 blurs hairlines on a 1x display. Reading the device transform fixed all 15 Icon & Text readouts in live menu bar screenshots comparing 1.6 and the fixed build:
let scale = max(abs(context.userSpaceToDeviceSpaceTransform.a), 1)Adding Intel and making the app smaller anyway
PR #38 added an Intel slice for a universal binary. Five changes brought 1.7 below the arm64-only 1.6 release:
- Stripping the symbol table. Symbols took 6.4 MB per slice versus 2.8 MB stripped. Release builds run
dsymutilthenstrip -x, shipping a 6.7 MB zipped dSYM beside each DMG. - Compiling with
-Osizeinstead of-O. Machine code shrank 18%. The heaviest Swift on the sampling path takes a few microseconds; collectors spend their time waiting on the kernel and the SMC. - Pruning
Sparkle.framework. Release builds removeHeaders,PrivateHeaders, andModulesfrom the bundled framework. - Shrinking the logo asset. Shipping the logo at 256 px in gray plus alpha cut it from 158 KB to 9 KB.
- Compressing the DMG with LZMA. Switching
dmgbuildtoULMOcut the DMG from 3.7 MB to 2.4 MB. macOS supportsULMOsince 10.15, and AirStats requires macOS 14.
App bundleon disk
Disk imagedownload
Switching dmgbuild to LZMA format ULMO cut the final DMG from 3.7 MB to 2.4 MB.
CPU after closing the panel
AirStats keeps its panel window alive for two minutes after close so reopening is instant. While hidden, its SwiftUI tree kept observing the sampling engine and re-rendering every module and chart each tick. An isPresented flag now swaps the root view for a 1 pt tall Color.clear after fade-out, cutting two-minute post-close CPU across two runs from 1.12% and 1.23% to 0.58% and 0.43%.
Idle CPU did not move, and why
Closed-panel idle CPU stayed at 0.47% and 0.53% before versus 0.47% and 0.52% after across two runs, because two thirds of that cost is AppKit redrawing the menu bar item whenever its readout changes. To skip redraws when nothing visible changed, graph series now build only for graph styles, and the bar style rounds fill levels to a whole percent so minor sensor drift does not redraw every sample.
Reading only what is on screen
Collectors now read only visible fields, and thread count refreshes only while the panel shows it.
| Collector | State | Before | After | Change |
|---|---|---|---|---|
| Temperature | Menu bar only | 4.4 ms | 2.6 ms | Reads CPU sensors only and skips the power adapter lookup |
| Power | Panel closed | 1.9 ms | 1.2 ms | Reads battery health only while the panel shows it |
| Wi-Fi | Panel open | 7.4 ms | 3.8 ms | Queries only the Wi-Fi fields shown on screen |
Auditing closed-panel behaviour also fixed a history bug where suspended sources repeated their last reading every tick, drawing flat lines across the 24-hour network, disk, and memory charts while the panel was shut.
Per-process watts and narrower menu bar pairs
Top Processes now sorts by CPU, disk, or energy, one of several features drawing on two forks of the MIT-licensed project. Watts come from ri_energy_nj nanojoule deltas in proc_pid_rusage with RUSAGE_INFO_V6. In a yes load test, AirStats reported 3.1 W for yes versus 2.9 W from an independent tool summing the same kernel counter, and a new summary line at the top of the panel read CPU 97%, yes 90%.
In the menu bar, a stacked pair style fits upload and download, or disk read and write, in one slot, cutting those four readouts from 312 pt to 152 pt. Disk Usage can also draw as a bar.
Testing an app that never quits
Build 1.7 passed 320 unit tests plus Thread Sanitizer and Address Sanitizer runs. Under combined CPU, disk, and network load, the stacked menu bar item held a constant width across 30 captures, and memory stayed at 34 MB across 60 rapid panel open and close cycles.
Tested against the live appcast, the 1.6 GitHub release found 1.7, verified its EdDSA signature, and staged and installed the update on quit. Because a menu bar app started at login rarely quits, 1.7 also installs staged updates when the screen locks or the display sleeps.
AirStats 1.7 is available at airstats.app, and the source is on GitHub.