π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Only index locally if enough RAM
laurenspriem054a9deb59e2
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dartindex d33e94f745..1c2542206f 100644--- a/mobile/lib/services/machine_learning/ml_service.dart+++ b/mobile/lib/services/machine_learning/ml_service.dart@@ -28,6 +28,7 @@ import "package:photos/services/machine_learning/semantic_search/semantic_searchimport "package:photos/services/user_remote_flag_service.dart";import "package:photos/utils/ml_util.dart";import "package:photos/utils/network_util.dart";+import "package:photos/utils/ram_check_util.dart";import "package:synchronized/synchronized.dart";class MLService {@@ -69,6 +70,9 @@ class MLService {.getCachedBoolValue(UserRemoteFlagService.mlEnabled)) return;_logger.info("init called");+ // Check if the device has enough RAM to run local indexing+ await checkDeviceTotalRAM();+// Get client namefinal packageInfo = ServiceLocator.instance.packageInfo;client = "${packageInfo.packageName}/${packageInfo.version}";diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dartindex 0376b83c35..d576b2fbe4 100644--- a/mobile/lib/utils/local_settings.dart+++ b/mobile/lib/utils/local_settings.dart@@ -1,4 +1,5 @@import 'package:photos/core/constants.dart';+import "package:photos/utils/ram_check_util.dart";import 'package:shared_preferences/shared_preferences.dart';enum AlbumSortKey {@@ -57,7 +58,7 @@ class LocalSettings {return getRateUsShownCount() < kRateUsPromptThreshold;}- bool get isMLIndexingEnabled => _prefs.getBool(_kisMLIndexingEnabled) ?? true;+ bool get isMLIndexingEnabled => _prefs.getBool(_kisMLIndexingEnabled) ?? enoughRamForLocalIndexing;bool get userEnabledMultiplePart =>_prefs.getBool(kEnableMultiplePart) ?? false;diff --git a/mobile/lib/utils/ram_check_util.dart b/mobile/lib/utils/ram_check_util.dartnew file mode 100644index 0000000000..cf26fcd9d9--- /dev/null+++ b/mobile/lib/utils/ram_check_util.dart@@ -0,0 +1,12 @@+import "package:system_info_plus/system_info_plus.dart";++/// The total amount of RAM in the device in MB+int? deviceTotalRAM;++bool get enoughRamForLocalIndexing => deviceTotalRAM == null || deviceTotalRAM! >= 5 * 1024;++/// Return the total amount of RAM in the device in MB+Future<int?> checkDeviceTotalRAM() async {+ deviceTotalRAM ??= await SystemInfoPlus.physicalMemory; // returns in MB+ return deviceTotalRAM;+}diff --git a/mobile/pubspec.lock b/mobile/pubspec.lockindex ed39789ae6..87517811da 100644--- a/mobile/pubspec.lock+++ b/mobile/pubspec.lock@@ -2475,6 +2475,14 @@ packages:url: "https://pub.dev"source: hostedversion: "3.3.0+3"+ system_info_plus:+ dependency: "direct main"+ description:+ name: system_info_plus+ sha256: b915c811c6605b802f3988859bc2bb79c95f735762a75b5451741f7a2b949d1b+ url: "https://pub.dev"+ source: hosted+ version: "0.0.5"term_glyph:dependency: transitivedescription:diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yamlindex 2b561e1dcd..a5b0724bf7 100644--- a/mobile/pubspec.yaml+++ b/mobile/pubspec.yaml@@ -168,6 +168,7 @@ dependencies:syncfusion_flutter_core: ^25.2.5syncfusion_flutter_sliders: ^25.2.5synchronized: ^3.1.0+ system_info_plus: ^0.0.5tuple: ^2.0.0ua_client_hints: ^1.4.0uni_links: ^0.5.1