Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Remove upload debug logs and widget V2 code

Prateek Sunal268202eb0e80
diff --git a/mobile/apps/photos/lib/services/home_widget_service.dart b/mobile/apps/photos/lib/services/home_widget_service.dart
index bf7e8411b5..cb08bab415 100644
--- a/mobile/apps/photos/lib/services/home_widget_service.dart
+++ b/mobile/apps/photos/lib/services/home_widget_service.dart
@@ -1,27 +1,17 @@
import 'dart:convert';
import 'dart:io';
-import 'dart:math' as math;
-import 'dart:ui' as ui;
-import 'package:computer/computer.dart';
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
import 'package:home_widget/home_widget.dart' as hw;
-import 'package:image/image.dart' as img;
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path_provider_foundation/path_provider_foundation.dart';
-import 'package:photo_manager/photo_manager.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/models/file/file.dart';
-import 'package:photos/models/file/file_type.dart';
-import 'package:photos/service_locator.dart';
import 'package:photos/services/album_home_widget_service.dart';
import 'package:photos/services/memory_home_widget_service.dart';
import 'package:photos/services/people_home_widget_service.dart';
import 'package:photos/services/smart_memories_service.dart';
-import 'package:photos/utils/file_util.dart';
import 'package:photos/utils/thumbnail_util.dart';
import 'package:synchronized/synchronized.dart';
@@ -42,12 +32,9 @@ enum WidgetStatus {
/// Handles widget initialization, updates, and interaction with platform-specific widget APIs
class HomeWidgetService {
// Constants
- static const int _widgetV2Size = 1024;
static const double THUMBNAIL_SIZE = 512.0;
- static const double THUMBNAIL_SIZE_V2 = 1024.0;
static const String WIDGET_DIRECTORY = 'home_widget';
static const int WIDGET_IMAGE_LIMIT_V1 = 50;
- static const int WIDGET_IMAGE_LIMIT_V2 = 25;
static const int WIDGET_IMAGE_LIMIT_MINIMAL = 5;
// URI schemes for different widget types
@@ -67,7 +54,6 @@ class HomeWidgetService {
HomeWidgetService._privateConstructor();
final Logger _logger = Logger((HomeWidgetService).toString());
- final Computer _computer = Computer.shared();
final computeLock = Lock();
bool _isAppGroupSet = false;
@@ -84,9 +70,7 @@ class HomeWidgetService {
}
int getWidgetImageLimit() {
- return flagService.useWidgetV2
- ? WIDGET_IMAGE_LIMIT_V2
- : WIDGET_IMAGE_LIMIT_V1;
+ return WIDGET_IMAGE_LIMIT_V1;
}
Future<void> initHomeWidget([bool isBg = false]) async {
@@ -122,20 +106,6 @@ class HomeWidgetService {
String title,
String? mainKey,
) async {
- // Use V2 (1024x1024 rendering) with isolate-based image processing
- final bool useV2 = flagService.useWidgetV2;
-
- if (useV2) {
- final Size? v2Size = await _captureFileV2(file, key, title, mainKey);
- if (v2Size != null) {
- return v2Size;
- }
- _logger.info(
- "V2 capture failed for ${file.displayName}, falling back to legacy",
- );
- }
-
- // Use legacy capture (either useV2 is false, or V2 failed)
final result = await _captureFileLegacy(file, key, title, mainKey);
if (!result) {
_logger.warning("Failed to capture file ${file.displayName}");
@@ -165,215 +135,6 @@ class HomeWidgetService {
return await hw.HomeWidget.getInstalledWidgets();
}
- Future<Size?> _captureFileV2(
- EnteFile file,
- String key,
- String title,
- String? mainKey,
- ) async {
- if (file.fileType == FileType.video) {
- return null;
- }
-
- final _WidgetSourceBytes? source = await _resolveWidgetSourceBytes(file);
- if (source == null) {
- return null;
- }
-
- try {
- String decodeStrategy = 'package:image';
- _WidgetImageProcessResult? processed =
- await _computeWidgetImageResult(source.bytes);
-
- if (processed == null) {
- final Uint8List? pngBytes = await _decodeWithUiFallback(source.bytes);
- if (pngBytes != null) {
- decodeStrategy = 'ui-codec';
- processed = await _computeWidgetImageResult(pngBytes);
- }
- }
-
- if (processed == null) {
- _logger.warning(
- "[widget_capture_v2] Failed to decode image for ${file.displayName} using ${source.sourceLabel}",
- );
- return null;
- }
-
- final String widgetDirectory = await _getWidgetStorageDirectory();
- final String imagePath = '$widgetDirectory/$WIDGET_DIRECTORY/$key.png';
- final File outputFile = File(imagePath);
- if (!await outputFile.exists()) {
- await outputFile.create(recursive: true);
- }
- await outputFile.writeAsBytes(processed.pngBytes);
- await setData(key, imagePath);
-
- final subText = await SmartMemoriesService.getDateFormattedLocale(
- creationTime: file.creationTime!,
- );
- // TODO: Remove dimension display after confirmation that widget v2 works correctly
- final bool showDimensions = kDebugMode || flagService.internalUser;
- final String resolvedSubText = showDimensions
- ? '$subText Β· ${processed.finalWidth}x${processed.finalHeight} Β· ${source.sourceLabel}'
- : subText;
- final Map<String, dynamic> metadata = {
- "title": title,
- "subText": resolvedSubText,
- "generatedId": file.generatedID!,
- if (mainKey != null) "mainKey": mainKey,
- };
- await _saveWidgetMetadata(key, metadata);
-
- _logger.info(
- "[widget_capture_v2] key=$key source=${source.sourceLabel} original=${processed.originalWidth}x${processed.originalHeight} "
- "final=${processed.finalWidth}x${processed.finalHeight} cropped=${processed.croppedToSquare} downscaled=${processed.downscaled} strategy=$decodeStrategy",
- );
-
- return Size(
- processed.finalWidth.toDouble(),
- processed.finalHeight.toDouble(),
- );
- } catch (error, stackTrace) {
- _logger.severe(
- "[widget_capture_v2] Failed to capture widget for ${file.displayName}",
- error,
- stackTrace,
- );
- return null;
- }
- }
-
- Future<Uint8List?> _decodeWithUiFallback(Uint8List bytes) async {
- try {
- final ui.Codec codec = await ui.instantiateImageCodec(bytes);
- final ui.FrameInfo frame = await codec.getNextFrame();
- final ui.Image image = frame.image;
- final ByteData? data =
- await image.toByteData(format: ui.ImageByteFormat.png);
- image.dispose();
- codec.dispose();
- return data?.buffer.asUint8List();
- } catch (error, stackTrace) {
- _logger.fine(
- "[widget_capture_v2] ui codec decode failed",
- error,
- stackTrace,
- );
- return null;
- }
- }
-
- Future<_WidgetImageProcessResult?> _computeWidgetImageResult(
- Uint8List bytes,
- ) async {
- try {
- final Map<String, dynamic>? result = await _computer.compute(
- _processWidgetImage,
- param: {
- 'bytes': bytes,
- 'targetSize': _widgetV2Size,
- },
- );
- if (result == null) {
- return null;
- }
- return _WidgetImageProcessResult.fromMap(result);
- } catch (error, stackTrace) {
- _logger.fine(
- "[widget_capture_v2] isolate processing failed",
- error,
- stackTrace,
- );
- return null;
- }
- }
-
- Future<_WidgetSourceBytes?> _resolveWidgetSourceBytes(EnteFile file) async {
- if (!file.isRemoteFile) {
- try {
- final AssetEntity? asset = await file.getAsset;
- if (asset != null) {
- final Uint8List? assetBytes = await asset.thumbnailDataWithSize(
- const ThumbnailSize.square(_widgetV2Size),
- quality: 90,
- );
- if (assetBytes != null && assetBytes.isNotEmpty) {
- return _WidgetSourceBytes(
- bytes: assetBytes,
- sourceLabel: 'asset.thumbnail',
- );
- }
-
- final File? originFile = await asset.originFile;
- if (originFile != null && await originFile.exists()) {
- final Uint8List originBytes = await originFile.readAsBytes();
- if (originBytes.isNotEmpty) {
- return _WidgetSourceBytes(
- bytes: originBytes,
- sourceLabel: 'asset.origin',
- );
- }
- }
- }
- } catch (error, stackTrace) {
- _logger.fine(
- "[widget_capture_v2] Failed to resolve local asset for ${file.displayName}",
- error,
- stackTrace,
- );
- }
- }
-
- if (file.uploadedFileID != null &&
- (file.isRemoteFile ||
- file.fileType == FileType.image ||
- file.fileType == FileType.livePhoto)) {
- // Check file size before downloading (skip very large files)
- const int maxFileSizeForWidget = 50 * 1024 * 1024; // 50MB
- if (file.fileSize != null && file.fileSize! > maxFileSizeForWidget) {
- _logger.info(
- "[widget_capture_v2] Skipping large file (${file.fileSize} bytes) for ${file.displayName}",
- );
- // Fall through to thumbnail fallback
- } else {
- // Use getFileFromServer to maintain caching behavior
- // This caches downloaded files so subsequent widget syncs can reuse them
- try {
- final File? cachedFile = await getFileFromServer(file);
- if (cachedFile != null && await cachedFile.exists()) {
- final Uint8List fileBytes = await cachedFile.readAsBytes();
- if (fileBytes.isNotEmpty) {
- final String sourceLabel = file.fileType == FileType.livePhoto
- ? 'cached-live-image'
- : 'cached-full';
- return _WidgetSourceBytes(
- bytes: fileBytes,
- sourceLabel: sourceLabel,
- );
- }
- }
- } catch (error, stackTrace) {
- _logger.warning(
- "[widget_capture_v2] Download failed for ${file.displayName}",
- error,
- stackTrace,
- );
- }
- }
- }
-
- final Uint8List? fallbackThumbnail = await getThumbnail(file);
- if (fallbackThumbnail != null && fallbackThumbnail.isNotEmpty) {
- return _WidgetSourceBytes(
- bytes: fallbackThumbnail,
- sourceLabel: 'legacy-thumbnail',
- );
- }
-
- return null;
- }
-
Future<bool> _captureFileLegacy(
EnteFile file,
String key,
@@ -541,113 +302,3 @@ class HomeWidgetService {
}
}
}
-
-class _WidgetImageProcessResult {
- const _WidgetImageProcessResult({
- required this.pngBytes,
- required this.originalWidth,
- required this.originalHeight,
- required this.finalWidth,
- required this.finalHeight,
- required this.croppedToSquare,
- required this.downscaled,
- });
-
- factory _WidgetImageProcessResult.fromMap(Map<String, dynamic> map) {
- return _WidgetImageProcessResult(
- pngBytes: map['pngBytes'] as Uint8List,
- originalWidth: map['originalWidth'] as int,
- originalHeight: map['originalHeight'] as int,
- finalWidth: map['finalWidth'] as int,
- finalHeight: map['finalHeight'] as int,
- croppedToSquare: map['croppedToSquare'] as bool,
- downscaled: map['downscaled'] as bool,
- );
- }
-
- final Uint8List pngBytes;
- final int originalWidth;
- final int originalHeight;
- final int finalWidth;
- final int finalHeight;
- final bool croppedToSquare;
- final bool downscaled;
-}
-
-Future<Map<String, dynamic>?> _processWidgetImage(
- Map<String, dynamic> param,
-) async {
- try {
- final Uint8List bytes = param['bytes'] as Uint8List;
- final int targetSize = param['targetSize'] as int;
-
- final img.Image? decoded = img.decodeImage(bytes);
- if (decoded == null) {
- return null;
- }
-
- // Apply EXIF orientation before cropping to prevent portrait photos from being rotated incorrectly
- final img.Image oriented = img.bakeOrientation(decoded);
-
- final int originalWidth = oriented.width;
- final int originalHeight = oriented.height;
- final int minSide = math.min(originalWidth, originalHeight);
- if (minSide <= 0) {
- return null;
- }
-
- img.Image working = oriented;
- bool croppedToSquare = false;
- if (originalWidth != originalHeight) {
- final int cropSize = minSide;
- final int left = ((originalWidth - cropSize) / 2).round();
- final int top = ((originalHeight - cropSize) / 2).round();
- working = img.copyCrop(
- oriented,
- x: math.max(0, left),
- y: math.max(0, top),
- width: cropSize,
- height: cropSize,
- );
- croppedToSquare = true;
- }
-
- img.Image finalImage = working;
- bool downscaled = false;
- if (working.width > targetSize) {
- finalImage = img.copyResize(
- working,
- width: targetSize,
- height: targetSize,
- interpolation: img.Interpolation.linear,
- );
- downscaled = true;
- }
-
- final Uint8List pngBytes =
- Uint8List.fromList(img.encodePng(finalImage, level: 0));
-
- return <String, dynamic>{
- 'pngBytes': pngBytes,
- 'originalWidth': originalWidth,
- 'originalHeight': originalHeight,
- 'finalWidth': finalImage.width,
- 'finalHeight': finalImage.height,
- 'croppedToSquare': croppedToSquare,
- 'downscaled': downscaled,
- };
- } catch (e) {
- // Catch errors from copyCrop, copyResize, encodePng (malformed images, OOM, etc.)
- return null;
- }
-}
-
-class _WidgetSourceBytes {
- const _WidgetSourceBytes({
- required this.bytes,
- required this.sourceLabel,
- });
-
- final Uint8List bytes;
- final String sourceLabel;
-}
diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
index 7b133e0d87..351ab78bf9 100644
--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart
@@ -17,7 +17,6 @@ import 'package:photos/events/files_updated_event.dart';
import 'package:photos/events/force_reload_home_gallery_event.dart';
import 'package:photos/events/local_photos_updated_event.dart';
import 'package:photos/events/sync_status_update_event.dart';
-import "package:photos/extensions/logger_extension.dart";
import "package:photos/main.dart" show isProcessBg;
import 'package:photos/models/device_collection.dart';
import "package:photos/models/file/extensions/file_props.dart";
@@ -633,131 +632,45 @@ class RemoteSyncService {
final int toBeUploaded = filesToBeUploaded.length + updatedFileIDs.length;
if (toBeUploaded > 0) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Preparing to upload $toBeUploaded files "
- "(${filesToBeUploaded.length} new, ${updatedFileIDs.length} updated) "
- "in ${isProcessBg ? 'BACKGROUND' : 'FOREGROUND'} mode",
- );
-
Bus.instance.fire(
SyncStatusUpdate(SyncStatus.preparingForUpload, total: toBeUploaded),
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Fired preparingForUpload status update",
- );
-
- // Step 1: Verify media location access permission
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Step 1/3: Checking media location access permission...",
- );
await _uploader.verifyMediaLocationAccess();
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Step 1/3: Media location access verified βœ“",
- );
-
- // Step 2: Check network availability for upload
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Step 2/3: Checking network availability for upload...",
- );
await _uploader.checkNetworkForUpload();
- _logger.internalInfo("[UPLOAD-DEBUG] Step 2/3: Network check passed βœ“");
-
- // Step 3: Fetch upload URLs from server
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Step 3/3: Fetching upload URLs from server for $toBeUploaded files...",
- );
await _uploader.fetchUploadURLs(toBeUploaded);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Step 3/3: Upload URLs fetched successfully βœ“",
- );
-
- _logger.internalInfo(
- "[UPLOAD-DEBUG] All pre-upload checks completed successfully! "
- "Proceeding to queue individual file uploads...",
- );
- } else {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] No files to upload, skipping upload preparation",
- );
}
final List<Future> futures = [];
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Starting to queue ${filesToBeUploaded.length} new files for upload...",
- );
- int queuedCount = 0;
for (final file in filesToBeUploaded) {
if (shouldThrottleUpload &&
futures.length >= kMaximumPermissibleUploadsInThrottledMode) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Throttle limit reached (${futures.length} files queued). "
- "Skipping remaining ${filesToBeUploaded.length - queuedCount} files.",
- );
break;
}
// prefer existing collection ID for manually uploaded files.
// See https://github.com/ente-io/photos-app/pull/187
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Queueing file ${queuedCount + 1}/${filesToBeUploaded.length}: "
- "${file.title} (localID: ${file.localID}, generatedID: ${file.generatedID})",
- );
try {
final collectionID = file.collectionID ??
(await _collectionsService.getOrCreateForPath(
file.deviceFolder ?? 'Unknown Folder',
))
.id;
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Resolved collectionID: $collectionID for file ${file.title}",
- );
_uploadFile(file, collectionID, futures);
- queuedCount++;
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Successfully queued file ${file.title} ($queuedCount queued so far)",
- );
- } catch (e, s) {
- _logger.internalSevere(
- "[UPLOAD-DEBUG] Failed to queue file ${file.title}",
- e,
- s,
- );
- }
+ } catch (_) {}
}
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Finished queueing new files. Total queued: $queuedCount/${filesToBeUploaded.length}",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Starting to queue ${updatedFileIDs.length} updated files for re-upload...",
- );
- int reuploadQueuedCount = 0;
for (final uploadedFileID in updatedFileIDs) {
if (shouldThrottleUpload &&
futures.length >= kMaximumPermissibleUploadsInThrottledMode) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Throttle limit reached for re-uploads (${futures.length} total queued). "
- "Skipping remaining ${updatedFileIDs.length - reuploadQueuedCount} updated files.",
- );
break;
}
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Processing updated file ${reuploadQueuedCount + 1}/${updatedFileIDs.length} "
- "(uploadedFileID: $uploadedFileID)",
- );
try {
final allFiles = await _db.getFilesInAllCollection(
uploadedFileID,
ownerID,
);
if (allFiles.isEmpty) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] No files found for uploadedFileID $uploadedFileID, skipping",
- );
continue;
}
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Found ${allFiles.length} file(s) for uploadedFileID $uploadedFileID",
- );
EnteFile? fileInCollectionOwnedByUser;
for (final file in allFiles) {
if (file.canReUpload(ownerID)) {
@@ -766,142 +679,41 @@ class RemoteSyncService {
}
}
if (fileInCollectionOwnedByUser != null) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Queueing re-upload for ${fileInCollectionOwnedByUser.title}",
- );
_uploadFile(
fileInCollectionOwnedByUser,
fileInCollectionOwnedByUser.collectionID!,
futures,
);
- reuploadQueuedCount++;
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Successfully queued re-upload ($reuploadQueuedCount re-uploads queued)",
- );
- } else {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] No re-uploadable file found for uploadedFileID $uploadedFileID",
- );
}
- } catch (e, s) {
- _logger.internalSevere(
- "[UPLOAD-DEBUG] Failed to queue re-upload for uploadedFileID $uploadedFileID",
- e,
- s,
- );
- }
+ } catch (_) {}
}
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Finished queueing updated files. Total re-uploads queued: "
- "$reuploadQueuedCount/${updatedFileIDs.length}",
- );
-
- _logger.internalInfo(
- "[UPLOAD-DEBUG] ═══════════════════════════════════════════════════════",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] SUMMARY: Total ${futures.length} upload futures queued",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] - New files queued: $queuedCount/${filesToBeUploaded.length}",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] - Re-uploads queued: $reuploadQueuedCount/${updatedFileIDs.length}",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] - Process mode: ${isProcessBg ? 'BACKGROUND' : 'FOREGROUND'}",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Now waiting for all ${futures.length} upload futures to complete...",
- );
- _logger.internalInfo(
- "[UPLOAD-DEBUG] ═══════════════════════════════════════════════════════",
- );
try {
await Future.wait(futures);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] All upload futures completed successfully! "
- "Completed: $_completedUploads, Ignored: $_ignoredUploads",
- );
- } on InvalidFileError catch (e, s) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] InvalidFileError caught (ignored)",
- e,
- s,
- );
+ } on InvalidFileError {
// Do nothing
- } on FileSystemException catch (e, s) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] FileSystemException caught (ignored - likely concurrency issue)",
- e,
- s,
- );
+ } on FileSystemException {
// Do nothing since it's caused mostly due to concurrency issues
// when the foreground app deletes temporary files, interrupting a background
// upload
- } on LockAlreadyAcquiredError catch (e, s) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] LockAlreadyAcquiredError caught (ignored)",
- e,
- s,
- );
+ } on LockAlreadyAcquiredError {
// Do nothing
- } on SilentlyCancelUploadsError catch (e, s) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] SilentlyCancelUploadsError caught (ignored)",
- e,
- s,
- );
+ } on SilentlyCancelUploadsError {
// Do nothing
- } on UserCancelledUploadError catch (e, s) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] UserCancelledUploadError caught (ignored)",
- e,
- s,
- );
+ } on UserCancelledUploadError {
// Do nothing
- } catch (e, s) {
- _logger.internalSevere(
- "[UPLOAD-DEBUG] Unexpected error during upload",
- e,
- s,
- );
- rethrow;
}
- final hasUploaded = _completedUploads > 0;
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Upload process finished. Returning hasUploaded=$hasUploaded "
- "(completedUploads: $_completedUploads)",
- );
- return hasUploaded;
+ return _completedUploads > 0;
}
void _uploadFile(EnteFile file, int collectionID, List<Future> futures) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _uploadFile() called for ${file.title} "
- "(localID: ${file.localID}, collectionID: $collectionID). "
- "Calling FileUploader.upload()...",
- );
final future = _uploader.upload(file, collectionID).then((uploadedFile) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Upload completed successfully for ${uploadedFile.title}",
- );
return _onFileUploaded(uploadedFile);
}).onError((error, stackTrace) {
- _logger.internalSevere(
- "[UPLOAD-DEBUG] Upload failed for ${file.title}",
- error,
- stackTrace,
- );
return _onFileUploadError(error, stackTrace, file);
});
futures.add(future);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Upload future added to futures list for ${file.title} "
- "(futures count: ${futures.length})",
- );
}
Future<void> _onFileUploaded(EnteFile file) async {
diff --git a/mobile/apps/photos/lib/utils/file_uploader.dart b/mobile/apps/photos/lib/utils/file_uploader.dart
index c4946b83f1..7b9e3afb6f 100644
--- a/mobile/apps/photos/lib/utils/file_uploader.dart
+++ b/mobile/apps/photos/lib/utils/file_uploader.dart
@@ -23,7 +23,6 @@ import "package:photos/events/file_uploaded_event.dart";
import 'package:photos/events/files_updated_event.dart';
import 'package:photos/events/local_photos_updated_event.dart';
import 'package:photos/events/subscription_purchased_event.dart';
-import "package:photos/extensions/logger_extension.dart";
import "package:photos/main.dart" show isProcessBg, kLastBGTaskHeartBeatTime;
import "package:photos/models/api/metadata.dart";
import "package:photos/models/backup/backup_item.dart";
@@ -171,26 +170,13 @@ class FileUploader {
// upload future will return null as File when the file entry is deleted
// locally because it's already present in the destination collection.
Future<EnteFile> upload(EnteFile file, int collectionID) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] FileUploader.upload() called for ${file.title} "
- "(localID: ${file.localID}, collectionID: $collectionID, "
- "isProcessBg: $isProcessBg)",
- );
-
if (file.localID == null || file.localID!.isEmpty) {
- _logger.internalSevere(
- "[UPLOAD-DEBUG] Upload rejected - file's localID is null or empty for ${file.title}",
- );
return Future.error(Exception("file's localID can not be null or empty"));
}
// If the file hasn't been queued yet, queue it for upload
_totalCountInUploadSession++;
final String localID = file.localID!;
if (!_queue.containsKey(localID)) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] File ${file.title} not in queue. Adding to upload queue... "
- "(queue size before: ${_queue.length})",
- );
final completer = Completer<EnteFile>();
_queue[localID] = FileUploadItem(file, collectionID, completer);
_allBackups[localID] = BackupItem(
@@ -200,33 +186,16 @@ class FileUploader {
completer: completer,
);
Bus.instance.fire(BackupUpdatedEvent(_allBackups));
- _logger.internalInfo(
- "[UPLOAD-DEBUG] File ${file.title} added to queue (queue size: ${_queue.length}). "
- "Calling _pollQueue()...",
- );
_pollQueue();
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _pollQueue() called for ${file.title}. Returning completer.future",
- );
return completer.future;
}
// If the file exists in the queue for a matching collectionID,
// return the existing future
- _logger.internalInfo(
- "[UPLOAD-DEBUG] File ${file.title} already in queue with localID $localID",
- );
final FileUploadItem item = _queue[localID]!;
if (item.collectionID == collectionID) {
_totalCountInUploadSession--;
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Same collectionID ($collectionID) - returning existing future",
- );
return item.completer.future;
}
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Different collectionID (existing: ${item.collectionID}, new: $collectionID) "
- "- waiting for existing upload to complete",
- );
debugPrint(
"Wait on another upload on same local ID to finish before "
"adding it to new collection",
@@ -300,55 +269,25 @@ class FileUploader {
}
void _pollQueue() {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _pollQueue() called. Queue size: ${_queue.length}, "
- "uploadCounter: $_uploadCounter/$kMaximumConcurrentUploads, "
- "isProcessBg: $isProcessBg",
- );
-
if (SyncService.instance.shouldStopSync()) {
- _logger.internalWarning(
- "[UPLOAD-DEBUG] Sync stop requested - clearing queue",
- );
clearQueue(SyncStopRequestedError());
return;
}
if (_queue.isEmpty) {
// Upload session completed
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Queue is empty - upload session completed. "
- "Resetting totalCountInUploadSession",
- );
_totalCountInUploadSession = 0;
return;
}
if (_uploadCounter < kMaximumConcurrentUploads) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Upload capacity available ($_uploadCounter < $kMaximumConcurrentUploads). "
- "Searching for pending entry...",
- );
var pendingEntry = _queue.entries
.firstWhereOrNull(
(entry) => entry.value.status == UploadStatus.notStarted,
)
?.value;
- if (pendingEntry != null) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Found pending entry: ${pendingEntry.file.title} "
- "(fileType: ${pendingEntry.file.fileType})",
- );
- } else {
- _logger.internalInfo("[UPLOAD-DEBUG] No pending entry found in queue");
- }
-
if (pendingEntry != null &&
pendingEntry.file.fileType == FileType.video &&
_videoUploadCounter >= kMaximumConcurrentVideoUploads) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Video upload limit reached ($_videoUploadCounter >= $kMaximumConcurrentVideoUploads). "
- "Looking for non-video entry...",
- );
// check if there's any non-video entry which can be queued for upload
pendingEntry = _queue.entries
.firstWhereOrNull(
@@ -357,19 +296,8 @@ class FileUploader {
entry.value.file.fileType != FileType.video,
)
?.value;
- if (pendingEntry != null) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Found non-video entry: ${pendingEntry.file.title}",
- );
- } else {
- _logger.internalInfo("[UPLOAD-DEBUG] No non-video entry available");
- }
}
if (pendingEntry != null) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Starting upload for ${pendingEntry.file.title}. "
- "Marking as inProgress and calling _encryptAndUploadFileToCollection()...",
- );
pendingEntry.status = UploadStatus.inProgress;
_allBackups[pendingEntry.file.localID!] =
_allBackups[pendingEntry.file.localID]!
@@ -379,20 +307,7 @@ class FileUploader {
pendingEntry.file,
pendingEntry.collectionID,
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _encryptAndUploadFileToCollection() initiated for ${pendingEntry.file.title}",
- );
- } else {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] No pending entry to process at this time "
- "(either all uploads in progress or video limit reached)",
- );
}
- } else {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Upload capacity full ($_uploadCounter >= $kMaximumConcurrentUploads). "
- "Waiting for uploads to complete...",
- );
}
}
@@ -401,36 +316,20 @@ class FileUploader {
int collectionID, {
bool forcedUpload = false,
}) async {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _encryptAndUploadFileToCollection() started for ${file.title} "
- "(collectionID: $collectionID, forcedUpload: $forcedUpload, "
- "isProcessBg: $isProcessBg)",
- );
_uploadCounter++;
if (file.fileType == FileType.video) {
_videoUploadCounter++;
}
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Upload counters updated: uploadCounter=$_uploadCounter, "
- "videoUploadCounter=$_videoUploadCounter",
- );
final localID = file.localID!;
try {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Calling _tryToUpload() for ${file.title} with ${kFileUploadTimeout.inSeconds}s timeout...",
- );
final uploadedFile =
await _tryToUpload(file, collectionID, forcedUpload).timeout(
kFileUploadTimeout,
onTimeout: () {
final message = "Upload timed out for file " + file.toString();
- _logger.internalWarning("[UPLOAD-DEBUG] $message");
throw TimeoutException(message);
},
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _tryToUpload() completed successfully for ${file.title}",
- );
_queue.remove(localID)!.completer.complete(uploadedFile);
_allBackups[localID] =
_allBackups[localID]!.copyWith(status: BackupItemStatus.uploaded);
@@ -820,43 +719,28 @@ class FileUploader {
late String thumbnailObjectKey;
if (count <= 1) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Non-multipart upload: Getting thumbnail upload URL...",
- );
final thumbnailUploadURL = await _getUploadURL(
contentLength: useChecksumThumbnailUpload ? encThumbSize : null,
contentMd5: useChecksumThumbnailUpload ? thumbnailMd5 : null,
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Thumbnail URL obtained, uploading thumbnail (size: ${formatBytes(encThumbSize)})...",
- );
thumbnailObjectKey = await _putFile(
thumbnailUploadURL,
encryptedThumbnailFile,
encThumbSize,
contentMd5: thumbnailMd5,
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Thumbnail uploaded successfully! Now getting file upload URL...",
- );
final useChecksumUpload =
flagService.enableUploadV2 && fileMd5?.isNotEmpty == true;
final fileUploadURL = await _getUploadURL(
contentLength: useChecksumUpload ? encFileSize : null,
contentMd5: useChecksumUpload ? fileMd5 : null,
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] File URL obtained, uploading actual file (size: ${formatBytes(encFileSize)})...",
- );
fileObjectKey = await _putFile(
fileUploadURL,
encryptedFile,
encFileSize,
contentMd5: fileMd5,
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Actual file uploaded successfully!",
- );
} else {
isMultipartUpload = true;
_logger.info(
@@ -1529,9 +1413,6 @@ class FileUploader {
required int contentLength,
required String contentMd5,
}) async {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Requesting single upload URL with checksum metadata (size: ${formatBytes(contentLength)})",
- );
final response = await _enteDio.post(
"/files/upload-url",
data: {
@@ -1545,25 +1426,13 @@ class FileUploader {
}
Future<UploadURL> _getLegacyUploadURL() async {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] _getUploadURL() called. URL queue size: ${_uploadURLs.length}, Upload queue size: ${_queue.length}",
- );
if (_uploadURLs.isEmpty) {
- _logger.internalInfo(
- "[UPLOAD-DEBUG] URL queue is empty, fetching new upload URLs from server...",
- );
// the queue is empty, fetch at least for one file to handle force uploads
// that are not in the queue. This is to also avoid
await fetchUploadURLs(math.max(_queue.length, 1));
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Successfully fetched upload URLs. New queue size: ${_uploadURLs.length}",
- );
}
try {
final uploadURL = _uploadURLs.removeFirst();
- _logger.internalInfo(
- "[UPLOAD-DEBUG] Returning upload URL. Remaining URLs in queue: ${_uploadURLs.length}",
- );
return uploadURL;
} catch (e) {
if (e is StateError && e.message == 'No element' && _queue.isEmpty) {
@@ -1605,25 +1474,16 @@ class FileUploader {
_uploadURLFetchInProgress ??= Future<void>(() async {
try {
final requestCount = math.min(42, fileCount * 2);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] fetchUploadURLs() starting HTTP GET to /files/upload-urls with count=$requestCount",
- );
final response = await _enteDio.get(
"/files/upload-urls",
queryParameters: {
"count": requestCount, // m4gic number
},
);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] HTTP GET completed, parsing ${(response.data["urls"] as List).length} URLs...",
- );
final urls = (response.data["urls"] as List)
.map((e) => UploadURL.fromMap(e))
.toList();
_uploadURLs.addAll(urls);
- _logger.internalInfo(
- "[UPLOAD-DEBUG] fetchUploadURLs() completed. Added ${urls.length} URLs to queue.",
- );
} on DioException catch (e, s) {
if (e.response != null) {
if (e.response!.statusCode == 402) {
diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
index d2650f2d51..4d46fc6d52 100644
--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
@@ -84,8 +84,6 @@ class FlagService {
bool get useNativeVideoEditor => true;
- bool get useWidgetV2 => internalUser;
-
bool get enableOnlyBackupFuturePhotos => internalUser;
bool get facesTimeline => internalUser;
diff --git a/mobile/apps/photos/scripts/internal_changes.txt b/mobile/apps/photos/scripts/internal_changes.txt
index 82a461444d..1707463f96 100644
--- a/mobile/apps/photos/scripts/internal_changes.txt
+++ b/mobile/apps/photos/scripts/internal_changes.txt
@@ -1,6 +1,5 @@
- Prateek: (i) Video streaming bitrate changes & enable streaming by default
-- Prateek: (i) Add "Start with latest backups" (last 7 days onwards)
+- Prateek: (i) Add "Start with latest backups" (last 7 days onwards)
- Neeraj: (i) Admin Role + Suggest Delete feature
- Laurens: (i) People Memory Lane feature
- Neeraj: (i) Show public link to album participants
-- Prateek: (i) Upload Debug logging. Optimize home widget image quality with V2