Open Bug 2086739 Opened 29 days ago Updated 16 days ago

learn.paloaltonetworks.com is extremely slow, main thread stuck in :has() style invalidation

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 159
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

  1. Log in to learn.paloaltonetworks.com (Palo Alto Networks learning portal, runs on Docebo, which is an Angular app)
  2. Open the Partner Hub page (/pages/39/partner-hub) or just click around the portal
  3. 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.

This might be a duplicate of Bug 2083741

Component: Untriaged → CSS Parsing and Computation
Product: Firefox → Core
See Also: → 2083741

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

Blocks: has-issues
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(janadamec8)

Thanks for the quick reply!

  1. :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.

  1. 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.

  1. 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.

Flags: needinfo?(janadamec8)
Attached file partner-hub-singlefile-sanitized.zip (obsolete) —

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

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

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

Flags: needinfo?(dshin)

Thanks! I’ll skip mozregression then, let me know if you need anything else.

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.

Just as a plain HTML so that it's easier to access.

Attachment #9670767 - Attachment is obsolete: true

Triaging as S3; dshin/emilio, feel free to adjust if you see fit. Thanks!

Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: