Closed Bug 1879438 Opened 10 months ago Closed 3 months ago

Missing BiDi network events for cached stylesheets

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
3

Tracking

(firefox132 fixed)

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: jdescottes, Assigned: Sasha)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [webdriver:m12][webdriver:relnote])

Attachments

(1 file)

In Firefox, we are currently not emitting network events for resources which are fully read from the cache without even doing a roundtrip on the server. This is also an issue with DevTools (eg Bug 1710373 + see related metas).

Such requests do not hit the network layer, but per spec we should still create events for them.

This blocks one puppeteer test at least: "network Network Events Page.Events.RequestServedFromCache"

Depends on: 1879502
Severity: -- → S3
Points: --- → 3
Priority: -- → P2
Whiteboard: [webdriver:m10]

Check if we are getting any observer notification and check with Necko.

Flags: needinfo?(jdescottes)

Hi Kershaw,

Last week we discussed on #necko about monitoring resources for which there is no network request performed at all, so I built a test case at: https://hg.mozilla.org/try/rev/8a5015b0e340a894fdc2e3e780d309d3c95fc90f

You can pull it and run ./mach test devtools/client/netmonitor/test/browser_net_http_cache.js

This test doesn't actually use anything from devtools, it should be pretty self explanatory. It first loads a HTML page using a stylesheet which will be read from the cache on next reload. Then setup an observer for http-on-examine-cached-response and reload -> we don't get any notification. I actually tried to monitor all possible topics:

"http-startup",
"http-on-failed-opening-request",
"http-on-opening-request",
"document-on-opening-request",
"http-on-modify-request",
"http-on-modify-request-before-cookies",
"document-on-modify-request",
"http-on-before-connect",
"http-on-dispatching-transaction",
"http-on-examine-response",
"http-on-examine-merged-response",
"http-on-background-revalidation",
"http-on-examine-cached-response",
"http-on-stop-request",

But I only ever get notified about requests for the document, never for the stylesheet. Is there something we could use in this case to be notified about the cache read for the stylesheet?

Flags: needinfo?(jdescottes) → needinfo?(kershaw)

Sorry for the delay.

I've tried to run the test case and I found that after reloading the tab, there was no http request made to test.css.
I assume the reason is that the style sheet is loaded via the css cache, not http cache.
If you enable the css loader log (MOZ_LOG=nsCSSLoader:5), you should be see logs below shows that test.css is loaded from the css cache.

 0:08.34 GECKO(70026) [Child 70035: Main Thread]: D/nsCSSLoader KeyEquals(http://localhost:56545/test.css)
 0:08.34 GECKO(70026) [Child 70035: Main Thread]: D/nsCSSLoader KeyEquals(http://localhost:56545/test.css)
 0:08.34 GECKO(70026) [Child 70035: Main Thread]: D/nsCSSLoader  > Encoding guess mismatch
 0:08.34 GECKO(70026) [Child 70035: Main Thread]: D/nsCSSLoader   Hit cache with state: Complete
 0:08.34 GECKO(70026) [Child 70035: Main Thread]: D/nsCSSLoader   Sheet is alternate: 0
 0:08.34 GECKO(70026) [Child 70035: Main Thread]: D/nsCSSLoader   Sheet already complete: 0x10e8400c0

I am not sure how to bypass the css cache or maybe we want to modify css loader to send notifications to devtools?

Flags: needinfo?(kershaw)

Thanks a lot for the feedback!

Indeed I didn't think about testing with other types of resources, but a similar test with a JS file works fine.
I don't think we want to bypass the CSS cache for webdriver, the browser should behave as usual. So we probably need to have notifications from the CSS loader in case something is fully read from the cache.

Maybe there are other resources for which we will need similar notifications? (images, fonts?)

Summary: Missing BiDi network events for fully cached resources → Missing BiDi network events for cached stylesheets

Hi Emilio,

Do you know if there are notifications from the CSS Loader when a stylesheet is retrieved from the CSS cache? Even if this is not using the http cache, I think that spec wise we should still emit BiDi network events for those.

Flags: needinfo?(emilio)

I don't think that right now we have such a thing. I mean, the loader notifies when the load is done to its observers, but not globally (see Loader::NotifyObservers). We could notify there, or do something like bug 1722759, but for css.

Flags: needinfo?(emilio)
Depends on: 1884876
See Also: → 1884877
Whiteboard: [webdriver:m10] → [webdriver:m11]
Priority: P2 → P3
Priority: P3 → P2
Whiteboard: [webdriver:m11] → [webdriver:m12]
Whiteboard: [webdriver:m12] → [webdriver:m12:blocked]

It's not blocking a Puppeteer P2 failure anymore.

No longer blocks: puppeteer-firefox-bidi
Assignee: nobody → aborovova
Status: NEW → ASSIGNED
Pushed by aborovova@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3aa26ab05d3e [bidi] Create BiDi network events for cached stylesheets. r=webdriver-reviewers,jdescottes
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
Depends on: 1919784
Whiteboard: [webdriver:m12:blocked] → [webdriver:m12][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: