Commit 50fb753a authored by MozLando's avatar MozLando
Browse files

Merge #6964

6964: Initialize accountManager on the main thread during migration r=pocmo a=grigoryk

Fenix bug for this - https://github.com/mozilla-mobile/fenix/issues/10432



This fixes fallout from #6395 in which
FennecMigrator changed to accept a Lazy-wrapped reference to the account manager.

This was done so that during regular (non-migrating) startup, a simple act of building a no-op
migrator will not cause account manager initialization.

However, during a migrating startup this creates a race to initialize account manager.
Two participants in this race are:
1) FenixApplication running expensive operations (such as storage init, account manager init)
after visual completeness. However, currently that just entails a 5 second delay from `onStart`.
2) FxA migration, which runs roughly at the mid-point of the migration.

Account manager currently can't be initialized on a background thread (or it will crash).
FxA migration runs on a background thread, so if (2) wins (that is, migrations before FxA migration take
less than 5 seconds), then migration will crash.

This patch adds an eager initialization right before we kick-off migrations but are still on the main thread,
iff an FxA migration will be executed.
Co-authored-by: default avatarGrisha Kruglov <gkruglov@mozilla.com>
parents 11940fba 09b55546
......@@ -20,7 +20,7 @@ The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration |
| --- | --- | --- | --- | --- | --- |
| crash_metrics.crash_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counts the number of crashes that occur in the application. This measures only the counts of each crash in association with the labeled type of the crash. The labels correspond to the types of crashes handled by lib-crash. Deprecated: `native_code_crash` replaced by `fatal_native_code_crash` and `nonfatal_native_code_crash` |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1553935#c3), [2](https://github.com/mozilla-mobile/android-components/pull/5700#pullrequestreview-347721248)|<ul><li>uncaught_exception</li><li>caught_exception</li><li>fatal_native_code_crash</li><li>nonfatal_native_code_crash</li></ul>|never |
| crash_metrics.crash_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Counts the number of crashes that occur in the application. This measures only the counts of each crash in association with the labeled type of the crash. The labels correspond to the types of crashes handled by lib-crash. Deprecated: `native_code_crash` replaced by `fatal_native_code_crash` and `nonfatal_native_code_crash` |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1553935#c3), [2](https://github.com/mozilla-mobile/android-components/pull/5700#pullrequestreview-347721248)|<ul><li>uncaught_exception</li><li>caught_exception</li><li>fatal_native_code_crash</li><li>nonfatal_native_code_crash</li></ul>|never |
<!-- AUTOGENERATED BY glean_parser. DO NOT EDIT. -->
......
......@@ -504,6 +504,13 @@ class FennecMigrator private constructor(
return result
}
// If we need to run an FxA migration later, first make sure 'accountManager' is initialized
// while we're still on the main thread. This is necessary because accountManager can't be
// initialized on a background thread.
if (migrationsToRun.any { it.migration is Migration.FxA }) {
accountManager?.value
}
return runMigrationsAsync(store, migrationsToRun)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment