Opening DevTools triggers PerformanceObserver (with entryTypes: ["resource"]) callback
Categories
(DevTools :: Inspector, defect)
Tracking
(firefox109 verified, firefox110 verified)
People
(Reporter: bzugmeyer, Assigned: sefeng)
References
()
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0
Steps to reproduce:
-
Navigate to https://firefox-duplicated-performancetiming-for-css.benoitzugmeyer.repl.co/ or any page with a few stylesheets included via <link> tags
-
Open the devtools Inspector panel (ex: right click > Inspect element)
-
Many PerformanceTiming entries are reported to
PerformanceObserver
callbacks with their.name
property referencing stylesheets URLs multiple times. In the demo page above, many ENTRY lines are showing up for the two stylesheets, even if the stylesheets are downloaded only once.
I tried a few anterior Firefox versions and the issue occurs way more since Firefox 89. Before that, PerformanceTiming entries were still repeated but just a few times.
Actual results:
Many PerformanceTiming are reported for stylesheets even if they are requested only once
Expected results:
Only one PerformanceTiming is reported for each requested stylesheet.
Reporter | ||
Comment 1•2 years ago
|
||
Reporter | ||
Comment 2•2 years ago
|
||
Comment on attachment 9300736 [details]
Screenshot 2022-10-28 at 11.56.05.png
Screenshot showing the issue on https://firefox-duplicated-performancetiming-for-css.benoitzugmeyer.repl.co/ on Firefox 106. As we can see, PerformanceTiming entries are repeated many times.
Comment 3•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'DevTools::Inspector' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 4•2 years ago
|
||
Thanks for the report Benoît.
I think we got a similar bug recently as DevTools are fetching resources from the network, but I can't find it at the moment.
Comment 5•2 years ago
|
||
This seem related to this fetch call: https://searchfox.org/mozilla-central/rev/73ff5f1ac45202c4621a1bcee4b35d20027e71ad/devtools/server/actors/utils/stylesheets-manager.js#457, which is done on behalf of the page (same window/principal)
Comment 6•2 years ago
|
||
Try to use cacheKey as in the debugger: https://searchfox.org/mozilla-central/rev/d1fe4b6dd7027a54c17ce3030948a1be354598ab/devtools/server/actors/utils/sources-manager.js#440
Comment 7•2 years ago
|
||
Using cacheKey doesn't seem to help here.
As mentioned in comment #5 we use both the window
and principal
options for this fetch call. The PerformanceObserver
seems triggered as long as we set the window option. But using the same window
as the page is still required for Bug 1405342.
So on one hand we want to request the stylesheet as if it was requested from the actual page, but we still would like to have a way to hide it from the PerformanceObserver. Markus, do you know if there is anything we could do to hide the fetch call at https://searchfox.org/mozilla-central/rev/73ff5f1ac45202c4621a1bcee4b35d20027e71ad/devtools/server/actors/utils/stylesheets-manager.js#457 from the PerformanceObserver
Comment 8•2 years ago
|
||
I don't know the PerformanceObserver code all that well, forwarding to Sean.
Assignee | ||
Comment 9•2 years ago
|
||
I don't think we could do this from the javascript side, however I think we can utilize IsInDevToolsContext
to filter these fetch requests out. Though I am not sure if it'll break existing PerformanceObserver usage in the devtools (if we have some), probably need to check IsInDevToolsContext
+ content principal
I think.
I'll write a write a patch for this next week.
Assignee | ||
Comment 10•1 year ago
|
||
Devtools can generate fetch request on behalf of the content document,
reporting these requests in PerformanceObserver would cause confusion,
so we should ignore them.
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 12•1 year ago
|
||
Pushed by sefeng@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b3760215fcc0 Make devtools generated fetch requests excluded from resource timing r=jdescottes,valentin,necko-reviewers
Comment 13•1 year ago
|
||
bugherder |
Updated•1 year ago
|
Comment 14•1 year ago
|
||
Reproducible on a 2022-10-28 Nightly build on macOS 12.
Verified as fixed on Firefox 109.0b6(build ID: 20221222190305) and Nightly 110.0a1(build ID: 20221226154927) on macOS 12, Windows 10, Ubuntu 22.
Description
•