From 5beec1d3dd8e5b272e650df06b4b96a016b1d030 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:05:40 +0530 Subject: [PATCH 1/5] [mob] Skip magic refresh if indexing is disabled --- mobile/lib/services/magic_cache_service.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mobile/lib/services/magic_cache_service.dart b/mobile/lib/services/magic_cache_service.dart index 6c66b1bbcc..f70c19316b 100644 --- a/mobile/lib/services/magic_cache_service.dart +++ b/mobile/lib/services/magic_cache_service.dart @@ -94,6 +94,9 @@ class MagicCacheService { } Future _updateCacheIfTheTimeHasCome() async { + if (localSettings.isFaceIndexingEnabled) { + return; + } final jsonFile = await RemoteAssetsService.instance .getAssetIfUpdated(_kMagicPromptsDataUrl); if (jsonFile != null) { From 7e9d9bc1268e1c1a617d70d0620f3888b6dc4a26 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:05:50 +0530 Subject: [PATCH 2/5] [mob] iOS Build changes --- mobile/ios/Podfile.lock | 6 ++++++ mobile/ios/Runner.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 8 insertions(+) diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lock index dc42f83a4b..9ccda2d8ef 100644 --- a/mobile/ios/Podfile.lock +++ b/mobile/ios/Podfile.lock @@ -108,6 +108,8 @@ PODS: - GoogleUtilities/UserDefaults (7.13.3): - GoogleUtilities/Logger - GoogleUtilities/Privacy + - heif_converter (1.0.0): + - Flutter - home_widget (0.0.1): - Flutter - image_editor_common (1.0.0): @@ -261,6 +263,7 @@ DEPENDENCIES: - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) + - heif_converter (from `.symlinks/plugins/heif_converter/ios`) - home_widget (from `.symlinks/plugins/home_widget/ios`) - image_editor_common (from `.symlinks/plugins/image_editor_common/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) @@ -361,6 +364,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_sodium/ios" fluttertoast: :path: ".symlinks/plugins/fluttertoast/ios" + heif_converter: + :path: ".symlinks/plugins/heif_converter/ios" home_widget: :path: ".symlinks/plugins/home_widget/ios" image_editor_common: @@ -462,6 +467,7 @@ SPEC CHECKSUMS: fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 + heif_converter: e3802659e4104e27e28c4d7bff07903da2f69318 home_widget: 0434835a4c9a75704264feff6be17ea40e0f0d57 image_editor_common: d6f6644ae4a6de80481e89fe6d0a8c49e30b4b43 image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 diff --git a/mobile/ios/Runner.xcodeproj/project.pbxproj b/mobile/ios/Runner.xcodeproj/project.pbxproj index dd14771994..349bf83d4a 100644 --- a/mobile/ios/Runner.xcodeproj/project.pbxproj +++ b/mobile/ios/Runner.xcodeproj/project.pbxproj @@ -305,6 +305,7 @@ "${BUILT_PRODUCTS_DIR}/flutter_secure_storage/flutter_secure_storage.framework", "${BUILT_PRODUCTS_DIR}/flutter_sodium/flutter_sodium.framework", "${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework", + "${BUILT_PRODUCTS_DIR}/heif_converter/heif_converter.framework", "${BUILT_PRODUCTS_DIR}/home_widget/home_widget.framework", "${BUILT_PRODUCTS_DIR}/image_editor_common/image_editor_common.framework", "${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework", @@ -400,6 +401,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_secure_storage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_sodium.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/heif_converter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/home_widget.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_editor_common.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework", From 165f288ad9acb4a54aa7cad61f99b539d86924d2 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:07:47 +0530 Subject: [PATCH 3/5] [mob] Remove unused key --- mobile/lib/utils/local_settings.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dart index 726aa04af8..b6dc3a25e7 100644 --- a/mobile/lib/utils/local_settings.dart +++ b/mobile/lib/utils/local_settings.dart @@ -10,9 +10,7 @@ enum AlbumSortKey { class LocalSettings { static const kCollectionSortPref = "collection_sort_pref"; static const kPhotoGridSize = "photo_grid_size"; - static const kEnableMagicSearch = "enable_magic_search"; static const kEnableFaceIndexing = "enable_face_indexing"; - static const kEnableFaceClustering = "enable_face_clustering"; static const kRateUsShownCount = "rate_us_shown_count"; static const kEnableMultiplePart = "ls.enable_multiple_part"; static const kRateUsPromptThreshold = 2; @@ -68,9 +66,6 @@ class LocalSettings { return value; } - bool get isFaceClusteringEnabled => - _prefs.getBool(kEnableFaceIndexing) ?? false; - /// toggleFaceIndexing toggles the face indexing setting and returns the new value Future toggleFaceIndexing() async { await _prefs.setBool(kEnableFaceIndexing, !isFaceIndexingEnabled); From a1b447c5c85556a021abeb94cb6511300061dbad Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:14:28 +0530 Subject: [PATCH 4/5] [mob] Rename --- .../lib/services/machine_learning/ml_service.dart | 6 +++--- .../semantic_search/semantic_search_service.dart | 6 +++--- mobile/lib/services/magic_cache_service.dart | 2 +- mobile/lib/services/search_service.dart | 2 +- .../settings/debug/ml_debug_section_widget.dart | 4 ++-- .../settings/machine_learning_settings_page.dart | 10 +++++----- .../lib/ui/viewer/file/file_details_widget.dart | 2 +- mobile/lib/ui/viewer/search_tab/search_tab.dart | 2 +- mobile/lib/utils/local_settings.dart | 15 +++++++++------ 9 files changed, 26 insertions(+), 23 deletions(-) diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart index d1703de8d9..7fb523a917 100644 --- a/mobile/lib/services/machine_learning/ml_service.dart +++ b/mobile/lib/services/machine_learning/ml_service.dart @@ -62,7 +62,7 @@ class MLService { /// Only call this function once at app startup, after that you can directly call [runAllML] Future init({bool firstTime = false}) async { - if (localSettings.isFaceIndexingEnabled == false || _isInitialized) { + if (localSettings.isMLIndexingEnabled == false || _isInitialized) { return; } _logger.info("init called"); @@ -80,7 +80,7 @@ class MLService { // Listen on MachineLearningController Bus.instance.on().listen((event) { - if (localSettings.isFaceIndexingEnabled == false) { + if (localSettings.isMLIndexingEnabled == false) { return; } _mlControllerStatus = event.shouldRun; @@ -572,7 +572,7 @@ class MLService { void _logStatus() { final String status = ''' isInternalUser: ${flagService.internalUser} - isFaceIndexingEnabled: ${localSettings.isFaceIndexingEnabled} + isMLIndexingEnabled: ${localSettings.isMLIndexingEnabled} canRunMLController: $_mlControllerStatus isIndexingOrClusteringRunning: $_isIndexingOrClusteringRunning shouldPauseIndexingAndClustering: $_shouldPauseIndexingAndClustering diff --git a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart index a9d8eced29..a7c846c29c 100644 --- a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart +++ b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart @@ -42,7 +42,7 @@ class SemanticSearchService { String? _latestPendingQuery; Future init() async { - if (!localSettings.isFaceIndexingEnabled) { + if (!localSettings.isMLIndexingEnabled) { return; } if (_hasInitialized) { @@ -60,7 +60,7 @@ class SemanticSearchService { } bool isMagicSearchEnabledAndReady() { - return localSettings.isFaceIndexingEnabled && + return localSettings.isMLIndexingEnabled && _textModelIsLoaded && _cachedImageEmbeddings.isNotEmpty; } @@ -72,7 +72,7 @@ class SemanticSearchService { if (!isMagicSearchEnabledAndReady()) { if (flagService.internalUser) { _logger.info( - "Magic search enabled ${localSettings.isFaceIndexingEnabled}, loaded $_textModelIsLoaded cached ${_cachedImageEmbeddings.isNotEmpty}", + "Magic search enabled ${localSettings.isMLIndexingEnabled}, loaded $_textModelIsLoaded cached ${_cachedImageEmbeddings.isNotEmpty}", ); } return (query, []); diff --git a/mobile/lib/services/magic_cache_service.dart b/mobile/lib/services/magic_cache_service.dart index f70c19316b..abe1f334a8 100644 --- a/mobile/lib/services/magic_cache_service.dart +++ b/mobile/lib/services/magic_cache_service.dart @@ -94,7 +94,7 @@ class MagicCacheService { } Future _updateCacheIfTheTimeHasCome() async { - if (localSettings.isFaceIndexingEnabled) { + if (localSettings.isMLIndexingEnabled) { return; } final jsonFile = await RemoteAssetsService.instance diff --git a/mobile/lib/services/search_service.dart b/mobile/lib/services/search_service.dart index ae00e18299..88462d7add 100644 --- a/mobile/lib/services/search_service.dart +++ b/mobile/lib/services/search_service.dart @@ -177,7 +177,7 @@ class SearchService { } Future> getMagicSectionResutls() async { - if (localSettings.isFaceIndexingEnabled && flagService.internalUser) { + if (localSettings.isMLIndexingEnabled && flagService.internalUser) { return MagicCacheService.instance.getMagicGenericSearchResult(); } else { return []; diff --git a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart index feb10dac92..7b888e066b 100644 --- a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart +++ b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart @@ -63,7 +63,7 @@ class _MLDebugSectionWidgetState extends State { builder: (context, snapshot) { if (snapshot.hasData) { return CaptionedTextWidget( - title: localSettings.isFaceIndexingEnabled + title: localSettings.isMLIndexingEnabled ? "Disable faces (${snapshot.data!} files done)" : "Enable faces (${snapshot.data!} files done)", ); @@ -76,7 +76,7 @@ class _MLDebugSectionWidgetState extends State { trailingIconIsMuted: true, onTap: () async { try { - final isEnabled = await localSettings.toggleFaceIndexing(); + final isEnabled = await localSettings.toggleMLIndexing(); if (!isEnabled) { MLService.instance.pauseIndexingAndClustering(); } diff --git a/mobile/lib/ui/settings/machine_learning_settings_page.dart b/mobile/lib/ui/settings/machine_learning_settings_page.dart index 89a074ea5b..dbd96e8a43 100644 --- a/mobile/lib/ui/settings/machine_learning_settings_page.dart +++ b/mobile/lib/ui/settings/machine_learning_settings_page.dart @@ -66,7 +66,7 @@ class _MachineLearningSettingsPageState @override Widget build(BuildContext context) { - final hasEnabled = localSettings.isFaceIndexingEnabled; + final hasEnabled = localSettings.isMLIndexingEnabled; return Scaffold( body: CustomScrollView( primary: false, @@ -184,7 +184,7 @@ class _MachineLearningSettingsPageState Future toggleIndexingState() async { final hasGivenConsent = UserRemoteFlagService.instance .getCachedBoolValue(UserRemoteFlagService.mlEnabled); - if (!localSettings.isFaceIndexingEnabled && !hasGivenConsent) { + if (!localSettings.isMLIndexingEnabled && !hasGivenConsent) { final result = await Navigator.push( context, MaterialPageRoute( @@ -197,7 +197,7 @@ class _MachineLearningSettingsPageState return; } } - final isEnabled = await localSettings.toggleFaceIndexing(); + final isEnabled = await localSettings.toggleMLIndexing(); if (isEnabled) { await MLService.instance.init(firstTime: true); await SemanticSearchService.instance.init(); @@ -213,7 +213,7 @@ class _MachineLearningSettingsPageState Widget _getMlSettings(BuildContext context) { final colorScheme = getEnteColorScheme(context); - final hasEnabled = localSettings.isFaceIndexingEnabled; + final hasEnabled = localSettings.isMLIndexingEnabled; return Column( children: [ if (hasEnabled) @@ -223,7 +223,7 @@ class _MachineLearningSettingsPageState ), menuItemColor: colorScheme.fillFaint, trailingWidget: ToggleSwitchWidget( - value: () => localSettings.isFaceIndexingEnabled, + value: () => localSettings.isMLIndexingEnabled, onChanged: () async { await toggleIndexingState(); }, diff --git a/mobile/lib/ui/viewer/file/file_details_widget.dart b/mobile/lib/ui/viewer/file/file_details_widget.dart index 98bf342012..21318523ba 100644 --- a/mobile/lib/ui/viewer/file/file_details_widget.dart +++ b/mobile/lib/ui/viewer/file/file_details_widget.dart @@ -280,7 +280,7 @@ class _FileDetailsWidgetState extends State { ]); } - if (localSettings.isFaceIndexingEnabled) { + if (localSettings.isMLIndexingEnabled) { fileDetailsTiles.addAll([ FacesItemWidget(file), const FileDetailsDivider(), diff --git a/mobile/lib/ui/viewer/search_tab/search_tab.dart b/mobile/lib/ui/viewer/search_tab/search_tab.dart index e6ffb43da8..650eb1be11 100644 --- a/mobile/lib/ui/viewer/search_tab/search_tab.dart +++ b/mobile/lib/ui/viewer/search_tab/search_tab.dart @@ -115,7 +115,7 @@ class _AllSearchSectionsState extends State { itemBuilder: (context, index) { switch (searchTypes[index]) { case SectionType.face: - if (!localSettings.isFaceIndexingEnabled) { + if (!localSettings.isMLIndexingEnabled) { return const SizedBox.shrink(); } return PeopleSection( diff --git a/mobile/lib/utils/local_settings.dart b/mobile/lib/utils/local_settings.dart index b6dc3a25e7..cdf0b6ef63 100644 --- a/mobile/lib/utils/local_settings.dart +++ b/mobile/lib/utils/local_settings.dart @@ -10,7 +10,7 @@ enum AlbumSortKey { class LocalSettings { static const kCollectionSortPref = "collection_sort_pref"; static const kPhotoGridSize = "photo_grid_size"; - static const kEnableFaceIndexing = "enable_face_indexing"; + static const _kisMLIndexingEnabled = "ls.enable_ml_idx"; static const kRateUsShownCount = "rate_us_shown_count"; static const kEnableMultiplePart = "ls.enable_multiple_part"; static const kRateUsPromptThreshold = 2; @@ -55,8 +55,11 @@ class LocalSettings { return getRateUsShownCount() < kRateUsPromptThreshold; } - bool get isFaceIndexingEnabled => - _prefs.getBool(kEnableFaceIndexing) ?? false; + // remove `enable_face_indexing`fallback after sometime, affects internal users only + bool get isMLIndexingEnabled => + _prefs.getBool(_kisMLIndexingEnabled) ?? + _prefs.getBool('enable_face_indexing') ?? + false; bool get userEnabledMultiplePart => _prefs.getBool(kEnableMultiplePart) ?? false; @@ -67,9 +70,9 @@ class LocalSettings { } /// toggleFaceIndexing toggles the face indexing setting and returns the new value - Future toggleFaceIndexing() async { - await _prefs.setBool(kEnableFaceIndexing, !isFaceIndexingEnabled); - return isFaceIndexingEnabled; + Future toggleMLIndexing() async { + await _prefs.setBool(_kisMLIndexingEnabled, !isMLIndexingEnabled); + return isMLIndexingEnabled; } //#region todo:(NG) remove this section, only needed for internal testing to see From 915612195417df914e2c45856713c4e587639cd5 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:14:53 +0530 Subject: [PATCH 5/5] bump version --- mobile/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 98e61a187c..f594556d65 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.9.24+924 +version: 0.9.25+925 publish_to: none environment: