Comment by marcan_42
4 years ago
Bad batteries generally allow for last-gasp handling, and I've definitely seen the SMC throw a fit on some properties a few seconds before shutdown due to the battery being really dead. Not sure if macOS handles this properly, but I'd hope it does, and if it doesn't they could certainly add the feature. It would be quite an extreme case to have a battery failure be so sudden the voltage doesn't drop slowly enough to invoke this.
A fair fraction of the bad batteries I have seen have not behaved like this. Things like immediate power failure on disconnecting AC power, or claiming to be at 30% and then dying, or denying the existence of the battery altogether (two of these have happened to me personally—one at the ripe age of four months rather than due to age—and three or four to other family members). It’s certainly more common for them to just fade fairly rapidly to zero and die there, but it’s by no means rare for them to spontaneously fall over.
We're talking different timescales here. All you need is one second or so to command the NVMe controller to flush, and killing other power consumers in the mean time would buy you more time by reducing load, possibly even giving you several minutes the way batteries work (they tend to fall over under load when defective/dead). What may visually appear as power suddenly failing isn't necessarily so at the scale of voltage threshold interrupts and PMICs.
What usually happens is battery internal resistance is too high to sustain a given power load, so once load crosses a threshold the system goes into a spiral of doom increasing current as battery voltage decreases and you end up in a shutdown. That's the "30% and suddenly 0% or a shutdown" scenario. But if you catch it before it's too late, you can just stop consuming power and let the NVMe controller flush.
The case I have in mind where it would suddenly die around 30% would happen around that point regardless of load, even asleep, after following a sufficiently typically linear discharge curve up to that point. Maybe the power management system gets a fraction of a second’s notice, I don’t know; but it wasn’t a 30% plummeting to zero over the course of ten or thirty seconds, or even a “30%; no—0%; no—dead” case, which seem to be the much more common failure modes. As for the “pull the AC power and it instantly dies” cases, I’m a layman in battery matters, with no more than high school electronics, but I’d be surprised if there’s enough in there for it to do anything—those are cases where either it literally has no battery to draw on (because it’s electronically dead), or thinks it has a battery but discovers as soon as it tries to draw on it that it effectively doesn’t actually.
2 replies →
iOS doesn’t. A bad battery makes it think it has more time than it does, and cleanup tasks can get killed just as they start.