From e541e1042737487f21133f6a4e89932d2760bf5f Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Thu, 19 Mar 2020 12:24:23 -0700 Subject: [PATCH] Initialize storage after visual completeness In order to eat the perceived performance costs, we initialize storage once we're visually complete. This way, we're reducing chances of user performing a UI action which will trigger storage init and delay said action. --- app/src/main/java/org/mozilla/fenix/FenixApplication.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index 1cfe0611f..eb1ec59fc 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -151,6 +151,15 @@ open class FenixApplication : LocaleAwareApplication() { registerActivityLifecycleCallbacks( PerformanceActivityLifecycleCallbacks(components.performance.visualCompletenessTaskManager) ) + + components.performance.visualCompletenessTaskManager.add { + GlobalScope.launch(Dispatchers.IO) { + logger.info("Initializing storage after visual completeness...") + components.core.lazyHistoryStorage.value + components.core.lazyBookmarksStorage.value + components.core.lazyPasswordsStorage.value + } + } } // See https://github.com/mozilla-mobile/fenix/issues/7227 for context.