Closes #21944: Top sites rendered slowly on first load of HomeFragment
This commit is contained in:
parent
8d5c6f6082
commit
c3ef16de61
|
@ -64,6 +64,7 @@ import org.mozilla.fenix.telemetry.TelemetryLifecycleObserver
|
|||
import org.mozilla.fenix.utils.BrowsersCache
|
||||
import java.util.concurrent.TimeUnit
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.storage.FrecencyThresholdOption
|
||||
import mozilla.components.feature.autofill.AutofillUseCases
|
||||
import mozilla.components.feature.search.ext.buildSearchUrl
|
||||
import mozilla.components.feature.search.ext.waitForSelectedOrDefaultSearchEngine
|
||||
|
@ -248,6 +249,19 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
|
|||
components.core.passwordsStorage.warmUp()
|
||||
components.core.autofillStorage.warmUp()
|
||||
|
||||
// Populate the top site cache to improve initial load experience
|
||||
// of the home fragment when the app is launched to a tab. The actual
|
||||
// database call is not expensive. However, the additional context
|
||||
// switches delay rendering top sites when the cache is empty, which
|
||||
// we can prevent with this.
|
||||
components.core.topSitesStorage.getTopSites(
|
||||
components.settings.topSitesMaxLimit,
|
||||
if (components.settings.showTopFrecentSites)
|
||||
FrecencyThresholdOption.SKIP_ONE_TIME_PAGES
|
||||
else
|
||||
null
|
||||
)
|
||||
|
||||
// This service uses `historyStorage`, and so we can only touch it when we know
|
||||
// it's safe to touch `historyStorage. By 'safe', we mainly mean that underlying
|
||||
// places library will be able to load, which requires first running Megazord.init().
|
||||
|
|
Loading…
Reference in New Issue
Block a user