Default addons e.g. webcompat/screenshots/pictureinpicture break when application path changes, e.g. by updating Nightly MSIX package
Categories
(Toolkit :: Add-ons Manager, defect, P2)
Tracking
()
People
(Reporter: saschanaz, Assigned: saschanaz)
References
Details
(Whiteboard: [addons-jira])
Attachments
(2 obsolete files)
The log when booting Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1747267#c12
Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/formautofill@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE) Extension.jsm:818
1681998163013 addons.xpi WARN Exception running bootstrap method startup on formautofill@mozilla.org: Error: Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/formautofill@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE)(resource://gre/modules/Extension.jsm:818:20) JS Stack trace: readJSON/</<@Extension.jsm:818:20
onStopRequest@NetUtil.jsm:126:18
Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/pictureinpicture@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE) Extension.jsm:818
1681998163014 addons.xpi WARN Exception running bootstrap method startup on pictureinpicture@mozilla.org: Error: Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/pictureinpicture@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE)(resource://gre/modules/Extension.jsm:818:20) JS Stack trace: readJSON/</<@Extension.jsm:818:20
onStopRequest@NetUtil.jsm:126:18
Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/screenshots@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE) Extension.jsm:818
1681998163014 addons.xpi WARN Exception running bootstrap method startup on screenshots@mozilla.org: Error: Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/screenshots@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE)(resource://gre/modules/Extension.jsm:818:20) JS Stack trace: readJSON/</<@Extension.jsm:818:20
onStopRequest@NetUtil.jsm:126:18
Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/webcompat-reporter@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE) Extension.jsm:818
1681998163014 addons.xpi WARN Exception running bootstrap method startup on webcompat-reporter@mozilla.org: Error: Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/webcompat-reporter@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE)(resource://gre/modules/Extension.jsm:818:20) JS Stack trace: readJSON/</<@Extension.jsm:818:20
onStopRequest@NetUtil.jsm:126:18
Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/webcompat@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE) Extension.jsm:818
1681998163015 addons.xpi WARN Exception running bootstrap method startup on webcompat@mozilla.org: Error: Error while loading 'jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/webcompat@mozilla.org.xpi!/manifest.json' (NS_ERROR_FAILURE)(resource://gre/modules/Extension.jsm:818:20) JS Stack trace: readJSON/</<@Extension.jsm:818:20
onStopRequest@NetUtil.jsm:126:18
And the path is wrong: https://bugzilla.mozilla.org/show_bug.cgi?id=1747267#c14
Okay, so there's no path like C:/Program Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/ as the real path includes Mozilla.MozillaFirefoxNightly_114.2304.1921.0_x64__gmpnhwe7bv608. For some reason it refers to a path of some old build.
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 1•2 years ago
|
||
Changing to see-also since bug 1429838 is more about profile path and this one is AFAICT about the binary path.
Comment 2•2 years ago
|
||
Relevant comment from https://bugzilla.mozilla.org/show_bug.cgi?id=1747267#c18:
(In reply to Nick Alexander :nalexander [he/him] from comment #15)
(In reply to Kagami [:saschanaz] from comment #14)
Okay, so there's no path like
C:/Program Files/WindowsApps/Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608/
as the real path includesMozilla.MozillaFirefoxNightly_114.2304.1921.0_x64__gmpnhwe7bv608
. For some reason it refers to a path of some old build. Does this ring a bell?It rings no bells. My guess is that the per-profile addons DB is baking the installation path into its storage in some manner, and that is breaking as the installation path moves around. That was a reasonable approach that only changed perhaps a year or two ago and was certainly not appreciated until much more recently. (E.g., https://bugzilla.mozilla.org/show_bug.cgi?id=1818606.)
Rob: do you know if the above is true (or possible)? Could you redirect if there's a person more likely to know?
This is certainly a possibility. When profile directories are moved around, something similar happens (bug 1429838), because the absolute path to the add-on location (xpi file) is stored in addonStartup.json.lz4
and extensions.json
.
Assignee | ||
Comment 3•2 years ago
|
||
BTW, the path being pinned to Mozilla.MozillaFirefoxNightly_114.2304.1303.0_x64__gmpnhwe7bv608
, perhaps that means the path only updates when the version number changes? 2023-04-10 was the merge date and the path indicates the build date 2023-04-13.
(The same path is still being used even when I'm now on 2023-04-27 build.)
Assignee | ||
Comment 4•2 years ago
|
||
This workaround also works here: https://bugzilla.mozilla.org/show_bug.cgi?id=1429838#c30
A quick manual fix:
- navigate to
about:profiles
- Open the folder listed as
Root Directory
under the currently used profile ("This is the profile in use...")- Remove the file
addonStartup.json.lz4
- Restart firefox twice.
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 5•2 years ago
•
|
||
I can confirm that the path updates when the major version bumps.
Assignee | ||
Comment 6•1 years ago
|
||
(In reply to Kagami [:saschanaz] from comment #5)
I can confirm that the path updates when the major version bumps.
And setting extensions.lastAppVersion
can trigger this. I guess we can have extensions.lastBinPath
for this bug's purpose.
Assignee | ||
Comment 7•1 years ago
|
||
This triggers regenerating addonStartup.json.lz4 when binary path changes, as the path includes build date in Windows MSIX installation.
Services.dirsvc.get("XREExeF", Ci.nsIFile).path
> "C:\\Program Files\\WindowsApps\\Mozilla.MozillaFirefoxNightly_116.2306.909.0_x64__gmpnhwe7bv608\\VFS\\ProgramFiles\\MozillaFirefoxNightly Package Root\\firefox.exe"
Updated•1 years ago
|
Comment 8•1 years ago
|
||
(In reply to Kagami [:saschanaz] from comment #6)
(In reply to Kagami [:saschanaz] from comment #5)
I can confirm that the path updates when the major version bumps.
And setting
extensions.lastAppVersion
can trigger this. I guess we can haveextensions.lastBinPath
for this bug's purpose.
Your current approach is to fake a major version bump without a change to the major version. That approach looks too blunt to me, especially when there is already an existing mechanism designed for detecting and repairing database inconsistencies, see XPIProvider.checkForChanges
and its implementation - https://searchfox.org/mozilla-central/rev/1d43d9f3d0ffcbdb619cfd1e2911fb22d1456657/toolkit/mozapps/extensions/internal/XPIProvider.jsm#3047,3057-3059
I was thinking of a fix in the direction of: when the path of the xpi is dependent on a "constant" location (e.g. the app binary path), and that "constant" location changes, then the path should be recomputed. That general fix would cover this bug and bug 1429838.
Assignee | ||
Comment 9•1 years ago
•
|
||
(In reply to Rob Wu [:robwu] from comment #8)
Your current approach is to fake a major version bump without a change to the major version. That approach looks too blunt to me, especially when there is already an existing mechanism designed for detecting and repairing database inconsistencies, see
XPIProvider.checkForChanges
and its implementation - https://searchfox.org/mozilla-central/rev/1d43d9f3d0ffcbdb619cfd1e2911fb22d1456657/toolkit/mozapps/extensions/internal/XPIProvider.jsm#3047,3057-3059
IMO it's okay to be "blunt" here as it's not something happening for every startup, isn't it? At most it should only happen daily after update, and rechecking after update is not something entirely unexpected.
I was thinking of a fix in the direction of: when the path of the xpi is dependent on a "constant" location (e.g. the app binary path), and that "constant" location changes, then the path should be recomputed. That general fix would cover this bug and bug 1429838.
I see two issues:
- Currently
XPIProvider.scanForChanges
ignores everything by default when aAppChanged is false. - Even if it's true, somehow the
addonChanged
check is faulty; bothfile.path
andxpiState.path
uses the right path that is not actually used to load the extension, so it fails to detect the change. For example,- both point to
C:\Program Files\WindowsApps\Mozilla.MozillaFirefoxNightly_116.2306.1609.0_x64__gmpnhwe7bv608\VFS\ProgramFiles\MozillaFirefoxNightly Package Root\browser\features\webcompat-reporter@mozilla.org.xpi
which exists, - ... while the load error message points to
jar:file:///C:/Program%20Files/WindowsApps/Mozilla.MozillaFirefoxNightly_116.2306.1421.0_x64__gmpnhwe7bv608/VFS/ProgramFiles/MozillaFirefoxNightly%20Package%20Root/browser/features/webcompat-reporter@mozilla.org.xpi!/manifest.json
which does not exist.
- both point to
Thoughts?
Comment 10•1 years ago
|
||
(In reply to Kagami [:saschanaz] from comment #9)
I see two issues:
- Currently
XPIProvider.scanForChanges
ignores everything by default when aAppChanged is false.
Not everything is ignored. Whenever the application has a meaningful update, its buildId changes. That triggers the code path where the ignoreSideloads
flag is effectively ignored. Here is a step-by-step evaluation:
if (ignoreSideloads && !(loc.scope & startupScanScopes)) {
with loc.scope = 4 (aka SCOPE_APPLICATION) and startupScanScopes = 31 (aka SCOPE_ALL)if (ignoreSideloads && !(l4 & 31) {
if (ignoreSideloads && !(4)) {
if (ignoreSideloads && false) {
if (false) {
To simulate the behavior without app changes, set the "extensions.startupScanScopes" preference to 31 to unconditionally simulate the same behavior. I highly recommend creating a xpcshell unit test that sets this flag, in order to test this behavior.
- Even if it's true, somehow the
addonChanged
check is faulty; bothfile.path
andxpiState.path
uses the right path that is not actually used to load the extension, so it fails to detect the change.
If it worked, then we wouldn't have this bug report ;)
Here are some pointers:
- The
location
inscanForChanges
areXPIStateLocation
instances. Relevant to this bug is DirectoryLocation, instantiated here (note: SystemAddonDefaults and SystemAddonLocation are subclasses of DirectoryLocation): https://searchfox.org/mozilla-central/rev/986024d59bff59819a3ed2f7c1d0f5254cdc3f3d/toolkit/mozapps/extensions/internal/XPIProvider.jsm#2294-2419 xpiState
is populated early inscanForChanges
by a call toloc.restore(oldState[loc.name]);
.- Note:
oldState
is the data from fromaddonStartup.json.lz4
, and may hold the previously incorrect data.
- Note:
restore
's implementation is at https://searchfox.org/mozilla-central/rev/986024d59bff59819a3ed2f7c1d0f5254cdc3f3d/toolkit/mozapps/extensions/internal/XPIProvider.jsm#727-745- That method calls
_addState
, which constructsXPIState
.
- That method calls
I would explore the following:
- From where is the add-on loaded? You could use the Browser Toolbox to put a breakpoint in the XPIProvider.sys.mjs module and install a xpi file from addons.mozilla.org to try and get a better understanding of how an add-on is started.
- Can DirectoryLocation detect inconsistencies in its path and the add-ons that are allegedly part of it, and repair the path as needed?
- (I believe that the answer is yes, in
restore
or the methods/classes that is calls)
- (I believe that the answer is yes, in
- Can we repair without doing repeated expensive file I/O checks?
- (again, I believe that the answer is yes)
- Create xpcshell unit test to reproduce the issue.
- Here is an example of an existing unit test that modifies addonStartup.json.lz4: https://searchfox.org/mozilla-central/rev/986024d59bff59819a3ed2f7c1d0f5254cdc3f3d/toolkit/mozapps/extensions/test/xpcshell/test_aom_startup.js#43-52
I hope this helps!
Assignee | ||
Comment 11•1 years ago
|
||
Amazing, deeply thank you for the detailed information! I think I got alternative solution. One question:
(In reply to Rob Wu [:robwu] from comment #10)
(In reply to Kagami [:saschanaz] from comment #9)
I see two issues:
- Currently
XPIProvider.scanForChanges
ignores everything by default when aAppChanged is false.Not everything is ignored. Whenever the application has a meaningful update, its buildId changes. That triggers the code path where the
ignoreSideloads
flag is effectively ignored. Here is a step-by-step evaluation:
I totally missed the build id check, and your explanation makes total sense! But from my understanding it still can't solve bug 1429838 as moving profile does not change build id, right? It's out of scope here, I just want to double check since you mentioned it in comment #8.
Comment 12•1 years ago
|
||
(In reply to Kagami [:saschanaz] from comment #11)
(In reply to Rob Wu [:robwu] from comment #10)
Not everything is ignored. Whenever the application has a meaningful update, its buildId changes. That triggers the code path where the
ignoreSideloads
flag is effectively ignored. Here is a step-by-step evaluation:I totally missed the build id check, and your explanation makes total sense! But from my understanding it still can't solve bug 1429838 as moving profile does not change build id, right? It's out of scope here, I just want to double check since you mentioned it in comment #8.
If the fix were to depend on iterating over all directory entries on disk, then a fix here would not fix bug 1429838 at once.
But if the fix consists of rewriting saved.path
before/while constructing XPIState, then that would also fix the other bug. As the mechanism to generate the paths is consistent, it should be possible to check whether rootURI
still matches location.dir
, and if not, to extract the leaf name and rebuild rootURI
with location.dir
.
Assignee | ||
Comment 13•1 years ago
|
||
Assignee | ||
Comment 14•1 years ago
|
||
Note for myself:
For some reason SystemDefaultsLoc()
fails and thus app-system-defaults
is being skipped in xpcshell tests, but fixing that is out of scope here when this bug is theoretically not limited to default addons. Try testing on app-profile
instead.
Updated•1 years ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Assignee | ||
Comment 15•1 year ago
|
||
Somehow this is fixed 👍
Assignee | ||
Comment 16•10 months ago
|
||
Restarted some time ago...
Description
•