Consider adding a persistant preference option in GeckoView as a preference type
Categories
(GeckoView :: General, enhancement)
Tracking
(Not tracked)
People
(Reporter: olivia, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Whiteboard: [geckoview:2024H2?][fxdroid][geckoview])
Background
When investigating bug 1884442, I looked into preferences in GeckoView to try and understand more.
From that investigation, I learned:
- I don't think users were ever intended to be able to manipulate prefs under GeckoRuntimeSettings.java
- For example, an embedder connects setTranslationsOfferPopup to a UI toggle.
- The way the
Pref<Boolean>
currently works is that the default is set at runtime. So, user's Gecko preferences are not persisted, because they will be overwrote. Therefore, the embedder must persist the setting, if they would like it to persist.
- The current architecture on similar preferences has Fenix maintain the persistence as a setting.
For example:- In GeckoView preferences,
geckoview.console.enabled
default is false - The runtime settings builder re-sets it to the persistent value on startup
- Setting persistence is handled by Fenix settings
- In GeckoView preferences,
- Related tangent:
PrefWithoutDefault
may have a bug that causes a runtime setting where a <T> is null when attempting to get. (Encountered when thinking that changing fromPref
toPrefWithoutDefault
might be a solution.)
For bug 1884442, I followed the existing pattern and allowed Fenix to control persistence. However, this flow feels like it could be improved with a GV API. There are likely many situations where the Gecko known value is fine and even expected.
The GV change to consider in this bug is:
The recommended consideration is to add an option in GeckoView preferences to persist the preference based on what Gecko knows the value to be and not overwrite the value with a new default value at startup.
- First ensure and investigate Gecko can correctly persist preferences as expected on mobile.
- It seems it does, because other translations prefs set and get via
TranslationsParent
and those prefs persist as expected. setLanguageSettings -> GeckoView:Translations:SetLanguageSettings -> set in toolkit. - Additionally, I have seen preferences manipulated in
about:config
persist. (However, if a pref is controlled via a GeckoViewPref
then it will rest back to the default on startup.)
- It seems it does, because other translations prefs set and get via
- Create something like
class PersistentGeckoPref<T> extends Pref<T>
- For getting, it should add an event like
GeckoView:GetGeckoPrefs
in GeckoViewStartup.sys.mjs to ask Gecko for the current value - For setting, it should set via an event like
GeckoView:SetGeckoPrefs
in GeckoViewStartup.sys.mjs (or reuse an existing one) - Should allow a default, but that default is only ever set if getting the Gecko pref fails
- First use case could be converting
final Pref<Boolean> mAutomaticallyOfferPopup = new Pref<Boolean>("browser.translations.automaticallyPopup", true);
tofinal PersistentGeckoPref<Boolean> mAutomaticallyOfferPopup = new PersistentGeckoPref<Boolean>("browser.translations.automaticallyPopup", true);
- For getting, it should add an event like
Updated•1 year ago
|
Reporter | ||
Comment 2•11 months ago
|
||
Related tangent: PrefWithoutDefault may have a bug that causes a runtime setting where a <T> is null when attempting to get. (Encountered when thinking that changing from Pref to PrefWithoutDefault might be a solution.)
Filed bug 1908134 to fix the null
state.
Reporter | ||
Comment 3•10 months ago
|
||
Bug 1909024 is an example of a Gecko about:config
preference getting clobbered and losing state in the wild.
Reporter | ||
Updated•10 months ago
|
Reporter | ||
Comment 4•10 months ago
•
|
||
This bug is likely just solving bug 1908134 to fix PrefWithoutDefault
to get the right behavior and switching over to that in a few places.
Leaving this open, because it is really dependent on how bug 1908134 is solved.
Reporter | ||
Updated•4 months ago
|
Updated•4 months ago
|
Reporter | ||
Updated•4 months ago
|
Description
•