mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] Closes 20975: Run metadata cleanup after Megazord.init()
This ensures that we do not attempt places initialization before Megazord.init() finishes, and that touching BrowserStore does not kick-off places initialization (due to the `cleanup` call being a side-effect of creating metadata middleware, used as part of the BrowserStore). Glean initialization happens before initialize megazord, and it touches core.store BrowserStore instance, kicking-off places initialization on an IO thread (due to the cleanup call), which raced megazord initialization on the main thread. App init sequence is a bit of a mine-field, so this patch takes the easy way out and doesn't attempt to re-order initialization sequence. Also, initializing places as a side-effect of touching BrowserStore was also, clearly, a bug.
This commit is contained in:
parent
8fd87ab361
commit
dd1b4ba5ae
@ -72,6 +72,7 @@ import org.mozilla.fenix.GleanMetrics.Addons
|
||||
import org.mozilla.fenix.GleanMetrics.AndroidAutofill
|
||||
import org.mozilla.fenix.GleanMetrics.Preferences
|
||||
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
|
||||
import org.mozilla.fenix.components.Core
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.components.metrics.MozillaProductDetector
|
||||
import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
||||
@ -241,6 +242,14 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
|
||||
components.core.bookmarksStorage.warmUp()
|
||||
components.core.passwordsStorage.warmUp()
|
||||
components.core.autofillStorage.warmUp()
|
||||
|
||||
// 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().
|
||||
// The visual completeness tasks are scheduled after the Megazord.init() call.
|
||||
components.core.historyMetadataService.cleanup(
|
||||
System.currentTimeMillis() - Core.HISTORY_METADATA_MAX_AGE_IN_MS
|
||||
)
|
||||
}
|
||||
|
||||
SecurePrefsTelemetry(this@FenixApplication, components.analytics.experiments).startTests()
|
||||
|
@ -254,9 +254,7 @@ class Core(
|
||||
* The [HistoryMetadataService] is used to record history metadata.
|
||||
*/
|
||||
val historyMetadataService: HistoryMetadataService by lazyMonitored {
|
||||
DefaultHistoryMetadataService(storage = historyStorage).apply {
|
||||
cleanup(System.currentTimeMillis() - HISTORY_METADATA_MAX_AGE_IN_MS)
|
||||
}
|
||||
DefaultHistoryMetadataService(storage = historyStorage)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -454,6 +452,6 @@ class Core(
|
||||
private const val KEY_STORAGE_NAME = "core_prefs"
|
||||
private const val PASSWORDS_KEY = "passwords"
|
||||
private const val RECENTLY_CLOSED_MAX = 10
|
||||
private const val HISTORY_METADATA_MAX_AGE_IN_MS = 14 * 24 * 60 * 60 * 1000 // 14 days
|
||||
const val HISTORY_METADATA_MAX_AGE_IN_MS = 14 * 24 * 60 * 60 * 1000 // 14 days
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user