Fenix shouldn't use `nsToolkitProfileService` to identify a profile folder
Categories
(Toolkit :: Startup and Profile System, defect)
Tracking
()
Performance Impact | ? |
People
(Reporter: mossop, Unassigned, NeedInfo)
Details
Currently when Fenix starts up Gecko we do the following steps:
- Set the
HOME
environment variable to point to the app's file storage location. - Call into
XRE_main
. - Eventually call
SelectProfile
in order to find the Gecko profile directory which:
3.1 Creates thensToolkitProfileService
3.2 Which finds or creates aprofiles.ini
file in the file storage area.
3.3 Loads and parsesprofiles.ini
to determine the default profile for the current install.
3.4 Finds or creates the default profile folder to pass back tonsAppRunner
. - We then attempt to lock the profile folder in case another process is using it.
- Then we do various file accesses to verify Gecko compatibility with the profile folder and whether we need to flush the startup caches.
- Before we finally run Gecko.
Steps 3 to 5 here seem unnecessary on Android. There is currently only one profile folder (and even if that changes in the future we're likely to manage profile folders from the Fenix side) so there is no need to use profiles.ini
. I believe that only one main Gecko process can be running at a time so there is no need to lock the profile. We can purge the startup cache based solely on application build ID rather than additional checks. And for compatibility I wonder if we assume that downgrades don't happen or if they do we can detect in Fenix and handle from that side directly.
All this adds up to a bunch of unnecessary I/O on Gecko startup which for phone devices is probably well worth getting rid of. The one niggle here is that all current Fenix users will have a randomly named profile folder. Historically this was done on Desktop as a mitigation against security vulnerabilities that might allow access to profile data if the path was known. I suspect that we still want to keep this so we can't just use a fixed profile path (and besides then we'd have to manage moving existing users profile folders which sounds fraught). But I think we can still mostly simplify this if we can cache some things on the Fenix side.
- Create a new build flag,
MOZ_SINGLE_PROFILE
which is set on Android and unset on desktop. - Before calling into Gecko if we know that this is a new install create a randomly named profile folder and store its path in the
XRE_PROFILE_PATH
environment variable. If this isn't a new install and we have cached the profile folder name that store that in the environment. - If Fenix detects it is a downgrade it can handle assigning a new profile folder and deleting the old. Likewise if purging caches is needed it can pass the
-purgecaches
command line argument. - Launch Gecko. When Gecko attempts to figure out the profile, if
MOZ_SINGLE_PROFILE
is set andXRE_PROFILE_PATH
is set it will just use that, otherwise it will continue to use the profile manager to find the profile fromprofiles.ini
. - Gecko skips profile locking and file I/O associated with compatibility checking when
MOZ_SINGLE_PROFILE
is set. - After Gecko starts Fenix retrieves the path of the profile and caches it for the next launch.
Strictly speaking we could simplify step 3 by assuming that there is only one profile folder anyway and we could just scan the directory to find it (either on Fenix or Gecko sides). I worry slightly about the admittedly small chance where a corrupt profiles.ini
might cause some users to end up with two profile folders so I think it is safer to just use the existing logic when we don't already know the profile folder in use.
Jeff, I've made some assumptions here about what is possible on the Fenix side prior to launching Gecko, does this seem feasible?
Reporter | ||
Updated•1 month ago
|
Comment 1•1 month ago
|
||
On the surface I would agree with your assumptions. But I'm going to rope in :owlish to chime in here as the GV lead they will definitely be able to answer with more confidence than I can 😅.
Description
•