Skip to content
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

Revert mutation observer for forms #396

Merged
merged 2 commits into from
Oct 10, 2023
Merged

Conversation

GioSensation
Copy link
Member

@GioSensation GioSensation commented Oct 10, 2023

Reviewer: @shakyShane
Asana: https://app.asana.com/0/0/1205690199450910/f
CC: @kzar

Description

Reverts the code that observes for form changes. This was causing the script to spin out of control in certain cases. To clarify, it wasn't the observer itself, but the way we were re-scanning the page when new fields were added (added in version 8.1.0). This is just a patch to stop the bleeding, I will follow up with a more comprehensive set of fixes as roughly outlined here.

Steps to test

To repro the issue:

  1. Go to your Asana inbox
  2. Refresh the page (so autofill starts from scratch)
  3. Then from the Asana search bar, search for macOS Feedback and go there
  4. On the macOS Feedback project, scroll a few times back and forth and wait for the items to load (usually a couple of scrolls are enough to trigger the warning in Firefox)

With this version it should not trigger the warning or freeze the page.

Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
Signed-off-by: Emanuele Feliziani <feliziani.emanuele@gmail.com>
@GioSensation GioSensation self-assigned this Oct 10, 2023
this.formAnalyzer = new FormAnalyzer(this.form, input, this.matching)
this.recategorizeAllInputs()
return this
}
Copy link
Member Author

@GioSensation GioSensation Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what was causing the problem. Basically, in certain edge cases the container of the field (what here we call this.form) could become the body. When that happened, any new field was hitting this conditional thus dropping everything and starting from scratch. We were doing this for every single added field, which in Asana could be hundreds at a time as you scroll through large projects. This wasn't always hitting the failsafes because we kept destroying and re-building the form data.

The failsafe we built for the form-specific mutation observer wasn't running here because the trigger comes from outside (the scanner), not from the internal observer.

In our browser the slowdown was limited (still massive), but on Firefox it could hang for several seconds and show the warning.

foundForm.addInput(input)
} else {
this.stopScanner('The form has too many inputs, destroying.')
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this check in the scanner as well for added security. I have a few follow up tasks in Asana to try and understand this flow better and see how we can make it more resilient to breakage.

@@ -8,7 +8,7 @@ import {test as base} from '@playwright/test'
*/
const test = base.extend({})

test.describe('Mutating form page', () => {
test.describe.skip('Mutating form page', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just switching the test off for now.

}
}
)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't directly related to the breakage, but I'm dropping it now before investigating things further in the next few days.

@GioSensation GioSensation marked this pull request as ready for review October 10, 2023 14:43
@GioSensation GioSensation merged commit 6dd7d69 into main Oct 10, 2023
1 check passed
@GioSensation GioSensation deleted the ema/revert-observing-forms branch October 10, 2023 15:01
CDRussell pushed a commit to duckduckgo/Android that referenced this pull request Oct 11, 2023
Task/Issue URL:
https://app.asana.com/0/1205691418983700/1205691418983700
Autofill Release:
https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/8.4.2


## Description
Updates Autofill to version
[8.4.2](https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/8.4.2).

### Autofill 8.4.2 release notes
## What's Changed
* Ema/perf followups by @GioSensation in
duckduckgo/duckduckgo-autofill#386
* Fix handler regression by @GioSensation in
duckduckgo/duckduckgo-autofill#392
* Bump markdown-it from 13.0.1 to 13.0.2 by @dependabot in
duckduckgo/duckduckgo-autofill#388
* Revert mutation observer for forms by @GioSensation in
duckduckgo/duckduckgo-autofill#396


**Full Changelog**:
duckduckgo/duckduckgo-autofill@8.4.1...8.4.2

## 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 <GioSensation@users.noreply.github.com>
joshliebe pushed a commit to duckduckgo/Android that referenced this pull request Nov 7, 2023
Task/Issue URL:
https://app.asana.com/0/1205691418983700/1205691418983700
Autofill Release:
https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/8.4.2


## Description
Updates Autofill to version
[8.4.2](https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/8.4.2).

### Autofill 8.4.2 release notes
## What's Changed
* Ema/perf followups by @GioSensation in
duckduckgo/duckduckgo-autofill#386
* Fix handler regression by @GioSensation in
duckduckgo/duckduckgo-autofill#392
* Bump markdown-it from 13.0.1 to 13.0.2 by @dependabot in
duckduckgo/duckduckgo-autofill#388
* Revert mutation observer for forms by @GioSensation in
duckduckgo/duckduckgo-autofill#396


**Full Changelog**:
duckduckgo/duckduckgo-autofill@8.4.1...8.4.2

## 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 <GioSensation@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants