-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix perf regressions #385
Fix perf regressions #385
Conversation
Signed-off-by: Emanuele Feliziani <[email protected]>
!string || | ||
string.length > constants.TEXT_LENGTH_CUTOFF | ||
) return this | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the meat of the fix. We want to avoid running several regex checks on potentially huge chunks of text. This is what was causing the issues.
const headings = document.querySelectorAll('h1, h2, h3, [class*="title"], [id*="title"]') | ||
headings.forEach(({textContent}) => { | ||
textContent = removeExcessWhitespace(textContent || '') | ||
const headings = document.querySelectorAll('h1, h2, h3') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed [class*="title"], [id*="title"]
to avoid catching a bunch of useless stuff.
@@ -256,10 +263,7 @@ class FormAnalyzer { | |||
this.updateSignal({string, strength, signalType: `external link: ${string}`, shouldFlip}) | |||
} else { | |||
// any other case | |||
// only consider the el if it's a small text to avoid noisy disclaimers | |||
if (removeExcessWhitespace(el.textContent)?.length < constants.TEXT_LENGTH_CUTOFF) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length check has been moved to updateSignal
so we're sure all these regexes are safeguarded against extra long text.
@@ -231,6 +231,9 @@ class DefaultScanner { | |||
return | |||
} | |||
|
|||
// Do not add explicitly search forms | |||
if (parentForm.role === 'search') return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just occurred to me we shouldn't even add these obvious search
forms, whenever web authors are kind enough to mark them as such. Now there's a new search
html element, but not worth bothering about it now.
Task/Issue URL: https://app.asana.com/0/1205602928782192/1205602928782192 Autofill Release: https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/8.4.1 BSK PR: duckduckgo/BrowserServicesKit#517 ## Description Updates Autofill to version [8.4.1](https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/8.4.1). ### Autofill 8.4.1 release notes ## What's Changed * Precompile regexes by @GioSensation in duckduckgo/duckduckgo-autofill#382 * Add perf tests by @GioSensation in duckduckgo/duckduckgo-autofill#383 * deps: remove deprecated content-scope-utils by @shakyShane in duckduckgo/duckduckgo-autofill#384 * Update dependencies by @GioSensation in duckduckgo/duckduckgo-autofill#368 * Fix perf regressions by @GioSensation in duckduckgo/duckduckgo-autofill#385 **Full Changelog**: duckduckgo/duckduckgo-autofill@8.4.0...8.4.1 ## Steps to test This release has been tested during autofill development. For smoke test steps see [this task](https://app.asana.com/0/1198964220583541/1200583647142330/f). --------- Co-authored-by: GioSensation <[email protected]> Co-authored-by: Chris Brind <[email protected]>
Reviewer: @shakyShane
Asana: https://app.asana.com/0/0/1205589679117410/f
Description
Prevent certain regex checks to run on huge strings.
Steps to test