Handle Low Power Mode Without Breaking An In Progress Task

A user starts exporting a document, then enables Low Power Mode. Cancelling the export, deleting its scratch files, and asking them to start again may save some immediate work while wasting everything already completed.

A better policy distinguishes optional work waiting to start from work the user explicitly requested. Low Power Mode is an input to that policy, not a universal cancellation command.

Make admission a small decision

Apple exposes isLowPowerModeEnabled on ProcessInfo. This example uses it to defer speculative preview prefetching while continuing to admit an explicit export:

import Foundation

enum WorkKind { case userExport, previewPrefetch }
enum Admission: Equatable { case start, deferUntilAllowed }
struct PowerPolicy {
    var isLowPowerModeEnabled: Bool
    func admission(for kind: WorkKind) -> Admission {
        switch kind {
        case .userExport: return .start
        case .previewPrefetch: return isLowPowerModeEnabled ? .deferUntilAllowed : .start
        }
    }
    static func current() -> Self {
        Self(isLowPowerModeEnabled: ProcessInfo.processInfo.isLowPowerModeEnabled)
    }
}

The policy returns a decision; it does not start a task, delete a file, or mutate a queue. That makes the product rule easy to test without needing to change the device’s battery settings.

“User export starts” is the rule for this example, not a system guarantee of execution time. Background execution limits, resource availability, user cancellation, and thermal conditions still apply.

Read state before starting work

Take an initial snapshot when the coordinator starts, then observe power-state changes. Apple’s documentation identifies the power-state notification and says to query the current property after receiving it.

Do not infer that a notification means the Boolean flipped exactly once, or keep toggling a local flag. Read the authoritative state. On returning to the foreground, refresh that state again before admitting a new batch.

Have one coordinator own the observation and distribute the current policy where needed. Installing a separate observer in every thumbnail row makes lifetime management harder and repeats a decision that belongs to the queue.

A policy change does not have to restart everything

When Low Power Mode turns on, stop admitting new speculative prefetch jobs. Let a small bounded amount of useful in-flight work finish, or cancel it at a safe boundary if the result is no longer needed.

For an explicit export, preserve completed chunks and the user’s selected output quality. You may lower concurrency or pause between resumable units if the workflow supports it. Do not silently switch a requested full-resolution export to a low-resolution preview.

Treat “paused to conserve energy” as a state with a resume path. The UI should not claim the operation failed if its inputs and progress are intact.

If the user cancels, that is a separate event with a separate cleanup policy. Keeping power policy and cancellation distinct makes those states much easier to explain.

Resume gradually

When normal power mode returns, reevaluate what is still useful. A screen the user left ten minutes ago does not need its old prefetch backlog completed.

Discard obsolete queue entries, coalesce repeated requests for the same resource, and refill only up to the normal concurrency limit. Resuming every deferred task simultaneously can cause the very burst of CPU, network, and memory activity the queue was meant to control.

A power change should not trigger redundant database reads or reload every visible model. Reuse the data and queued work the client already owns.

Test transitions as well as states

The fixture covers normal-mode prefetch, deferred low-power prefetch, and explicit export admission in both states. In the actual coordinator, add a transition test: begin an export, change the policy, and confirm its progress and output contract survive.

Then test the reverse transition with an obsolete queued request and repeated notifications. The desired result is one current policy and a bounded set of useful jobs, not one new task for every notification.

September 2026 review: the pure admission checks passed and the ProcessInfo adapter type-checked for iOS 17. The article does not claim device battery savings or automatic completion of background exports; measure the actual workflow on hardware.