We set the ContentBlockingSettings directly on the GeckoRuntime now to
improve the startup of the engine.
This change has requirements from Android Components and GeckoView, so
we would only see the full perf benefits in Nightly as the changes ride
the train, although we might start to see some of them as we're updating
the GeckoProvider for the `geckoBeta` variant as well.
Co-authored-by: Arturo Mejia <arturomejiamarmol@gmail.com>
We were supposed to have removed Experiments for performance purposes.
However, I find some code dangling in the tree.
Experiments.initialize is no longer called so I suspect
Experiments.withExperiment is a no-op. I verified that the lambda
function provided to it never ran in my local geckoBetaDebug on startup.
Assuming experiments behavior doesn't change in other build types, this
change appears safe.
Make sure that we actually lazily initialize our storage layers.
With this patch applied, storage layers (history, logins, bookmarks) will be initialized when first
accessed. We will no longer block GeckoEngine init, for example, on waiting for the logins storage
to initialize (which needs to access the costly securePrefStorage).
Similarly, BackgroundServices init will no longer require initialized instances of the storage
components - references to their "lazy wrappers" will suffice.
In practice, this change changes when our storage layers are initialized in the following ways.
Currently, we will initialize everything on startup. This includes loading our megazord, as well.
With this change, init path depends on if the user is signed-into FxA or not.
If user is not an FxA user:
- on startup, none of the storage layers are initialized
- history storage will be initialized once, whenever:
- first non-customTab page is loaded (access to the HistoryDelegate)
- first interaction with the awesomebar
- history UI is accessed
- bookmarks storage will be initialized once, whenever:
- something is bookmarked, or we need to figure out if something's bookmarked
- bookmarks UI is accessed
- logins storage will be initialized once, whenever:
- first page is loaded with a login/password fields that can be autofilled
- (or some other interaction by GV with the autofill/loginStorage delegates)
- logins UI is accessed
- all of these storages will be initialized if the user logs into FxA and starts syncing data
- except, if a storage is not chosen to be synced, it will not be initialized
If user is an FxA user:
- on startup, none of the storage layers are initialized
- sometime shortly after startup is complete, when a sync worker runs in the background, all storage
layers that are enabled to sync will be initialized.
This change also means that we delay loading the megazord until first access (as described above).
The a-c side of this work is in https://github.com/mozilla-mobile/android-components/pull/6128
This switches Fenix to use `SyncableLoginsStorage`, which caches a connection internally
on first access, and doesn't expose any lock/unlock APIs at the public boundary.
Since we are now able to build against GeckoView Nightly and GeckoView Beta,
we should create the GeckoRuntime from a flavor-specific source set.
Creating the runtime is not covered by the AC abstraction and so API changes
in GeckoView Nightly can break the build and leaves us with no option to fix
it from a shared code base. Separating the creation of GeckoRuntime
allows us to adapt individually and also to configure the runtimes
differently.