π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile] Remove fixed native iOS processing deadlines
laurenspriem81ba1e29e08a
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dartindex 56899ecca8..4e801aad08 100644--- a/mobile/apps/photos/lib/main.dart+++ b/mobile/apps/photos/lib/main.dart@@ -248,7 +248,7 @@ Future<void> runBackgroundTask(String taskId,TimeLogger tlog, {String mode = 'normal',- Duration? mlSelfStop,+ required Duration? mlSelfStop,Duration? mlLockWait,MlRunControl? control,bool Function()? shouldStop,@@ -256,15 +256,12 @@ Future<void> runBackgroundTask(// Created at task start so a stop that fires before ML begins stays// latched for the whole task.final mlRunControl = control ?? MlRunControl();- final mlBudget =- mlSelfStop ??- (Platform.isIOS ? kBGTaskMLSelfStopIOS : kBGTaskMLSelfStopAndroid);- if (mlBudget <= Duration.zero) {+ if (mlSelfStop != null && mlSelfStop <= Duration.zero) {mlRunControl.requestStop(MlStopReason.backgroundDeadline);}- final mlSelfStopTimer = mlBudget > Duration.zero+ final mlSelfStopTimer = mlSelfStop != null && mlSelfStop > Duration.zero? Timer(- mlBudget,+ mlSelfStop,() => mlRunControl.requestStop(MlStopReason.backgroundDeadline),): null;diff --git a/mobile/apps/photos/lib/utils/background_tasks.dart b/mobile/apps/photos/lib/utils/background_tasks.dartindex ca3819f7f4..a3510fc0a2 100644--- a/mobile/apps/photos/lib/utils/background_tasks.dart+++ b/mobile/apps/photos/lib/utils/background_tasks.dart@@ -138,9 +138,7 @@ class BackgroundTasks {requiresNetwork: true,requiresCharging: Platform.isAndroid,runBudget: Platform.isIOS- ? BgTaskUtils.taskTimeoutFor(- BgTaskUtils.iOSBackgroundProcessingTask,- )+ ? null: BgTaskUtils.mlSelfStopFor(BgTaskUtils.androidBackgroundProcessingTask,),@@ -261,6 +259,8 @@ class BackgroundTasks {}task.throwIfStopping();await retireLegacySchedules();+ final isIOSProcessing =+ Platform.isIOS && task.identifier == processing;final taskName = task.identifier == processing? (Platform.isIOS? BgTaskUtils.iOSBackgroundProcessingTask@@ -280,31 +280,37 @@ class BackgroundTasks {);var timedOut = false;try {- final remainingBudget =- BgTaskUtils.taskTimeoutFor(taskName) - task.elapsed;- await runBackgroundTask(+ final remainingBudget = isIOSProcessing+ ? null+ : BgTaskUtils.taskTimeoutFor(taskName) - task.elapsed;+ final work =+ runBackgroundTask(taskName,TimeLogger(),control: control,shouldStop: () => timedOut || task.isStopping,- mlSelfStop:- BgTaskUtils.mlSelfStopFor(taskName) - task.elapsed,+ mlSelfStop: isIOSProcessing+ ? null+ : BgTaskUtils.mlSelfStopFor(taskName) - task.elapsed,mlLockWait: BgTaskUtils.mlLockWaitFor(taskName),- )- .whenComplete(() async {+ ).whenComplete(() async {try {await SuperIsolate.disposeAll();} finally {await SqlDbBase.closeAll();}- })- .timeout(- remainingBudget.isNegative ? Duration.zero : remainingBudget,- onTimeout: () {- timedOut = true;- throw TimeoutException("Background task timed out");- },- );+ });+ if (remainingBudget == null) {+ await work;+ } else {+ await work.timeout(+ remainingBudget.isNegative ? Duration.zero : remainingBudget,+ onTimeout: () {+ timedOut = true;+ throw TimeoutException("Background task timed out");+ },+ );+ }result = task.isStopping? BackgroundTaskResult.stopped: BackgroundTaskResult.completed;