Closed Bug 1762796 Opened 2 years ago Closed 2 years ago

slowdown on a website due to slow Element.classList.values() (which slows down uBlock)

Categories

(Core :: DOM: Core & HTML, defect, P2)

Firefox 98
defect

Tracking

()

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: drsdk102, Assigned: emilio)

References

()

Details

Attachments

(3 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Android 11; Mobile; rv:98.0) Gecko/98.0 Firefox/98.0

Steps to reproduce:

  1. Install ublock origin stable 1.42, update its filters
  2. visit website https://moviewatchonline.com.pk/
  3. after loading website completely, page becomes unresponsive followed by firefox dialog ublock origin is slowing down the firefox,to speedup your browser, stop that extension
  4. addon developer is contacted here https://github.com/uBlockOrigin/uBlock-issues/discussions/2076

Actual results:

firefox becomes unresponsive

Expected results:

firefox should run normally

Component: DOM: Core & HTML → CSS Parsing and Computation
Summary: slowdown on a website → slowdown on a website due to slow Element.classList.values() (which slows down uBlock)

DOMTokenList is DOM code. I can take a look anyways. It seems from the profile that nsDOMTokenList::RemoveDuplicates takes most of the time, because it can be quadratic when there are duplicate tokens.

Component: CSS Parsing and Computation → DOM: Core & HTML
Flags: needinfo?(emilio)
Flags: needinfo?(emilio)

This prevents DOMTokenList from being quadratic / needing to iterate
over all values on the indexed getter, which can get slow with long
class lists.

Assignee: nobody → emilio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Remember whether we have already de-duplicated them once and avoid doing
that again.

This is an alternative approach that doesn't add overhead to attribute
setting in the general case.

Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/49b1e879a2c9
Deduplicate TokenList values faster. r=smaug
Severity: -- → S2
Priority: -- → P2
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch

Sorry to post on a closed bug, but I've got a loose end:

It looks to me that the patch here makes it so code can't use nsAttrValue without having a previous #include "nsAtom.h". This is because the new struct AttrAtomArray has inline code which requires the full nsAtom definition rather than just the forward declaration.

It caused some (easily fixed) build bustage over in Thunderbird (Bug 1763034). I've landed a fix there, but it seems like it might be more correct to replace the nsAtom forward declaration in nsAttrValue.h with #include "nsAtom.h"?
Anyway, I'll post my proposed patch and you can decide :-)

See Also: → 1763034
Attachment #9270665 - Attachment is obsolete: true

This also fixes SeaMonkey builds.

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/integration/autoland/rev/675457b38270
Allow nsAttrValue use without requiring a prior #include "nsAtom.h". r=emilio
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: