My new M5 MacBook Air was losing a percent of battery every three minutes. 68% at 10:42, 56% at 11:18. A laptop sold on all-day battery life was on course to be flat by two in the afternoon.
The battery itself was fine: 26 cycles, 100% maximum capacity. Something was keeping the machine busy.
It turned out to be three somethings. Two were my own doing. The third was appstoreagent, the App Store's background service, asking for the Touch ID daemon several thousand times a second and being told no every time.
Measuring the drain in watts
"It feels like it drains fast" isn't something you can compare before and after a fix. The battery reports its own current and voltage, no sudo needed:
$ ioreg -rn AppleSmartBattery | grep -E '"(Amperage|Voltage)" ='
"Voltage" = 11652
"Amperage" = 18446744073709550821 That amperage isn't a typo and the battery isn't delivering eighteen quintillion milliamps. It's a negative number printed as an unsigned 64-bit one. Subtract 2^64 and you get -795 mA, negative because the battery is discharging.
795 mA at 11.65 V is 9.3 W. On a 4,540 mAh battery that's about 17% an hour, close enough to the 20% I'd been watching. As I found out later, this one sits at 3 to 5 W when it's doing light work.
One more trap while you're measuring: the menu bar can flatter you. After a full charge mine said 98% while the gauge's own RemainingCapacity and FullChargeCapacity put it at 93%.
The two that were my fault
top -o power pointed at the first two straight away.
Docker Desktop had been up for three days with a LocalStack container that burns 15% of a core while doing nothing at all. I stopped the containers.
Chrome had a tab that kept the GPU busy. When I caught it in Chrome's Task Manager it was Instagram, at 18% CPU, with Chrome's GPU process and WindowServer working just as hard to put it on screen. That one gets closed when I'm not looking at it.
With Docker stopped and a reboot behind me, the same measurement over 35 minutes came out at 4.2 W. About 7% an hour. Case closed, I thought.
Then it climbed back
Fifteen minutes later the gauge had dropped another 142 mAh, which works out to 7.4 W. This time the top of the list looked different:
PID COMMAND %CPU POWER TIME
1136 appstoreagent 101.7 101.7 28:01.05 I'd seen that name already. A minute after the reboot it was at 91% CPU and I'd waved it away as post-boot housekeeping, in the same breath as Spotlight reindexing. Two hours later I caught it at 94%, opened the App Store, found a pile of pending updates, let them install, and waved it away a second time.
It hadn't finished anything. Between two checks 15 minutes apart, its CPU time went from 12:35 to 28:01. That's a full core for fifteen minutes straight, and it was still at 101% after the updates had installed.
What it was doing
sample takes stack snapshots of a running process and works on your own processes without sudo:
sample 1136 3 -file appstoreagent.txt The main thread was parked in its run loop, waiting for messages like a well-behaved daemon. The worker threads were not. These frames kept turning up, with their sample counts:
502 __48-[BiometricKitXPCClientConnection xpcConnection]_block_invoke.228 (in BiometricKit)
383 -[BiometricKitXPCClient initializeConnection] (in BiometricKit)
265 -[BiometricKitXPCClient connect] (in BiometricKit)
130 -[BiometricKitXPCClientConnection xpcConnection] (in BiometricKit) connect, initializeConnection, and a block that runs when the connection dies. BiometricKit is the Touch ID framework. The App Store agent was trying to open a connection to the Touch ID daemon, failing, and trying again.
7,000 times a second
The unified log had the other half of the conversation. (I spell out /usr/bin/log because zsh has a log builtin of its own. Apple's /etc/zshrc disables it in interactive shells, but a script or zsh -c still gets the builtin, and it has no idea what show means.)
/usr/bin/log show --last 20s --style compact \
--predicate 'process == "appstoreagent"' One lap of the loop, from just after boot, looks like this:
17:10:41.576 appstoreagent [com.apple.xpc:connection] activating connection: mach=true listener=false peer=false name=com.apple.biometrickitd
17:10:41.576 appstoreagent [com.apple.xpc:connection] failed to do a bootstrap look-up: xpc_error=[159: Unknown error: 159]
17:10:41.576 appstoreagent [com.apple.xpc:connection] invalidated after a failed init
17:10:41.576 appstoreagent (BiometricKit) BiometricKitXPCClient::xpcConnection invalidated
17:10:41.576 appstoreagent (BiometricKit) BiometricKitXPCClient::interruptConnection (_cid:1427112563)
17:10:41.577 appstoreagent [com.apple.xpc:connection] activating connection: mach=true listener=false peer=false name=com.apple.biometrickitd Ask for com.apple.biometrickitd, get refused, tear the connection down, get told the connection was interrupted, ask again. All five lines share a millisecond.
The log held on to about 15 seconds of this from just after boot. In those 15 seconds it recorded 110,915 failed lookups, peaking at 7,831 in a single second. Nothing in those 15 seconds looks like backoff. It just asks again.
Error 159 has a name
The log calls it Unknown error: 159, which is a little unfair, because another part of the same OS knows exactly what it is:
$ launchctl error 159
159: Sandbox restriction So the lookup isn't failing because the Touch ID daemon is down. It was running the whole time, with 0.15 seconds of CPU to its name after two hours. Touch ID was set up and enabled. The App Store agent was being refused at the door, and its response to "no" was to knock again immediately.
The fix
killall appstoreagent It's a launch agent, so launchd starts a new one whenever the App Store next needs it. Check nothing is mid-install in the App Store first.
A minute later there was no appstoreagent process and no new lookups in the log. WindowServer was at 9%, the power reading was down to 4.3 W, and the busiest thing left in top -o power after it was Terminal, which was me. Chrome had been busy during the 7.4 W stretch too, so I won't pin the whole drop on one process.
What I don't know
I don't know what starts it. It was running a minute after boot, it was quiet for a stretch in the middle, and it was pinned again while I was installing updates. Signing in to the App Store and confirming purchases are the obvious places Touch ID gets involved, but I haven't caught the first lap of the loop, only the middle.
I also don't know if it comes back by itself. This is macOS 27.0.1 (26A434) on a Mac17,3. The next day, three and a half hours after a boot, appstoreagent had used three seconds of CPU and the log had no failed lookups in it. If the loop returns, I'll update this post with what brought it back.
There's a different appstoreagent loop being reported on macOS 27, where it and dasd keep each other busy from midnight until morning. This doesn't look like that one. dasd was nowhere near the top of my list.
Takeaway
A process that's busy right after boot gets a free pass, and it shouldn't get an unlimited one. "It's probably indexing" is a fine first guess and a bad second one. The number that settles it is accumulated CPU time, checked twice: appstoreagent's grew by 15 minutes in 15 minutes.
And when macOS tells you an error is unknown, ask launchctl. It might know.
