source not showing in worker
Categories
(DevTools :: Debugger, defect, P3)
Tracking
(firefox130 fixed)
Tracking | Status | |
---|---|---|
firefox130 | --- | fixed |
People
(Reporter: tarek, Assigned: ochameau)
References
Details
Attachments
(2 files)
When working with a script I am trying to set some break points into an imported mjs
file in a chrome worker, but I get an empty source for some of the files, and a console warning:
console warning 13223> console.warn: "source source-url-chrome://global/content/ml/ONNXPipeline.mjs/originalSource-d5b2a77756f17135cf42a6cb637bb78e
see the screenshot, notice that the root mjs file for the worker works fine. ONNXPipeline.mjs
is imported.
Reporter | ||
Comment 1•2 months ago
•
|
||
To reproduce in mozilla-central, toggle browser.ml.enable
and run this in a toolbox:
async function infere() {
const {PipelineOptions, EngineProcess } = ChromeUtils.importESModule("chrome://global/content/ml/EngineProcess.sys.mjs");
const options = new PipelineOptions({taskName: "moz-image-to-text" });
const engineParent = await EngineProcess.getMLEngineParent();
const engine = engineParent.getEngine(options);
const request = {url: "https://huggingface.co/datasets/mishig/sample_images/resolve/main/football-match.jpg"};
const res = await engine.run(request);
console.log(res);
}
await infere();
This will create a new content process with the worker.
Notice that I've recenty introduced an inference
remote type, so maybe I did a regression https://bugzilla.mozilla.org/show_bug.cgi?id=1905599
Reporter | ||
Comment 2•2 months ago
|
||
I tried to switch back the remoteType
to web
and same issue, so I think that is not related
Assignee | ||
Comment 3•2 months ago
|
||
Summary of the current situation about this ONNXPipeline.mjs
module with missing source:
We first load chrome://global/content/ml/MLEngine.worker.mjs
as a ChromeWorker from here:
https://searchfox.org/mozilla-central/rev/f3e4b33a6122ce63bf81ae8c30cc5ac37458864b/toolkit/components/promiseworker/PromiseWorker.sys.mjs#184
No issues in loading this module source text content.
This MLEngineWorker.worker.mjs
loads ONNXPipeline.mjs
via ChromeUtils.defineESModuleGetters + {current: "global"}
.
So, loaded as an ESM from an ESM loaded as a ChromeWorker.
What happens in devtools is that spidermonkey Debugger API's Source.text attribute is returning [no source]
string over there:
https://searchfox.org/mozilla-central/rev/f3e4b33a6122ce63bf81ae8c30cc5ac37458864b/devtools/server/actors/source.js#260
For some reason, spidermonkey looses, or do not store the source text content.
This isn't the case for most system ESMs. DevTools fetches the text content via this Source.text API.
Now, there is a fallback code, when spidermonkey misses the text content, where DevTools tries to fetch the url for text content.
But it is also broken on this very particular usecase because of this line:
https://searchfox.org/mozilla-central/rev/f3e4b33a6122ce63bf81ae8c30cc5ac37458864b/devtools/server/actors/utils/sources-manager.js#492
This complex workaround doesn't expect a source actor with no source content and actually ignore the correct content fetched by source url
and replace it with the [no source]
.
A workaround until this is fixed is to execute ChromeUtils.importESModule("chrome://global/content/ml/ONNXPipeline.mjs")
from the main thread, before ONNXPipeline.mjs
is loaded from the worker. Even it throws, the debugger will pick this up and be able to show the source.
Comment 4•2 months ago
|
||
:ochameau will check is this impacts regular (non-chrome) workers as well.
Will set priority afterwards.
Comment 6•2 months ago
|
||
(In reply to Julian Descottes [:jdescottes] from comment #5)
Build a test case for regular workers.
Built one where we load a module worker with a ESM import:
https://turquoise-cumbersome-bottom.glitch.me/
Added setInterval in worker files so they're not killed
Assignee | ||
Comment 7•2 months ago
|
||
Looking at nicolas test page, regular DOM workers are not impacted by this issue.
I'll try to provide a fix for the source text content fallback, so that the privileged modules can be debugged.
But we should have a followup to investigate why spidermonkey doesn't expose these worker modules source content.
Assignee | ||
Comment 8•2 months ago
|
||
Spidermonkey fails returning source text content via Source.text
attribute.
It returns "[no source]" and the urlContents fallback was trying to keep using this instead
of the text content fetched via a request.
Updated•2 months ago
|
Comment 10•2 months ago
|
||
bugherder |
Description
•