Debugging and logging of extensions is broken
Categories
(DevTools :: Debugger, defect, P2)
Tracking
(firefox-esr128 unaffected, firefox134 unaffected, firefox135 verified, firefox136 verified)
Tracking | Status | |
---|---|---|
firefox-esr128 | --- | unaffected |
firefox134 | --- | unaffected |
firefox135 | --- | verified |
firefox136 | --- | verified |
People
(Reporter: roman.deev06, Assigned: ochameau)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: regression)
Attachments
(3 files)
4.38 MB,
video/mp4
|
Details | |
603.50 KB,
image/png
|
Details | |
48 bytes,
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-beta+
|
Details | Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Steps to reproduce:
Firefox 135.0b4 (aarch64)
- Install Violentmonkey https://addons.mozilla.org/firefox/addon/violentmonkey
- Install the userscript https://gist.github.com/deevroman/9a3ed7768766baf74347bef3545e6f33/raw/96ac306cba3a69169df1dd2e717584403227c68b/bug.user.js
- Open https://www.openstreetmap.org
- Open a debugger
- Reload the page.
- Try taking a few debugging steps
Also try disabling breakpoints and look at the logs console. You will see that all extension logs are duplicated. Sometimes for ~30 times!
Actual results:
Debugging doesn't work. Logs in the console are duplicated. Sometimes debugger bugs appear.
Reporter | ||
Comment 1•21 days ago
|
||
Comment 2•21 days ago
|
||
The Bugbug bot thinks this bug should belong to the 'DevTools::Debugger' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 3•20 days ago
|
||
Alex, does this look like anything you saw these days working on webextension?
Reporter | ||
Comment 4•20 days ago
|
||
The problem is also reproduced in 136.0a1 (2025-01-14) (aarch64)
Assignee | ||
Comment 5•20 days ago
|
||
This issue around duplicated log messages is probably a regression from bug 1413872.
Now that we spawn distinct targets for content scripts, we have to filter-out content script log messages from the WindowGlobal Target's ConsoleMessageWatcher, while filter-in them in the ConsoleMessageWatcher of ContentScript Target.
Unfortunately the filtering is broken.
ConsoleEvent's addonId is never set for content scripts, but only for extension sidebar, background page,...
It comes from the fact that the console
object used by the Content Script is the web page one.
We do not try to spawn a Console instance for the content script Sandbox.
ConsoleEvent's sourceId
is always defined, it could help filter-in messages in the case of the ContentScript Target,
as we have Debugger API exposing the content script sources and we could do a match.
Unfortunately, it wouldn't help filter-out messages in the case of WindowGlobal Target as it wouldn't spawn the content script sources.
We could filter-out all console message while sourceId
doesn't match any source registered in the thread actor, but that may filter-out some other type of sources.
I'll keep investigating.
Roman, I'm curious about debugger issues. Could it be that you are only confused because of the unreliable console messages? Or is there actual issues with the debugger? Some more details would be helpful if you are able to find some steps to reproduce.
Reporter | ||
Comment 6•20 days ago
|
||
Could it be that you are only confused because of the unreliable console messages?
Notice what happens in the video when I try to do Step Into. The file with the script seems to be located immediately in all the extensions that I have installed. When I take a step, it's like I'm being switched to a duplicate script file in a different extension. As a result, you need to make a few clicks of Step Into to go to the next line of code.
Assignee | ||
Comment 7•20 days ago
|
||
(In reply to Roman Deev from comment #6)
Could it be that you are only confused because of the unreliable console messages?
Notice what happens in the video when I try to do Step Into. The file with the script seems to be located immediately in all the extensions that I have installed. When I take a step, it's like I'm being switched to a duplicate script file in a different extension. As a result, you need to make a few clicks of Step Into to go to the next line of code.
ah, I missed the video, I can repro and will investigate as well. Thanks for your report!
Updated•19 days ago
|
Updated•19 days ago
|
Comment 8•19 days ago
|
||
Set release status flags based on info from the regressing bug 1413872
Assignee | ||
Comment 9•18 days ago
|
||
The content script targets should only process messages having an addonId
attribute set.
For now, ConsoleEvent objects are never setting the addonId
correctly,
which makes the console message appear as a page message.
For now, display messages and errors as page messages and errors,
which means that they are and will be shown regarding of the debugger setting
controlling content script debugging.
Updated•18 days ago
|
Assignee | ||
Updated•18 days ago
|
Updated•18 days ago
|
Comment 10•14 days ago
|
||
Comment 11•14 days ago
|
||
bugherder |
Comment 12•13 days ago
|
||
The patch landed in nightly and beta is affected.
:ochameau, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- If no, please set
status-firefox135
towontfix
.
For more information, please visit BugBot documentation.
Assignee | ||
Comment 13•13 days ago
|
||
Comment on attachment 9459943 [details]
Bug 1941418 - [devtools] Prevent duplicated console messages of extension content scripts.
Beta/Release Uplift Approval Request
- User impact if declined/Reason for urgency: Content script messages and errors would be shown multiple times in the console.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: Yes
- If yes, steps to reproduce: * Install Violentmonkey https://addons.mozilla.org/firefox/addon/violentmonkey
- Install the userscript https://gist.github.com/deevroman/9a3ed7768766baf74347bef3545e6f33/raw/96ac306cba3a69169df1dd2e717584403227c68b/bug.user.js
- Open a debugger
- Open https://www.openstreetmap.org
- the debugger will pause
- open the web console
The console message of the content script should be shown only once. There should be no blue badge which are shown in case of repeated message.
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): The fix is rather simple and focuses on working around this specific issue.
- String changes made/needed:
- Is Android affected?: Yes
Assignee | ||
Updated•13 days ago
|
Comment 14•13 days ago
|
||
Comment on attachment 9459943 [details]
Bug 1941418 - [devtools] Prevent duplicated console messages of extension content scripts.
Approved for 135.0b8.
Updated•13 days ago
|
Comment 15•13 days ago
|
||
uplift |
Updated•12 days ago
|
Comment 16•11 days ago
|
||
Verified as Fixed. Tested on the latest Nightly (136.0a1/20250122165122) and Beta (135.0b8/20250122091721) under Windows 10 x64 and Ubuntu 24.04 LTS.
The console message of the content script is shown only once, with no blue badge being displayed as the logs are no longer duplicated.
Assignee | ||
Comment 17•11 days ago
|
||
Hi Roman, Could you confirm that everything works well for you now?
It should be fixed in Firefox Nightly and next Firefox Beta (build more recent than 2025-01-22 [yesterday]).
Reporter | ||
Comment 18•11 days ago
|
||
In 135.0b8 the problem is fixed. Thank you!
Description
•