Open Bug 2057395 Opened 4 months ago Updated 15 days ago

Deeply nested trees where all items are focusable cause major performance problems

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

Tracking Status
firefox-esr140 --- unaffected
firefox-esr153 --- wontfix
firefox153 --- wontfix
firefox154 --- wontfix
firefox155 --- wontfix
firefox156 --- wontfix

People

(Reporter: Jamie, Unassigned, NeedInfo)

References

(Blocks 2 open bugs, Regression)

Details

(Keywords: perf, regression)

Test case:

data:text/html,
<body role="application">
<div id="tree" role="tree">
  <div id="root" role="treeitem" tabindex="-1">root
    <div id="rootGroup" role="group"></div>
  </div>
</div>
<script>
let group = rootGroup;
for (let level = 1; level < 20; ++level) {
  const item = document.createElement("div");
  group.append(item);
  item.role = "treeitem";
  item.ariaExpanded = "true";
  item.tabIndex = -1;
  item.textContent = `a${level}`;
  group = document.createElement("div");
  item.append(group);
  group.role = "group";
}
for (let l = 0; l < 4; ++l) {
  const item = document.createElement("treeitem");
  group.append(item);
  item.role = "treeitem";
  item.tabIndex = 0;
  item.textContent = `l${l}`;
}
</script>
  1. Start NVDA or Narrator, but I think any screen reader will be impacted to some extent or another.
  2. Load the test case.
  3. Tab between the tree items.
    • Expected: Firefox and the screen reader should remain responsive.
    • Actual: Multi second hangs every time the focus is moved.

Profile: https://share.firefox.dev/4yDhsyR

I think we're hitting a nasty edge case with this code. That code walks the ancestors calling State() to check for the unavailable state. The problem is that in a deeply nested tree where all the items are focusable, we end up calling ImplicitState() on each ancestor, which in turn calls State() on all its ancestors, which in turn calls ImplicitState()... and so on; O(n^2).

Set release status flags based on info from the regressing bug 1899960

:eeejay, since you are the author of the regressor, bug 1899960, could you take a look?

For more information, please visit BugBot documentation.

Keywords: perf

Set release status flags based on info from the regressing bug 1899960

Blocks: 2091585
You need to log in before you can comment on or make changes to this bug.