From 6c38b773151e1c17a8016d851407bb3cd7de4ef9 Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Thu, 26 Mar 2020 23:28:16 -0700 Subject: [PATCH] Part 6: Kick-off account manager initialization after visual completeness In order to hide the time it takes for the account manager to be initialized (which always involves disk IO, and often network IO), let's kick it off after "visual completeness". This makes sure that for most users, by the time they interact with the account manager-related functionality (e.g. in Settings), it's ready to go. Also, for signed-in users, this will establish background sync workers. --- app/src/main/java/org/mozilla/fenix/FenixApplication.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index 41a13bc08..10d19fee8 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -162,6 +162,12 @@ open class FenixApplication : LocaleAwareApplication() { components.core.passwordsStorage.warmUp() } } + // Account manager initialization needs to happen on the main thread. + GlobalScope.launch(Dispatchers.Main) { + logElapsedTime(logger, "Kicking-off account manager") { + components.backgroundServices.accountManager + } + } } }