Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: some changes

Prateek Sunal74d930005c2a
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dart
index 037f64759e..8f33cf3fd2 100644
--- a/mobile/apps/photos/lib/main.dart
+++ b/mobile/apps/photos/lib/main.dart
@@ -119,11 +119,6 @@ Future<void> _homeWidgetSync([bool isBackground = false]) async {
return;
}
- if (isBackground) {
- final locale = await getLocale();
- await initializeDateFormatting(locale?.languageCode ?? "en");
- }
-
try {
await HomeWidgetService.instance.initHomeWidget(isBackground);
} catch (e, s) {
@@ -182,11 +177,13 @@ Future<void> _runMinimally(String taskId, TimeLogger tlog) async {
// only runs for android
updateService.showUpdateNotification().ignore();
await _sync('bgTaskActiveProcess');
+
+ final locale = await getLocale();
+ await initializeDateFormatting(locale?.languageCode ?? "en");
// only runs for android
await _homeWidgetSync(true);
await MLService.instance.init();
- await SemanticSearchService.instance.init();
await PersonService.init(entityService, MLDataDB.instance, prefs);
await MLService.instance.runAllML(force: true);
await smartAlbumsService.syncSmartAlbums();
diff --git a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart
index dfc663f85c..3c4f9d046c 100644
--- a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart
@@ -8,6 +8,7 @@ import "package:flutter/foundation.dart";
import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/compute_control_event.dart";
+import "package:photos/main.dart";
import "package:thermal/thermal.dart";
enum _ComputeRunState {
@@ -71,8 +72,12 @@ class ComputeController {
}
bool requestCompute({bool ml = false, bool stream = false}) {
+ // TODO: Remove check
+ if (!isProcessBg) {
+ return false;
+ }
_logger.info("Requesting compute: ml: $ml, stream: $stream");
- if (!_isDeviceHealthy || !_canRunGivenUserInteraction()) {
+ if (!_isDeviceHealthy || !isProcessBg && !_canRunGivenUserInteraction()) {
_logger.info("Device not healthy or user interacting, denying request.");
return false;
}
diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
index 1312aabc6b..c059512d37 100644
--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
@@ -10,6 +10,7 @@ import "package:photos/db/files_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/events/compute_control_event.dart";
import "package:photos/events/people_changed_event.dart";
+import "package:photos/main.dart";
import "package:photos/models/ml/face/face.dart";
import "package:photos/models/ml/ml_versions.dart";
import "package:photos/service_locator.dart";
@@ -136,7 +137,7 @@ class MLService {
);
await clusterAllImages();
}
- if (_mlControllerStatus == true) {
+ if (!isProcessBg && _mlControllerStatus == true) {
// refresh discover section
magicCacheService.updateCache(forced: force).ignore();
// refresh memories section
@@ -148,7 +149,7 @@ class MLService {
if ((await mlDataDB.getUnclusteredFaceCount()) > 0) {
await clusterAllImages();
}
- if (_mlControllerStatus == true) {
+ if (!isProcessBg && _mlControllerStatus == true) {
// refresh discover section
magicCacheService.updateCache().ignore();
// refresh memories section (only runs if forced is true)
@@ -158,9 +159,10 @@ class MLService {
_logger.severe("runAllML failed", e, s);
rethrow;
} finally {
+ _logger.severe("ML finished running");
_isRunningML = false;
computeController.releaseCompute(ml: true);
- VideoPreviewService.instance.queueFiles();
+ if (!isProcessBg) VideoPreviewService.instance.queueFiles();
}
}
diff --git a/mobile/apps/photos/lib/utils/bg_task_utils.dart b/mobile/apps/photos/lib/utils/bg_task_utils.dart
index 1ae1dfcb0b..a4d9c699b0 100644
--- a/mobile/apps/photos/lib/utils/bg_task_utils.dart
+++ b/mobile/apps/photos/lib/utils/bg_task_utils.dart
@@ -23,7 +23,7 @@ void callbackDispatcher() {
try {
BgTaskUtils.$.info('Task started $tlog');
await runBackgroundTask(taskName, tlog).timeout(
- Platform.isIOS ? kBGTaskTimeout : const Duration(hours: 1),
+ !Platform.isIOS ? kBGTaskTimeout : const Duration(hours: 1),
onTimeout: () async {
BgTaskUtils.$.warning(
"TLE, committing seppuku for taskID: $taskName",