diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index 50de0b9a1..247ab9553 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -51,6 +51,7 @@ import 'package:photos/services/user_service.dart'; import 'package:photos/ui/tools/app_lock.dart'; import 'package:photos/ui/tools/lock_screen.dart'; import 'package:photos/utils/crypto_util.dart'; +import "package:photos/utils/email_util.dart"; import 'package:photos/utils/file_uploader.dart'; import 'package:photos/utils/local_settings.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -180,6 +181,16 @@ void _headlessTaskHandler(HeadlessTask task) { } Future _init(bool isBackground, {String via = ''}) async { + bool initComplete = false; + Future.delayed(const Duration(seconds: 15), () { + if (!initComplete && !isBackground) { + sendLogsForInit( + "support@ente.io", + "Stuck on splash screen for >= 15 seconds", + null, + ); + } + }); _isProcessRunning = true; _logger.info("Initializing... inBG =$isBackground via: $via"); final SharedPreferences preferences = await SharedPreferences.getInstance(); @@ -254,6 +265,7 @@ Future _init(bool isBackground, {String via = ''}) async { preferences, ); + initComplete = true; _logger.info("Initialization done"); } diff --git a/mobile/lib/utils/email_util.dart b/mobile/lib/utils/email_util.dart index f07d37b1c..7d085cbf6 100644 --- a/mobile/lib/utils/email_util.dart +++ b/mobile/lib/utils/email_util.dart @@ -16,6 +16,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:photos/core/configuration.dart'; import 'package:photos/core/error-reporting/super_logging.dart'; import "package:photos/generated/l10n.dart"; +import "package:photos/ui/common/progress_dialog.dart"; import 'package:photos/ui/components/buttons/button_widget.dart'; import 'package:photos/ui/components/dialog_widget.dart'; import 'package:photos/ui/components/models/button_type.dart'; @@ -122,9 +123,28 @@ Future _sendLogs( } } -Future getZippedLogsFile(BuildContext context) async { - final dialog = createProgressDialog(context, S.of(context).preparingLogs); - await dialog.show(); +Future sendLogsForInit( + String toEmail, + String? subject, + String? body, +) async { + final String zipFilePath = await getZippedLogsFile(null); + final Email email = Email( + recipients: [toEmail], + subject: subject ?? '', + body: body ?? '', + attachmentPaths: [zipFilePath], + isHTML: false, + ); + await FlutterEmailSender.send(email); +} + +Future getZippedLogsFile(BuildContext? context) async { + late final ProgressDialog dialog; + if (context != null) { + dialog = createProgressDialog(context, S.of(context).preparingLogs); + await dialog.show(); + } final logsPath = (await getApplicationSupportDirectory()).path; final logsDirectory = Directory(logsPath + "/logs"); final tempPath = (await getTemporaryDirectory()).path; @@ -134,7 +154,9 @@ Future getZippedLogsFile(BuildContext context) async { encoder.create(zipFilePath); await encoder.addDirectory(logsDirectory); encoder.close(); - await dialog.hide(); + if (context != null) { + await dialog.hide(); + } return zipFilePath; }