π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile] Validate iOS refresh task capacity before configuring
laurenspriem12b1916eb2fe
diff --git a/mobile/apps/photos/plugins/ente_background_manager/README.md b/mobile/apps/photos/plugins/ente_background_manager/README.mdindex cbd1b71c3c..185338f5e3 100644--- a/mobile/apps/photos/plugins/ente_background_manager/README.md+++ b/mobile/apps/photos/plugins/ente_background_manager/README.md@@ -16,6 +16,8 @@ The package is part of the mobile workspace. Photos does not depend on or initiaTask configuration supports refresh/processing kind, frequency, initial delay, supported native constraints, and two optional durations. `runBudget` requests cooperative stopping from native entry, including engine startup. `foregroundStopTimeout` starts force teardown after the first foreground arrival. Omission disables the corresponding timer; zero acts immediately and negative durations are rejected. Android supports periodic flex and device-idle constraints. iOS supports network/power constraints only for processing tasks; unsupported combinations are rejected.+iOS configurations accept at most one refresh task, including when scheduling is disabled. Configurations exceeding this limit fail before changing stored settings, pending schedules, or active work. [Apple limits each app to one pending refresh request and ten pending processing requests](https://developer.apple.com/documentation/backgroundtasks/bgtaskscheduler/submit(_:)).+Before supplying `foregroundStopTimeout`, validate the lifetime of the consumer's native/FFI operations. Destroying a Flutter engine does not establish that those operations have stopped.## Native lifecyclediff --git a/mobile/apps/photos/plugins/ente_background_manager/ios/Classes/BackgroundRuntime.swift b/mobile/apps/photos/plugins/ente_background_manager/ios/Classes/BackgroundRuntime.swiftindex 759e24dd47..aa5a11f3a0 100644--- a/mobile/apps/photos/plugins/ente_background_manager/ios/Classes/BackgroundRuntime.swift+++ b/mobile/apps/photos/plugins/ente_background_manager/ios/Classes/BackgroundRuntime.swift@@ -127,10 +127,18 @@ final class BackgroundRuntime: NSObject {guard registrations[task.identifier] == (task.kind == "processing") else {throw TaskConfiguration.ConfigurationError.unregisteredIdentifier}- if !configuration.tasks.contains(task) { changedTasks.insert(task.identifier) }+ }+ guard parsed.filter({ $0.kind == "refresh" }).count <= 1 else {+ result(+ FlutterError(+ code: "configuration", message: "iOS supports at most one refresh task", details: nil))+ return}let next = StoredConfiguration(enabled: enabled, tasks: parsed)try next.save()+ for task in parsed where !configuration.tasks.contains(task) {+ changedTasks.insert(task.identifier)+ }configuration = nextif !enabled { requestStop() }configurationResults.append(result)