chore: Add some stats for app start

This commit is contained in:
Krille Fear 2021-11-16 12:00:22 +01:00
parent 3126ce27f9
commit abfe6a138b
6 changed files with 25 additions and 28 deletions

View File

@ -11,6 +11,7 @@ linter:
analyzer:
errors:
implementation_imports: ignore
todo: ignore
exclude:
- lib/generated_plugin_registrant.dart

View File

@ -37,7 +37,7 @@ void main() async {
Zone.current.handleUncaughtError(details.exception, details.stack);
final clients = await ClientManager.getClients();
Logs().level = kReleaseMode ? Level.info : Level.verbose;
Logs().level = kReleaseMode ? Level.debug : Level.verbose;
if (PlatformInfos.isMobile) {
BackgroundPush.clientOnly(clients.first);

View File

@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:matrix/encryption/utils/key_verification.dart';
import 'package:matrix/matrix.dart';
import 'package:matrix/src/utils/run_benchmarked.dart';
import 'package:path_provider/path_provider.dart';
import 'package:fluffychat/utils/platform_infos.dart';
@ -22,7 +23,10 @@ abstract class ClientManager {
}
final clientNames = <String>{};
try {
final rawClientNames = await Store().getItem(clientNamespace);
final rawClientNames = await runBenchmarked(
'Get client names',
() => Store().getItem(clientNamespace),
);
if (rawClientNames != null) {
final clientNamesList =
(jsonDecode(rawClientNames) as List).cast<String>();
@ -37,11 +41,12 @@ abstract class ClientManager {
await Store().setItem(clientNamespace, jsonEncode(clientNames.toList()));
}
final clients = clientNames.map(createClient).toList();
await Future.wait(clients.map((client) => client
.init(
waitForFirstSync: false,
waitUntilLoadCompletedLoaded: false,
)
await Future.wait(clients.map((client) => runBenchmarked(
'Init client ${client.clientName}',
() => client.init(
waitForFirstSync: false,
waitUntilLoadCompletedLoaded: false,
))
.catchError((e, s) => Logs().e('Unable to initialize client', e, s))));
if (clients.length > 1 && clients.any((c) => !c.isLogged())) {
final loggedOutClients = clients.where((c) => !c.isLogged()).toList();
@ -51,7 +56,11 @@ abstract class ClientManager {
clientNames.remove(client.clientName);
clients.remove(client);
}
await Store().setItem(clientNamespace, jsonEncode(clientNames.toList()));
await runBenchmarked(
'Update clientNamespaces',
() =>
Store().setItem(clientNamespace, jsonEncode(clientNames.toList())),
);
}
return clients;
}

View File

@ -65,14 +65,8 @@ class FlutterMatrixSembastDatabase extends MatrixSembastDatabase {
path: await _findDatabasePath(client),
dbFactory: kIsWeb ? databaseFactoryWeb : databaseFactoryIo,
);
try {
await db.open();
Logs().d('Sembast is ready');
} catch (e, s) {
Logs().e('Unable to open Sembast. Delete and try again...', e, s);
await db.clear();
await db.open();
}
await db.open();
Logs().d('Sembast is ready');
return db;
}
@ -91,7 +85,6 @@ class FlutterMatrixSembastDatabase extends MatrixSembastDatabase {
}
path = '${directory.path}${client.clientName}.db';
}
Logs().i('Use database path: "$path"');
return path;
}

View File

@ -773,12 +773,10 @@ packages:
matrix:
dependency: "direct main"
description:
path: "."
ref: "krille/sembast"
resolved-ref: "28af05289a6d48cbe6067031bdf08ab72fb21225"
url: "https://gitlab.com/famedly/company/frontend/famedlysdk.git"
source: git
version: "0.7.0-nullsafety.5"
name: matrix
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.0-nullsafety.6"
matrix_api_lite:
dependency: transitive
description:

View File

@ -46,7 +46,7 @@ dependencies:
intl: any
localstorage: ^4.0.0+1
lottie: ^1.2.1
matrix: ^0.7.0-nullsafety.5
matrix: ^0.7.0-nullsafety.6
matrix_link_text: ^1.0.2
native_imaging:
git: https://gitlab.com/famedly/libraries/native_imaging.git
@ -115,8 +115,4 @@ dependency_overrides:
hosted:
name: geolocator_android
url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
matrix:
git:
url: https://gitlab.com/famedly/company/frontend/famedlysdk.git
ref: krille/sembast
provider: 5.0.0