Skip to content
  • Grisha Kruglov's avatar
    Initialize accountManager on the main thread during migration · 09b55546
    Grisha Kruglov authored
    This fixes fallback from https://github.com/mozilla-mobile/android-components/pull/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.
    09b55546