toolkit/components/extensions/test/xpcshell/test_ext_experiments.js fails with Android isolated process
Categories
(GeckoView :: General, defect)
Tracking
(Not tracked)
People
(Reporter: jnicol, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Rob's analysis from bug 1709961:
TEST-UNEXPECTED-TIMEOUT | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js | Test timed out
The log viewer doesn't show any useful information, but I downloaded the logcat file and filtered it to exclude logspam from bug 1844829 (2M lines out of 2.4M are logspam, 481 MB -> 97 MB):
07-01 20:11:29.056 17741 17762 I Gecko : {"action":"test_status","time":1751400689056,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] typeof browser.experiments - Expected: object, Actual: object - true == true"}
07-01 20:11:29.061 17741 17762 I Gecko : {"action":"test_status","time":1751400689061,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] typeof browser.experiments.foo - Expected: object, Actual: object - true == true"}
07-01 20:11:29.065 17741 17762 I Gecko : {"action":"test_status","time":1751400689065,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] typeof browser.experiments.foo.child - Expected: function, Actual: function - true == true"}
07-01 20:11:29.067 17741 17762 I Gecko : {"action":"test_status","time":1751400689067,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] typeof browser.experiments.foo.parent - Expected: function, Actual: function - true == true"}
07-01 20:11:29.070 17741 17762 I Gecko : {"action":"test_status","time":1751400689070,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] foo.child() - Expected: child, Actual: child - true == true"}
07-01 20:11:29.086 17797 17814 E WebExtensions: [JavaScript Error: "uncaught exception: Error opening input stream (invalid filename?): jar:file:///data/local/tmp/test_root/xpc/p/075eef98-6c61-489e-a5e9-5f404dba5f20/temp/generated-extension-1.xpi!/child.js" {file: "moz-extension://05cd66f0-93eb-4960-a143-adcef1347a6e/%7Bc879248e-c25b-446c-a4ba-22e659864a1b%7D.js" line: 73}]
07-01 20:11:29.086 17797 17814 E WebExtensions: background@moz-extension://05cd66f0-93eb-4960-a143-adcef1347a6e/%7Bc879248e-c25b-446c-a4ba-22e659864a1b%7D.js:73:3
07-01 20:11:29.086 17797 17814 E WebExtensions: async*@moz-extension://05cd66f0-93eb-4960-a143-adcef1347a6e/%7Bc879248e-c25b-446c-a4ba-22e659864a1b%7D.js:73:5
07-01 20:11:29.097 17741 17762 D GeckoViewConsole: onExtensionReady {ed34fa23-c3fc-44ee-a512-3a6349ac99cf}
07-01 20:11:29.106 17741 17762 I Gecko : {"action":"test_status","time":1751400689106,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] await foo.parent() - Expected: parent, Actual: parent - true == true"}
07-01 20:11:29.107 17741 17762 I Gecko : {"action":"test_status","time":1751400689107,"thread":null,"pid":null,"source":"xpcshell/head.js","test":"xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_experiments.js","subtest":"test_unbundled_experiments","status":"PASS","message":"[test_unbundled_experiments : 144] typeof browser.experiments.crunk - Expected: object, Actual: object - true == true"}
07-01 20:11:29.109 17741 17762 I Gecko : {"action":"log","time":1751400689108,"thread":null,"pid":null,"source":"xpcshell/head.js","level":"INFO","message":"\"CONSOLE_MESSAGE: (error) [JavaScript Error: \"uncaught exception: Error opening input stream (invalid filename?): jar:file:///data/local/tmp/test_root/xpc/p/075eef98-6c61-489e-a5e9-5f404dba5f20/temp/generated-extension-1.xpi!/child.js\" {file: \"moz-extension://05cd66f0-93eb-4960-a143-adcef1347a6e/%7Bc879248e-c25b-446c-a4ba-22e659864a1b%7D.js\" line: 73}]\nbackground@moz-extension://05cd66f0-93eb-4960-a143-adcef1347a6e/%7Bc879248e-c25b-446c-a4ba-22e659864a1b%7D.js:73:3\nasync*@moz-extension://05cd66f0-93eb-4960-a143-adcef1347a6e/%7Bc879248e-c25b-446c-a4ba-22e659864a1b%7D.js:73:5\n\""}
The log show that an error is thrown while executing typeof browser.experiments.crunk.child because the child.js file declared in apiExtension cannot be loaded: uncaught exception: Error opening input stream (invalid filename?): jar:file:///data/local/tmp/test_root/xpc/p/075eef98-6c61-489e-a5e9-5f404dba5f20/temp/generated-extension-1.xpi!/child.js.
Oddly enough, other tests in the file also load (a different) child.js in the extension process, which works just fine.
| Reporter | ||
Comment 1•1 month ago
|
||
Oddly enough, other tests in the file also load (a different) child.js in the extension process, which works just fine.
Claude has this explanation:
What gets loaded, and when
A privileged extension can declare
experiment_apis. Each API has a parent script and a child script inside the extension's xpi. Intest_unbundled_experiments,crunk@experiments.addons.mozilla.orgprovidesexperiments.crunk, and a second extension uses it.
ExtensionData.parseManifestturns each child script into module data, which is sent to the extension process. In the extension process,browser.experiments.crunkis a lazy getter. The first time the background script touches it (heretypeof browser.experiments.crunk), the getter runs synchronously:
getAPI→SchemaAPIManager.loadModule(name)→Services.scriptloader.loadSubScriptWithOptions(module.url, …)inExtensionCommon.sys.mjsThat load is what failed.
The old path:
jar:file:opened directly by the child
moduleDataseturl: this.rootURI.resolve(data.script). For a packed extension,rootURIis the xpi itself, so the URL was:
jar:file:///data/local/tmp/.../temp/generated-extension-1.xpi!/child.jsloadSubScriptopens a channel to that URL and reads it synchronously. The error in logcat, "Error opening input stream (invalid filename?)", is what it reports when that open fails.- A
jar:URL gives annsJARChannel. nsJARChannel::Open(modules/libjar/nsJARChannel.cpp):
LookupFile()takes the innerfile:URL and makes annsIFilefor the xpi's path.CreateJarInput(jarCache, …)asks the process-wide zip cache for a reader:nsZipReaderCache::GetZip(file)innsJAR.cpp.GetZiplooks the archive up by"file:" + file->GetPersistentDescriptor(), i.e. its path.
- Cache hit: it reuses the already-open
nsJAR, and nothing touches the filesystem.- Cache miss: it does
new nsJAR()andzip->Open(zipFile). That opens the file by path, in this process.- On a miss in an isolated process, that open fails. An isolated process runs as its own sandboxed user with no access to the app's files or
/data/local/tmp. A regular Android content process runs as the app's user, so it can open the file. On desktop, the sandbox file broker allows reads under<profile>/extensions(SandboxBrokerPolicyFactory.cpp).So the child script itself was fine. What failed was the child process opening the xpi by path.
Why the bundled
fooexperiment worked anywayIts URL was also a raw
jar:file:URL, intogenerated-extension.xpi. But that extension's background page had already been loaded throughmoz-extension:URLs (path below). Those loads open the xpi from a file descriptor the parent sends, and put the open archive in the same zip cache. That cache is keyed by the xpi's real path; I infer thatFileDescriptorFilereports the original file's path, but couldn't find its source to confirm it. So whenfoo'sjar:file:child script was loaded later, step 4 was a cache hit and the file was never opened.
crunk's xpi is never loaded throughmoz-extension:in the extension process, so its lookup is a cache miss. The cache also drops entries:nsZipReaderCacheevicts the oldest released archive once it's over its size limit, and it registers formemory-pressureandflush-cache-entry. So even the bundled case only worked by luck.
| Reporter | ||
Comment 2•1 month ago
|
||
Rob, do you have any suggestions for how this could be fixed?
Comment 3•1 month ago
|
||
This sounds like the same issue as bug 1976115. I mentioned the same symptom before at https://bugzilla.mozilla.org/show_bug.cgi?id=1976115#c2
Comment 4•1 month ago
|
||
The severity field is not set for this bug.
:owlish, could you have a look please?
For more information, please visit BugBot documentation.
| Reporter | ||
Comment 5•12 days ago
|
||
We can close this as a dup of bug 1976115. The test is now passing
Description
•