2
0
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:
Grisha Kruglov 2021-08-23 14:35:35 -07:00 committed by mergify[bot]
parent 8fd87ab361
commit dd1b4ba5ae
2 changed files with 11 additions and 4 deletions

View File

@ -72,6 +72,7 @@ import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AndroidAutofill import org.mozilla.fenix.GleanMetrics.AndroidAutofill
import org.mozilla.fenix.GleanMetrics.Preferences import org.mozilla.fenix.GleanMetrics.Preferences
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine 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.Event
import org.mozilla.fenix.components.metrics.MozillaProductDetector import org.mozilla.fenix.components.metrics.MozillaProductDetector
import org.mozilla.fenix.components.toolbar.ToolbarPosition import org.mozilla.fenix.components.toolbar.ToolbarPosition
@ -241,6 +242,14 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
components.core.bookmarksStorage.warmUp() components.core.bookmarksStorage.warmUp()
components.core.passwordsStorage.warmUp() components.core.passwordsStorage.warmUp()
components.core.autofillStorage.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() SecurePrefsTelemetry(this@FenixApplication, components.analytics.experiments).startTests()

View File

@ -254,9 +254,7 @@ class Core(
* The [HistoryMetadataService] is used to record history metadata. * The [HistoryMetadataService] is used to record history metadata.
*/ */
val historyMetadataService: HistoryMetadataService by lazyMonitored { val historyMetadataService: HistoryMetadataService by lazyMonitored {
DefaultHistoryMetadataService(storage = historyStorage).apply { DefaultHistoryMetadataService(storage = historyStorage)
cleanup(System.currentTimeMillis() - HISTORY_METADATA_MAX_AGE_IN_MS)
}
} }
/** /**
@ -454,6 +452,6 @@ class Core(
private const val KEY_STORAGE_NAME = "core_prefs" private const val KEY_STORAGE_NAME = "core_prefs"
private const val PASSWORDS_KEY = "passwords" private const val PASSWORDS_KEY = "passwords"
private const val RECENTLY_CLOSED_MAX = 10 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
} }
} }