Closed Bug 2067165 Opened 3 months ago Closed 2 months ago

about:preferences sometimes has an empty accessible tree (DocAccessible with no children)

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: florian, Assigned: Jamie)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

With --enable-a11y-checks, clicking a control in about:preferences intermittently fails:

FAIL test_turn_on_scheduled_backups_encryption - Node is not accessible via accessibility API: id: main-button, tagName: button, className:

The named node is incidental. The document's accessible tree is empty: its DocAccessible exists and is correctly bound to the parent OuterDocAccessible, but has zero children, so findInteractiveAccessible() finds nothing walking up from any node and a11yFail reports whichever node was clicked.

Logging DocAccessible::childCount at every click the checks examine correlates exactly: across 19 checks in one run, every passing check was on a document with docAccKids=1 and every failing one on a document with docAccKids=0. Which tab is affected varies per run, which is why this presents as several unrelated intermittents that move between tasks.

The affected document is otherwise entirely normal at that moment:

docURI = browserCurrentURI = about:preferences#sync   docIsBrowserDoc=true
readyState=complete  docHidden=false  winActive=true  node is laid out
outerDocAccessible.childCount=1  (the DocAccessible IS bound to its parent)
docAccessible.childCount=0       (but its tree is empty)
body.childElementCount=4         (the DOM is not empty)

It never recovers: still no accessible two requestAnimationFrame callbacks later, or 2 seconds later.

DoInitialUpdate() builds the tree and sets eTreeConstructed, and outside DocManager is only reached from NotificationController::WillRefresh (NotificationController.cpp:777) behind !IsBoundToParent() || (!DidInitialize() && !IsInitialDocument()). Both predicates are satisfied here, so that early return is not what is happening.

What remains is that eTreeConstructed is already set on a tree that is empty. DocAccessible::ContentInserted early-returns while !HasLoadState(eTreeConstructed), discarding insertions on the assumption that the initial tree walk will cover them; if DoInitialUpdate() runs while the document still has no content, nothing ever re-walks the subtree and the document stays permanently without accessibles.

This is worth treating as more than test flakiness: a visible, focused, fully loaded about:preferences with an empty accessible tree is a page a screen reader cannot see at all.

Reproduction on Linux, failing on most runs, in a different task each time:

./mach mochitest --headless --enable-a11y-checks browser/components/backup/tests/browser/browser_settings_turn_on_scheduled_backups.js

Three consecutive runs gave 2, 3 and 1 failures across five different tasks. In CI it is three intermittents on test-linux2404-64/opt-mochitest-browser-chrome-swr-a11y-checks sharing the signature: browser_settings_turn_on_scheduled_backups.js (14.9% of runs there), browser_settings_enable_backup_encryption.js (15.7%), browser_settings.js (6.6%).

Secondary ask: when the tree is empty, "Node is not accessible ...: id: main-button" points at the wrong thing entirely. Reporting that the document has no accessible tree would make the next instance diagnosable from the log alone — same class of fix as bug 2067078.

Thanks for reporting.

(In reply to Florian Quèze [:florian] from comment #0)

What remains is that eTreeConstructed is already set on a tree that is empty. DocAccessible::ContentInserted early-returns while !HasLoadState(eTreeConstructed), discarding insertions on the assumption that the initial tree walk will cover them; if DoInitialUpdate() runs while the document still has no content, nothing ever re-walks the subtree and the document stays permanently without accessibles.

DoInitialUpdate is the only thing that sets eTreeConstructed. If DoInitialUpdate runs while the document has no content, it will set eTreeConstructed and all insertions after that point will be processed. That is, only insertions before DoInitialUpdate will be discarded, because DoInitialUpdate walks all document content when it runs. That leaves two possibilities I can think of:

  1. DoInitialUpdate isn't processing the document content for some reason, even though the document contains some.
  2. We aren't getting critical insertion notifications after DoInitialUpdate runs.

This is worth treating as more than test flakiness: a visible, focused, fully loaded about:preferences with an empty accessible tree is a page a screen reader cannot see at all.

I agree, though curiously, we have not had any user reports of this at all. I would expect to have seen at least one.

Secondary ask: when the tree is empty, "Node is not accessible ...: id: main-button" points at the wrong thing entirely. Reporting that the document has no accessible tree would make the next instance diagnosable from the log alone — same class of fix as bug 2067078.

While we obviously have a bug here, there is no valid situation in which the accessibility tree should be empty. That is, this is not a failure I would ever expect a front-end test writer to have to deal with once this bug is fixed.

Blocks: treea11y
Severity: -- → S3

(In reply to Florian Quèze [:florian] from comment #0)

Reproduction on Linux, failing on most runs, in a different task each time:

./mach mochitest --headless --enable-a11y-checks browser/components/backup/tests/browser/browser_settings_turn_on_scheduled_backups.js

I couldn't reproduce this locally, so that's going to make this fun to debug. :(

I've pushed a try run to ensure this is still reproducible with no changes. That'll form a base for me to investigate this:
https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=90400

We don't (and shouldn't) create an Accessible for a display: contents element (including a <slot> inside shadow DOM) if it is inside an inert subtree.
However, it's possible that it has descendants that are not inert; e.g. an open modal <dialog>.
Previously, if we chose not to create a display: contents Accessible, we skipped its entire subtree.
In the modal dialog case above, that meant we skipped the dialog, resulting in a completely empty document (since the rest of the document is inert when a modal dialog is open).
This only occurred if the initial tree was built after the dialog was shown; e.g. the accessibility service was started late.
The mutation path actually handled this correctly, since the dialog was inserted directly in that case, rather than walking from an ancestor.

Assignee: nobody → jteh
Status: NEW → ASSIGNED

S2 because this can result in a completely empty accessibility tree in some cases, and it's not specific to about:preferences.

Severity: S3 → S2
Pushed by jteh@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e8a2c5954a21 https://hg.mozilla.org/integration/autoland/rev/002238114d63 When building the accessibility tree, traverse into descendants of an inert display: contents element. r=accessibility-platform-reviewers,morgan
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: