ipswnotes
← Blog

iOS 27.3 learns to predict heat from charging and schedule around user habits

The background task scheduler in iOS, dasd, has always decided when deferred work runs from the state of the device right now: is it plugged in, is it idle, is it hot, is the battery low. In iOS 27.3 it starts acting on two forecasts instead.

The first is a forecast of heat. When a device is plugged in, the system predicts whether charging will push the battery to a thermal limit, and if so it throttles background work before that happens, not after. The second is a forecast of use. An on-device model predicts which apps the user will open over the next day and week, and the scheduler puts their background work ahead of everything else.

Neither arrived in one piece. Each is spread over several daemons and two betas, and the interesting part is how the pieces connect. This post follows both, then covers two smaller threads found along the way.

Scope of investigation

Everything here comes from the ipswnotes diffs of four builds: iOS 27.3 beta 1 (24C5037i, compared with 27.2.1) and beta 2 (24C5049d), and macOS 27.3 beta 1 (26C5035r) and beta 2 (26C5047e). A re-released iOS beta 2 build, 24C5049f (beta 2 v2), changes nothing under /usr/libexec and can be ignored for this topic.

Three kinds of evidence carry the argument, and they answer different questions:

  • Strings and selectors in a Mach-O diff say what a binary does. os_log format strings are the richest source, because they name the variables a decision depends on.
  • Entitlement diffs say who talks to whom. A daemon can't connect to another daemon's private service without being granted the right to, so a new entitlement is direct evidence of a new connection.
  • Full-text search across all releases says when and where. It turns one string into the list of every binary that carries it, and shows which build introduced each piece.

A forecast of heat

An unexplained name in dasd

The starting point is a pair of log strings in the beta 2 diff of dasd:

TLC prediction: willHitTLC=%{BOOL}u confidence=%.3f
TLC mitigation %{public}@ -> %{public}@ (predicted=%{BOOL}u SOC=%ld limit=%ld temp=%ld hit=%{BOOL}u)

They show that the scheduler receives a yes-or-no prediction with a confidence, and that it changes "mitigation" based on that prediction together with state of charge, a limit, and a temperature. They don't say what TLC is or where the prediction comes from.

Searching every release for TLC answers the second question. Most hits are unrelated: TLContentProtectionStateObserver in ToneLibrary, TLCompositeTransliterator, fcTLCount in ImageIO, and "TLC mode" NAND counters in the storage controller firmware. With those set aside, four components remain, and they split cleanly by build: batteryintelligenced and Powerlog in beta 1, dasd and powerexperienced in beta 2. The source of the prediction shipped one beta before anything used it.

Beta 1

batteryintelligenced is the daemon behind the BatteryIntelligence framework. It could already answer "will this device hit TLC" in 27.2.1, but only through a Core ML model or a crude fallback (Using fallback prediction: willHitTLC=%d, confidence=%.2f, method=Fallback). The beta 1 diff deletes the fallback and puts a proper second method in its place:

Plugged in at SOC %u, caching a prediction
Lookup table prediction: SOC=%.2f in bucket [%@-%@] threshold=%.2f°C, temp=%.2f°C, willHitTLC=%d, confidence=%.2f
Lookup table prediction: SOC=%.2f is not covered by any bucket, willHitTLC=0, confidence=%.2f
Notifying %lu registered clients of prediction update

These four lines describe the whole mechanism. The prediction is made at the moment of plug-in. The daemon takes the current state of charge, finds the bucket it falls into, and compares the battery temperature (rawBatteryVirtualTemperatureCentiC, read through libSMC) with that bucket's threshold. If the battery is already warmer than the threshold for its charge level, the answer is yes.

The bucket names give the shape of the table: TLCLookupTableThreshold60To64, 65To69, 70To74, 75To79 and 80To99. There is no bucket below 60%, and the third log line confirms what happens there: the answer is always no. That makes physical sense. A battery at low charge takes current easily and has a long way to go; it is the last stretch of charging, on an already warm cell, where heat becomes a problem.

The thresholds themselves are not in the binary. They are delivered through Trial, Apple's system for remotely configured parameters, and the daemon clamps what it receives (Trial %@ of %.2f°C is outside [%.1f, %.1f]°C, using default). Trial also chooses between the ML model and the table (predictionMethod). So Apple can retune the heat forecast, or switch its method, without shipping an update.

The fourth line matters most for what follows. Until beta 1 the daemon answered questions; now it keeps a list of registered clients and pushes updates to them. In beta 1 that list had no members.

One more detail from the same build: Powerlog gains +[PLBatteryAgent meetsTLCNotificationConditionsWithChargingState:uisoc:] on both iOS and macOS. The name points to a user notification for this condition, though no matching UI string exists yet.

Beta 2

In beta 2 two daemons register as clients, and the entitlement diffs show it directly. Both dasd and powerexperienced gain com.apple.batteryintelligenced.thermalprediction-read, along with the right to look up the Mach service com.apple.batteryintelligenced.thermalprediction.

The class names on the client side finally say what kind of thing TLC is. The client object is a BIThermalPredictionClient, its callback is didUpdateTLCPrediction:error:, and the payload is a BIThermalPredictionOutput. TLC is a thermal condition. Since it is predicted at plug-in and tied to charge level, it is a thermal condition of charging. The binaries never expand the acronym; "thermal limit while charging" fits every use.

Both daemons also soft-link PowerUI.framework and create a PowerUISmartChargeClient. PowerUI is the home of Optimized Battery Charging and the user-set charge limit. The reason they need it becomes clear below: if charging has been paused or capped on purpose, there is no charging heat to mitigate.

dasd

In dasd, everything funnels into one decision method:

mitigationForPrediction:isPluggedIn:chargeIntentionallyStopped:batteryLevel:temperature:hitTLC:

The argument list is the policy's input. It combines the forecast (prediction) with the present (hitTLC, temperature), and it asks PowerUI whether charging is deliberately on hold (chargeIntentionallyStopped). The result is one of four named mitigations, in rising order of severity:

  • lower QoS for intensive: intensive activities keep running, at a lower quality of service
  • stop intensive: they are stopped
  • stop pluggedIn-required: work that waits for external power is stopped too
  • stop pluggedIn-required until 35C: the same, held until the battery cools to 35°C

Which one applies depends on battery level, through four thresholds (TLCMitigationSOCFloor1 to 4). Each mitigation also has its own Trial switch (TLCMitigationLowerQoSEnabled, TLCMitigationStopIntensiveTasksEnabled, TLCMitigationStopPluggedInTasksEnabled, TLCMitigationStopPluggedInTasksUntil35CEnabled) under a master TLCMitigationsEnabled. Apple can therefore roll the mild response out widely and keep the harsh ones for an experiment group.

The targets are well chosen. "Intensive" and "requires plugged in" describe exactly the work iOS saves for overnight charging: photo analysis, Spotlight indexing, backups. That is CPU and GPU load added to a battery that is already heating from charge current.

The removed strings show what this replaces. Beta 1's dasd had one boolean, prohibitTasksOnTLC. It also kept a list of tasks it had suspended for heat (Remembering %{public}@ (task ID %lu) for thermal pressure, resetThermalMemoryWithReason:). In other words, the old design reacted: wait for the limit, block everything, remember what was blocked, resume later. The new one acts on the forecast and has steps between "run" and "stop".

How powerexperienced uses this

dasd controls whether a task runs. powerexperienced controls how much power running tasks may draw, by setting targets for the SoC. Its beta 2 diff adds a second layer of mitigation there, and its log strings state the conditions outright:

Charging, not in use and TLC predicted
Charging, not in use and TLC engaged
Battery %d reached charge limit %d, TLC mitigation is ignored

"Not in use" is the important qualifier. The power caps apply only to an idle device, so they never slow down someone actively using a phone on the charger. When the conditions hold, the daemon lowers the power budgets for the background and utility QoS classes (tlcBgPowerTarget, tlcUtilityPowerTarget) and selects a package power target. That target depends on battery level, with one option above TLCMitigationSOCThreshold and another below (tlcHighSOCPowerOption, tlcLowSOCPowerOption).

The third line closes the loop with PowerUI. The daemon reads the charge limit (getMCLLimitWithHandler:, MCL limit changed to %d). Once the battery reaches it, charging stops, the heat source is gone, and the caps are lifted.

The net effect

A device plugged in above 60% with a warm battery, left idle, will now do its overnight work more slowly, later, or after it has cooled. Work that would have run flat out while the battery was charging gets spread out. Heat during charging is one of the main drivers of battery ageing, so the benefit is battery lifespan; nothing about daytime performance changes.

macOS has the same settings but not the feature itself

The macOS beta 2 powerexperienced picks up the same TLC properties and Trial keys as iOS. What it lacks is everything that would feed them: there is no BIThermalPredictionClient, no PowerUI client, and none of the "Charging, not in use" logic. macOS dasd gains the single string predicted TLC and no mitigation code. The source is shared, with the parts that depend on batteryintelligenced compiled only for iOS. On a Mac, nothing can currently switch these settings on.

A forecast of use

Core ML model

The second thread starts with two Core ML models added to ospredictiond in beta 2: ps_open_24h.mlmodelc and ps_open_7d.mlmodelc. ospredictiond is the daemon for OS-level predictions, and the names say these models predict an "open" over 24 hours and over 7 days. The ps prefix is explained by a log line in the same diff, personalized_scheduling is on: scheduling %{public}@, and by a new feature flag, personalized_scheduling, in OSIntelligence.plist.

Searching for that name shows the same strings in dasd in the same build, on both iOS and macOS. So this feature has the same producer-and-consumer shape as TLC, but both halves landed together.

How the prediction is made

The new classes in ospredictiond all share the prefix _OSPS, and their names read as a pipeline in order: _OSPSAppFocusReader, _OSPSUsageAggregator, _OSPSPredictor, _OSPSUtilityLabeler, _OSPSUtilityTable, _OSPSDASUtilityPublisher. The log strings fill in each stage.

The raw input is the system's record of which app was in the foreground and for how long (Read %lu App.InFocus event(s)). That history is protected data: Cycle skipped: no unlock since boot, so App.InFocus and the stored table are not readable. The pipeline simply cannot run on a device that has rebooted and not yet been unlocked.

The aggregator turns events into per-app usage by hour and by day (_OSPSHourlyUsage, _OSPSDailyUsage). The feature names show what the models look at: how active the device has been over one and seven days (d_dev_log_s_1d, d_dev_active_frac_7d) and usage rates per day of the week (d_dow_rate_k1 to k7). The weekday features are the telling ones. They let the model learn that an app is used on weekdays but not weekends, or only on Sundays.

Each app then gets one of three labels: NEXT_DAY, NEXT_7_DAYS or NONE. The error paths are designed with care. If the 7-day model fails, the 24-hour model is used alone (The 7 day model failed; those apps used the 24 hour model only). A new device has no history, so it falls back to fixed rules (User has neither enough history nor a usable backup; using the rule-based model). Usage intervals from before a time-zone change are dropped, so a trip doesn't shift the learned daily pattern by several hours.

The labelled list is called a utility table. It is published to dasd at most once an hour (Cycle skipped: already published for this hour).

How dasd uses it

dasd receives the table as "app usage priorities" through updateAppUsagePriorities:version:timestamp:withHandler:, and treats it as untrusted input. It checks the version and age and can reject a table outright (App usage priorities v%lu rejected (%{public}@ v%lu, age %.0fs)). Only holders of the new entitlement com.apple.das.private.usagepriorities may send one, and reading needs com.apple.das.private.usagepriorities.read.

The accepted table is saved as appUsagePriorities.plist. The diff shows dasd importing NSURLIsExcludedFromBackupKey for it, with a matching error string (Failed to exclude app usage priorities from backup). A ranked list of the apps someone uses is sensitive, and this keeps it out of iCloud and local backups.

There is a practical gap between the table and the scheduler. The table is keyed by app, but dasd schedules activities, and a system activity is named after the service that submitted it, not the app it serves. A new file bridges the two: /System/Library/DuetActivityScheduler/Scheduler/Resources/com.apple.dasd.taskAppMap.plist. The load message shows what it holds: Loaded task app map: %lu prefixes, medium: %lu services, %lu feature codes, %lu prefixes, %lu name substrings. It maps activity name prefixes to apps, and separately lists services and feature codes that are always treated as medium priority, whatever the model says.

With that in place, the comparison between two pending activities (compareActivity:withActivity:usagePriorities:) can take app priority into account. How much it counts is again set remotely: Trial supplies three weights (PersonalizedSchedulingWeightHigh, Medium, Low), a master switch (PersonalizedSchedulingEnabled), and a separate switch for whether Spotlight indexing follows the same order (PersonalizedSchedulingSpotlightUsesAppPriority).

Finally, dasd counts how many activities finished at each level and reports it (Reported personalized scheduling metrics: completed %lu/%lu/%lu (low/medium/high)). That is the measurement of an A/B test: if the feature works, high-priority completions go up without low-priority ones collapsing.

The net effect

Background time is limited by battery, by heat, and from this release by TLC as well. When there isn't enough to go round, the work that gets done is now the work for apps the user is about to open. For third-party developers the consequence is straightforward: once this is enabled, BGTaskScheduler requests from an app that is rarely opened will be deferred more often than the same requests from an app opened daily.

The two features complement each other. TLC reduces how much background work can run on a warm, charging device; personalized scheduling decides which work still runs.

Unlike TLC, this one is complete on macOS: both ospredictiond and dasd carry the full set of changes there.

CSPN: push delivery in deep standby

One of the new feature flags in beta 2, APS/EmbeddedCSPNNonWaking, has a name that explains little by itself. APS is the push notification service; CSPN isn't expanded anywhere. Searching for CSPN across releases shows it is the third appearance of a state that three daemons have been taught about in turn.

In beta 1, dasd on iOS and macOS begins tracking it: CSPN entered, CSPN exited. It also opens a "post-CSPN window" afterwards, which stays open until the user unlocks the device or a timeout passes (Post-CSPN window closed without an unlock after %.0f hours, locked since CSPN). So CSPN is a state a locked device enters and leaves by itself, and the scheduler cares about the period between leaving it and the user's return.

In beta 2, powerd starts reporting the state to apsd, the push daemon (isAPSDClientIdentifier:, resetAPSDClientsToOff). This is guarded by a Trial switch: CSPN: Skipping update state for client %@ (Trial sendCSPNStatusUpdateToAPSD is off). In the same build dasd gains a policy condition for the window, QoSPolicyPostCSPNEnabled, and the APS flag arrives.

Put together: the power daemon owns a deep idle state, it now tells the push daemon when the device is in it, and the push daemon has a new "non-waking" mode. Pushes arriving during this state can be handled without bringing the whole system out of sleep, while the scheduler holds back its own work until the user is back. The result is less overnight standby drain.

Signs of new hardware

Two changes in these builds only make sense for devices that don't exist yet.

thermalmonitord talks to the SoC's power-management processor through a kernel service, ApplePMPv2. Until now it expected one. The beta 2 diff replaces that assumption throughout:

LTS: no usable ApplePMPv2 instances found
LTS invariant: multi-PMP instance %u reports die-count %u (expected 1)
%@: dieCount*loopCount %u exceeds the %d-bit TDDB cluster mask capacity

The daemon now discovers several PMP instances, expects each to manage exactly one die, and addresses reads and writes to a specific die (copyKeyFromPMP:is_64:forDie:, sendDataToPMP:forKey:forDie:, replacing the versions without forDie:). This is preparation for a chip built from several dies, each with its own power controller.

The third string adds something. TDDB is time-dependent dielectric breakdown, the gradual wear of a transistor's gate insulation under voltage and heat. A thermal daemon that keeps a per-cluster TDDB mask, with controls named lts-ctrl-%u-0-cores, is managing chip lifetime as well as temperature: it accounts for how much stress each core cluster has accumulated. "LTS" is not expanded.

The other change is in battery logging. In beta 1, SpringBoard's _SBBatteryLogContext gains hingeStateDescription. In beta 2, Powerlog gains a HingeState field and listens for CoreMotion::HingeUsage events (handleHingeUsageNotificationWithPayload:, logHingeUsageToCA:). The same builds carry "iPhone Duo" strings in Setup, Touch ID settings and SF Symbols (iphone.duo.*). Apple's battery telemetry is being extended to record whether a folding phone was open or closed, which is what is needed to attribute battery drain to one display or the other.

Smaller changes

Sysdiagnose. Previously dasd reacted to the start of a sysdiagnose by suspending running tasks (Sysdiagnose started, suspending running tasks if any). That string is gone, replaced by a full policy, _DASSysdiagnosePolicy, described in the binary as "Holds discretionary and intensive tasks while a sysdiagnose is captured." It releases them when com.apple.sysdiagnose.sysdiagnoseStopped arrives. It also has a timeout (No sysdiagnose stopped notification after %.0fs, releasing held tasks), so a crashed capture can't block background work indefinitely.

Freezer model for iPad. The freezer decides which suspended apps have their memory compressed and frozen. dasd loads an ML model for that decision from Trial, and the loader now takes the device class into account (FreezerModeliPad, Loaded freezer ML model from Trial (isiPad: %d)). iPads keep more apps alive with more memory, so a model trained on iPhone behaviour is a poor fit.

Two more flags. SiriTTSService/lowInactiveMemory and PrivateCloudCompute/scheduledTokensPrefetch arrive with no related code changes found in this build. Going by the names, the first reduces the memory the text-to-speech engine holds while idle, and the second fetches Private Cloud Compute access tokens on a schedule so a request doesn't have to wait for them.