Large lag from identifyAutofillFields on page with many forms
Categories
(Toolkit :: Form Autofill, defect, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox102 | --- | fixed |
People
(Reporter: matze.kind, Assigned: dimi)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0
Steps to reproduce:
I opened a page using many form fields with labels (in my case a lage json-editor https://github.com/json-editor/json-editor ) and entered some data in text fields / selected diffrent options of a <select>
UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0
OS: Darwin 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
Device: Macbook Pro 15' 2017 i7 16GB
Actual results:
At some point (just after entering some string or switching an <select> to a diffrent option), the whole page (JS) freezes for 20-40 seconds. (see profile attached)
The page was deployed more than 50 days ago, so no dependency change there that caused this. Until a few days ago I never encountered this kind of lag after inital initalization of the editor, so I guess this was introduced in FF 99
Profiling shows 35 seconds (86%) spent in identifyAutofillFields -> ... -> findLabelElements
Expected results:
Like with previous versions of FF, the autofill machanic should not block the page noticable for the user, especially when the DOM mostly didn't change
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Layout: Form Controls' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
The severity field is not set for this bug.
:jwatt, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 3•2 years ago
|
||
Sorry for the lag here.
Shareable profile for convenience: https://share.firefox.dev/37D6rGc
This looks pretty bad... Dimi can you take a look? You seem to be the last one that touched that relevant code. Though it seems significant changes happened in the 100 release. Reporter, is this still happening with Firefox 100?
Assignee | ||
Comment 4•2 years ago
|
||
Firefox 100 did change a lot of stuff, but the flow is basically the same, I guess this issue will still be reproducible in 100.
The profile shows that we spend a lot of time extracting labels from elements. This is for our heuristics to determine whether a field is a credit card field or an address field. The poor performance on form in many fields with labels is actually not surprising to me, I can see there is a lot of room to improve.
Hi matze, could you share with me the page you reproduce this issue, then I can make sure we improve our heuristic in the right direction.
Assignee | ||
Comment 5•2 years ago
|
||
Accessing control via label.control
requires a call to native HTMLLabelElement::GetLabeledElement.
And for unmapped label case, we call
this._unmappedLabels.filter(label => label.control == element);
for every input element in the form. This means if a form has 10 labels
and 10 elements, a identifyAutofillFields
call to the form may invoke up to 100 (10x10)
HTMLLabelElement::GetLabeledElement call.
This patch fixes this issue by storing the reference of the control elements in
this._unmappedLabelControls
to reduce the number of HTMLLabelElement::GetLabeledElement calls
(10 HTMLLabelElement::GetLabeledElement calls in the foregoing example).
Updated•2 years ago
|
Assignee | ||
Comment 6•2 years ago
|
||
I think I've found the root cause, clear the needinfo.
Pushed by dlee@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cf51f1125d46 Store the reference of HTMLLabelElement.control when generating label maps r=sgalich
Comment 8•2 years ago
|
||
Backed out for causing failures at test_autocomplete_off_on_inputs.js.
Backout link: https://hg.mozilla.org/integration/autoland/rev/84b9f42369c1f7849288ea7acda5faeea4917704
Updated•2 years ago
|
Updated•2 years ago
|
Pushed by dlee@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cb3d80b0b483 Store the reference of HTMLLabelElement.control when generating label maps r=sgalich
Comment 10•2 years ago
|
||
bugherder |
Assignee | ||
Updated•2 years ago
|
Updated•2 years ago
|
Description
•