Closed Bug 1941418 Opened 21 days ago Closed 14 days ago

Debugging and logging of extensions is broken

Categories

(DevTools :: Debugger, defect, P2)

Firefox 135
defect

Tracking

(firefox-esr128 unaffected, firefox134 unaffected, firefox135 verified, firefox136 verified)

VERIFIED FIXED
136 Branch
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)

Attached video devtools_bug.mp4

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)

  1. Install Violentmonkey https://addons.mozilla.org/firefox/addon/violentmonkey
  2. Install the userscript https://gist.github.com/deevroman/9a3ed7768766baf74347bef3545e6f33/raw/96ac306cba3a69169df1dd2e717584403227c68b/bug.user.js
  3. Open https://www.openstreetmap.org
  4. Open a debugger
  5. Reload the page.
  6. 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.

Attached image stacktrace

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.

Component: Untriaged → Debugger
Product: Firefox → DevTools

Alex, does this look like anything you saw these days working on webextension?

Flags: needinfo?(poirot.alex)

The problem is also reproduced in 136.0a1 (2025-01-14) (aarch64)

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.

Flags: needinfo?(poirot.alex)

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.

(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!

Depends on: 1941681
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Keywords: regression
Regressed by: 1413872

Set release status flags based on info from the regressing bug 1413872

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.

Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fb6ab0231051 [devtools] Prevent duplicated console messages of extension content scripts. r=devtools-reviewers,nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 14 days ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch

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 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(poirot.alex)

Comment on attachment 9459943 [details]
Bug 1941418 - [devtools] Prevent duplicated console messages of extension content scripts.

Beta/Release Uplift Approval Request

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
Flags: needinfo?(poirot.alex)
Attachment #9459943 - Flags: approval-mozilla-beta?
Flags: qe-verify+

Comment on attachment 9459943 [details]
Bug 1941418 - [devtools] Prevent duplicated console messages of extension content scripts.

Approved for 135.0b8.

Attachment #9459943 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

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.

Status: RESOLVED → VERIFIED
Flags: qe-verify+

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]).

Flags: needinfo?(roman.deev06)

In 135.0b8 the problem is fixed. Thank you!

Flags: needinfo?(roman.deev06)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: