Closed Bug 2013043 Opened 3 months ago Closed 1 month ago

Reporting API reports are not shown in the devtools network tab

Categories

(DevTools :: Netmonitor, defect, P2)

defect

Tracking

(firefox150 fixed)

RESOLVED FIXED
150 Branch
Tracking Status
firefox150 --- fixed

People

(Reporter: nchevobbe, Assigned: sfarre)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

(Keywords: devtools-platform-blocked)

Attachments

(2 files, 1 obsolete file)

STR:

  1. Go to about:config
  2. Set dom.reporting.enabled and dom.reporting.header.enabled to true
  3. Navigate to https://nchevobbe--019c088c009977e6946581840457796c.web.val.run/
  4. Open DevTools, select the Netmonitor
  5. Click the trigger report button

(Note that the STR seem finicky, the report might only be sent once, when opening the URL in a new tab. After reloading (even hard), it doesn't show up reliably)

Similarly to Bug 1886790, the report POST request is not showing in the regular toolbox netmonitor, only in the Browser Toolbox netmonitor.

This is where we return false https://searchfox.org/firefox-main/rev/a771bf78b90de89e0ea9d17caaa64ffa240ecd7e/devtools/shared/network-observer/NetworkUtils.sys.mjs#541,608-609

function matchRequest(channel, filters) {
...
    const win = lazy.NetworkHelper.getWindowForRequest(channel);
    return windows.includes(win);

because in https://searchfox.org/firefox-main/rev/a771bf78b90de89e0ea9d17caaa64ffa240ecd7e/devtools/shared/network-observer/NetworkHelper.sys.mjs#254-264

getWindowForRequest(request) {
  try {
    return this.getRequestLoadContext(request).associatedWindow;
  } catch (ex) {
    // On some request notificationCallbacks and loadGroup are both null,
    // so that we can't retrieve any nsILoadContext interface.
    // Fallback on nsILoadInfo to try to retrieve the request's window.
    // (this is covered by test_network_get.html and its CSS request)
    return request.loadInfo.loadingDocument?.defaultView;
  }
},

this.getRequestLoadContext(request).associatedWindow throws with Uncaught NS_ERROR_UNEXPECTED: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsILoadContext.associatedWindow]
so we enter the catch block, and request.loadInfo.loadingDocument is null, so we end up returning undefined

Valentin, would you know where those channels are created and if we can properly set their loading document?

Flags: needinfo?(valentin.gosu)

They are sent from mozilla::dom::SendReports
I'm also not sure if these reports should have a loadingDocument, since we're not actually loading the response of the reporting API report.
Simon is working on the Reporting API so he can provide more info.

Flags: needinfo?(valentin.gosu) → needinfo?(sfarre)

Is this really an issue still? I see the request being made in devtools (under the network panel)? Or is this related to something different?

Flags: needinfo?(sfarre)

(In reply to Simon Farre [:sfarre] from comment #3)

Is this really an issue still? I see the request being made in devtools (under the network panel)? Or is this related to something different?

it's only showing up in the Browser Toolbox Netmonitor (https://firefox-source-docs.mozilla.org/devtools-user/browser_toolbox/index.html), which is a "special" DevTools toolbox, mostly aimed at Firefox engineers. We want to have it displayed in the Tab toolbox netmonitor, which is what Web Developers are using. The tab netmonitor needs to have a way to match a given channel with the current opened tab (done in NetworkUtils.sys.mjs), which it usually does either by checking the associatedWindow or the loadingDocument (as said in Comment 0).
If it's not possible to set those on the channel, we might look for another flag (e.g. browsingContextId, innerWindowId, …) so we could match it with the tab's page.

Does that make sense Simon?

Flags: needinfo?(sfarre)

Feature seems scheduled for 149, we should have devtools support at the same time.

Severity: -- → S3
Priority: -- → P2

I've added a WIP here, but it's touching rather more than I want. It definitely would need review from a few people I believe, if I were to move this out of planned changes.

Flags: needinfo?(sfarre)
Assignee: nobody → sfarre
Attachment #9546161 - Attachment description: WIP: Bug 2013043 - Set associated browsing context ID for fetch → Bug 2013043 - Set associated browsing context ID for fetch r=#necko-reviewers,#dom-worker-reviewers,#devtools-reviewers
Status: NEW → ASSIGNED

This is done by checking the channel associatedBrowsingContext in NetworkUtils matchRequest function.
A test is added to make sure Reporting API requests are visible in the Netmonitor
and that we can inspect their payload.

Attachment #9547563 - Attachment is obsolete: true
Pushed by sfarre@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2b68fb9e0e27 https://hg.mozilla.org/integration/autoland/rev/167e2110755d Set associated browsing context ID for fetch r=necko-reviewers,dom-worker-reviewers,devtools-reviewers,cookie-reviewers,manuel,nchevobbe,edgul,kershaw,edenchuang https://github.com/mozilla-firefox/firefox/commit/4de5de5f2fbb https://hg.mozilla.org/integration/autoland/rev/8a2a412f3291 [devtools] Show Reporting API requests in Netmonitor. r=devtools-reviewers,bomsy
Regressions: 2023186
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
Regressions: 2024107
QA Whiteboard: [qa-triage-done-c151/b150]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: