learn.paloaltonetworks.com is extremely slow, main thread stuck in :has() style invalidation
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
People
(Reporter: janadamec8, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 1 obsolete file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:159.0) Gecko/20100101 Firefox/159.0
Steps to reproduce
- Log in to learn.paloaltonetworks.com (Palo Alto Networks learning portal, runs on Docebo, which is an Angular app)
- Open the Partner Hub page (/pages/39/partner-hub) or just click around the portal
- Watch CPU in about:processes, or wait for the "This page is slowing down Firefox" bar
Unfortunately the portal needs a partner login, so I know you probably can't reproduce it directly. Happy to test a Nightly build or a patch, or record another profile with different settings if that helps.
Actual results
The portal is painfully slow. Pages take a long time to load, clicking around lags and I regularly get the slow-script warning. The tab sits at around 97 % CPU (one full core) while loading.
What I already tried:
- Private window with extensions disabled and tracking protection off for the site: same thing, so it's not my profile or an add-on.
- Blocking third-party stuff (Pendo, Google Tag Manager, their AI sidebar module) didn't really help.
- "Debug script" on the slow-script warning stopped in Angular's TransitionAnimationEngine.flush(), in the loop that adds the "ng-star-inserted" class to newly inserted elements.
Then I recorded a profile. If I'm reading it right, on the content process main thread:
- roughly 76 % of the non-idle time is in style invalidation
- roughly 58 % is in relative selector invalidation (style::invalidation::element::relative_selector), so I assume the site's CSS uses :has()
- most of it is triggered by DOMTokenList.add (about 47 %) and Node.insertBefore
- the single biggest caller is the flush() loop mentioned above (around 29 %)
- getComputedStyle / layout is basically nothing
So it looks like Angular adds a class to a lot of elements at once and every change kicks off expensive :has() invalidation.
Profile: https://share.firefox.dev/4yIMwMn
Expected results
The page should load and respond normally, without the main thread being pegged for seconds and without the slow-script warning.
Comment 1•29 days ago
|
||
This might be a duplicate of Bug 2083741
Comment 2•29 days ago
|
||
(not really, that is all dom mutation invalidation)
Useful things to know would be:
- On devtools, if you search for :has() in the debugger or style editor, what selectors do you see?
- Is attaching a static version of the site generated with something like SingleFile or so possible? That gives us an idea of the dom involved.
- Is it possible to use mozregression to see if this is a regression on our end? Though this code hasn't changed all that much recently...
Thanks!
| Reporter | ||
Comment 3•29 days ago
|
||
Thanks for the quick reply!
- :has() selectors
Searching the debugger for ":has(" gives 1834 hits, almost all in the site's JS bundles. They all seem to come from Docebo's design system (prefixed "lmn-"). A few examples:
lmn-list-item:has(.lmn-list-item-title-text[data-lmn-list-item-link...])
lmn-list-item:has(.lmn-list-item-selection-start lmn-input-radio, ...)
a[lmnlistitem]:has(.lmn-list-item-title-text[role=link]:focus-visible)
lmn-avatar:where(:has(.lmn-avatar-image))
.lmn-input-checkbox-label-container:has(label.lmn-input-checkbox-label:not(.lmn-visually-hidden))
Two of the bundles seem to contain the same rules, not sure if that matters.
- SingleFile
Attached a SingleFile capture of the Partner Hub page (the one from the profile). I had to block images, fonts and scripts when saving, otherwise the file was over 500 MB because of the banner images. Stylesheets are kept in full, I also turned off "remove unused styles" and "remove hidden elements". I replaced my name and initials with "Test User" / "TU", everything else is as saved.
- mozregression
I'll do it tomorrow if it's still needed. Logging in on every build makes it a bit slow, so I'd rather do it when I have some time.
| Reporter | ||
Comment 4•29 days ago
|
||
Comment 5•29 days ago
|
||
That does catch it, thanks.
https://share.firefox.dev/4zj1TfM
... Going to have to dig a bit to see what is causing all those invalidations
Comment 6•29 days ago
|
||
(In reply to Jan Adamec from comment #3)
Searching the debugger for ":has(" gives 1834 hits, almost all in the site's JS bundles. They all seem to come from Docebo's design system (prefixed "lmn-"). A few examples:
lmn-list-item:has(.lmn-list-item-title-text[data-lmn-list-item-link...])
lmn-list-item:has(.lmn-list-item-selection-start lmn-input-radio, ...)
a[lmnlistitem]:has(.lmn-list-item-title-text[role=link]:focus-visible)
lmn-avatar:where(:has(.lmn-avatar-image))
.lmn-input-checkbox-label-container:has(label.lmn-input-checkbox-label:not(.lmn-visually-hidden))Two of the bundles seem to contain the same rules, not sure if that matters.
Uhh, fun... :')
I'll do it tomorrow if it's still needed. Logging in on every build makes it a bit slow, so I'd rather do it when I have some time.
FWIW there's a --profile-persistence reuse option that you can use to avoid this. But seems that we have a repro, thanks so much!
Comment 7•29 days ago
|
||
Basic instrumentation tells me we're seeing a loooooot of selectors like:
.app-layout-main > lrn-content-overview > .ui-row-slender > div[class*="ui-col"] > lrn-widget-content-description .dcb-te-content-description-widget .dcb-te-content-description-widget-wrapper .gk-panw-gtm-olx-course-overview-page-customisation
at offset 8, which is div[class*="ui-col"], for divs like <div class="lmn-tooltips-root">, <div class="lmn-toasts-container" role="log" aria-atomic="false" tabindex="-1" aria-label="Platform feedback">, etc. We should be able to reject those early for sure..
| Reporter | ||
Comment 8•29 days ago
|
||
Thanks! I’ll skip mozregression then, let me know if you need anything else.
Comment 9•29 days ago
|
||
So we end up walking through nested selectors, and registering next dependencies for the shared :has multiple times... Selector in the testcase adds the attribute dependency 6 times.
... We share the allocation of the selector already, so it seems reasonable to share the next dependencies? We need to point at multiple next dependencies, which is possible since @scope does that, but interaction may not be that fun.
Comment 10•17 days ago
|
||
Just as a plain HTML so that it's easier to access.
Comment 11•16 days ago
|
||
Triaging as S3; dshin/emilio, feel free to adjust if you see fit. Thanks!
Description
•