1
0
Fork 0

No issue: clean up initVisualCompletenessQueue... method.

A no-op clean up.
master
Michael Comella 2020-07-21 13:41:16 -07:00 committed by Michael Comella
parent 633bc4f2f2
commit 6e06c7fda1
1 changed files with 43 additions and 31 deletions

View File

@ -156,46 +156,58 @@ open class FenixApplication : LocaleAwareApplication() {
private fun initVisualCompletenessQueueAndQueueTasks() { private fun initVisualCompletenessQueueAndQueueTasks() {
val taskQueue = components.performance.visualCompletenessQueue val taskQueue = components.performance.visualCompletenessQueue
registerActivityLifecycleCallbacks(PerformanceActivityLifecycleCallbacks(taskQueue))
// Enable the service-experiments component to be initialized after visual completeness fun initQueue() {
// for performance wins. registerActivityLifecycleCallbacks(PerformanceActivityLifecycleCallbacks(taskQueue))
if (settings().isExperimentationEnabled) { }
taskQueue.runIfReadyOrQueue {
Experiments.initialize( fun queueInitExperiments() {
applicationContext = applicationContext, if (settings().isExperimentationEnabled) {
onExperimentsUpdated = { taskQueue.runIfReadyOrQueue {
ExperimentsManager.initSearchWidgetExperiment(this) Experiments.initialize(
}, applicationContext = applicationContext,
configuration = mozilla.components.service.experiments.Configuration( onExperimentsUpdated = {
httpClient = components.core.client, ExperimentsManager.initSearchWidgetExperiment(this)
kintoEndpoint = KINTO_ENDPOINT_PROD },
configuration = mozilla.components.service.experiments.Configuration(
httpClient = components.core.client,
kintoEndpoint = KINTO_ENDPOINT_PROD
)
) )
) ExperimentsManager.initSearchWidgetExperiment(this)
ExperimentsManager.initSearchWidgetExperiment(this) }
} else {
// We should make a better way to opt out for when we have more experiments
// See https://github.com/mozilla-mobile/fenix/issues/6278
ExperimentsManager.optOutSearchWidgetExperiment(this)
} }
} else {
// We should make a better way to opt out for when we have more experiments
// See https://github.com/mozilla-mobile/fenix/issues/6278
ExperimentsManager.optOutSearchWidgetExperiment(this)
} }
components.performance.visualCompletenessQueue.runIfReadyOrQueue { fun queueInitStorageAndServices() {
GlobalScope.launch(Dispatchers.IO) { components.performance.visualCompletenessQueue.runIfReadyOrQueue {
logger.info("Running post-visual completeness tasks...") GlobalScope.launch(Dispatchers.IO) {
logElapsedTime(logger, "Storage initialization") { logger.info("Running post-visual completeness tasks...")
components.core.historyStorage.warmUp() logElapsedTime(logger, "Storage initialization") {
components.core.bookmarksStorage.warmUp() components.core.historyStorage.warmUp()
components.core.passwordsStorage.warmUp() components.core.bookmarksStorage.warmUp()
components.core.passwordsStorage.warmUp()
}
} }
} // Account manager initialization needs to happen on the main thread.
// Account manager initialization needs to happen on the main thread. GlobalScope.launch(Dispatchers.Main) {
GlobalScope.launch(Dispatchers.Main) { logElapsedTime(logger, "Kicking-off account manager") {
logElapsedTime(logger, "Kicking-off account manager") { components.backgroundServices.accountManager
components.backgroundServices.accountManager }
} }
} }
} }
initQueue()
// We init these items in the visual completeness queue to avoid them initing in the critical
// startup path, before the UI finishes drawing (i.e. visual completeness).
queueInitExperiments()
queueInitStorageAndServices()
} }
private fun startMetricsIfEnabled() { private fun startMetricsIfEnabled() {