π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Internally keep track of MLController status
laurenspriem6ab13710773d
diff --git a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dartindex d4c1a891f0..0508505efe 100644--- a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart+++ b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart@@ -41,7 +41,6 @@ import 'package:photos/services/machine_learning/face_ml/face_ml_exceptions.dartimport 'package:photos/services/machine_learning/face_ml/face_ml_result.dart';import 'package:photos/services/machine_learning/file_ml/file_ml.dart';import 'package:photos/services/machine_learning/file_ml/remote_fileml_service.dart';-import "package:photos/services/machine_learning/machine_learning_controller.dart";import "package:photos/services/search_service.dart";import "package:photos/utils/file_util.dart";import 'package:photos/utils/image_ml_isolate.dart';@@ -86,7 +85,9 @@ class FaceMlService {final _computer = Computer.shared();bool isInitialized = false;+ bool canRunMLController = false;bool isImageIndexRunning = false;+ bool isClusteringRunning = false;final int _parallelism = 10;final int _remoteFetchLimit = 100;@@ -123,7 +124,8 @@ class FaceMlService {/// hooking FaceML into [MachineLearningController]if (Platform.isAndroid) {Bus.instance.on<MachineLearningControlEvent>().listen((event) {- if (event.shouldRun) {+ canRunMLController = event.shouldRun;+ if (canRunMLController) {unawaited(indexAllImages());} else {pauseIndexing();@@ -257,7 +259,8 @@ class FaceMlService {return _functionLock.synchronized(() async {_resetInactivityTimer();- if (isImageIndexRunning == false || MachineLearningController.instance.canRunML == false) {+ if (isImageIndexRunning == false ||+ canRunMLController == false) {return null;}@@ -649,7 +652,7 @@ class FaceMlService {stopwatch.stop();_logger.info(- "`indexAllImages()` finished. Analyzed $fileAnalyzedCount images, in ${stopwatch.elapsed.inSeconds} seconds (avg of ${stopwatch.elapsed.inSeconds / fileAnalyzedCount} seconds per image, skipped $fileSkippedCount images. MLController status: ${MachineLearningController.instance.canRunML})",+ "`indexAllImages()` finished. Analyzed $fileAnalyzedCount images, in ${stopwatch.elapsed.inSeconds} seconds (avg of ${stopwatch.elapsed.inSeconds / fileAnalyzedCount} seconds per image, skipped $fileSkippedCount images. MLController status: $canRunMLController)",);// Dispose of all the isolates@@ -1343,7 +1346,7 @@ class FaceMlService {'''Skipped analysis of image with enteFile, it might be the wrong format or has no uploadedFileID, or MLController doesn't allow it to run.enteFile: ${enteFile.toString()}isImageIndexRunning: $isImageIndexRunning- canRunML: ${MachineLearningController.instance.canRunML}+ canRunML: $canRunMLController''',);throw CouldNotRetrieveAnyFileData();@@ -1351,7 +1354,8 @@ class FaceMlService {}bool _skipAnalysisEnteFile(EnteFile enteFile, Map<int, int> indexedFileIds) {- if (isImageIndexRunning == false || MachineLearningController.instance.canRunML == false) {+ if (isImageIndexRunning == false ||+ canRunMLController == false) {return true;}// Skip if the file is not uploaded or not owned by the userdiff --git a/mobile/lib/services/machine_learning/machine_learning_controller.dart b/mobile/lib/services/machine_learning/machine_learning_controller.dartindex 81c1dc8bc9..8f30dc9ffd 100644--- a/mobile/lib/services/machine_learning/machine_learning_controller.dart+++ b/mobile/lib/services/machine_learning/machine_learning_controller.dart@@ -22,11 +22,9 @@ class MachineLearningController {bool _isDeviceHealthy = true;bool _isUserInteracting = true;- bool _isRunningML = false;+ bool _canRunML = false;late Timer _userInteractionTimer;- get canRunML => _isDeviceHealthy && !_isUserInteracting;-void init() {if (Platform.isAndroid) {_startInteractionTimer();@@ -37,6 +35,7 @@ class MachineLearningController {});} else {// Always run Machine Learning on iOS+ _canRunML = true;Bus.instance.fire(MachineLearningControlEvent(true));}}@@ -54,9 +53,9 @@ class MachineLearningController {}void _fireControlEvent() {- final shouldRunML = canRunML;- if (shouldRunML != _isRunningML) {- _isRunningML = shouldRunML;+ final shouldRunML = _isDeviceHealthy && !_isUserInteracting;+ if (shouldRunML != _canRunML) {+ _canRunML = shouldRunML;_logger.info("Firing event with device health: $_isDeviceHealthy and user interaction: $_isUserInteracting",);