Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[macOS] Remove a single accessibility root assumption #40316

Merged
merged 2 commits into from
Mar 17, 2023

Conversation

loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Mar 15, 2023

Today, the root accessibility semantics node is guaranteed to have ID 0. In a multi-window world, each view will have its own semantics tree, but semantic node IDs will be globally unique. In other words, the semantics tree's root will no longer be guaranteed to have ID 0. As a result, AccessibilityBridge::kRootNodeId is deprecated and all uses should be removed.

Part of flutter/flutter#119391

Manual test

Manual test...

Apply the framework patch below, run an app using your local engine, and verify the accessibility works as expected:

diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart
index 969f822f5f..6431b3ed28 100644
--- a/packages/flutter/lib/src/semantics/semantics.dart
+++ b/packages/flutter/lib/src/semantics/semantics.dart
@@ -1650,7 +1650,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
     this.key,
     VoidCallback? showOnScreen,
     required SemanticsOwner owner,
-  }) : _id = 0,
+  }) : _id = 123,
        _showOnScreen = showOnScreen {
     attach(owner);
   }
@@ -1663,7 +1663,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
   // bits are reserved for engine generated IDs.
   static const int _maxFrameworkAccessibilityIdentifier = (1<<16) - 1;

-  static int _lastIdentifier = 0;
+  static int _lastIdentifier = 123;
   static int _generateNewId() {
     _lastIdentifier = (_lastIdentifier + 1) % _maxFrameworkAccessibilityIdentifier;
     return _lastIdentifier;

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -187,9 +187,7 @@
if (ax_node.data().HasState(ax::mojom::State::kEditable)) {
Copy link
Member Author

@loic-sharma loic-sharma Mar 15, 2023

Choose a reason for hiding this comment

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

@chunhtai Do you know a widget that exercises this scenario? This scenario can only be reached by nodes with the kEditable state that don't have the kTextField role.

The logic to create AXNodes only gives the kEditable state to semantic nodes with the kFlutterSemanticsFlagIsTextField flag but not the kFlutterSemanticsFlagIsReadOnly flag. However, such a semantics node would have the kTextField role. In other words, it seems this code is unreachable. Please let me know if I misunderstood something.

Copy link
Member

@cbracken cbracken Mar 16, 2023

Choose a reason for hiding this comment

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

Is there documentation in the ax::mojo::State enum for this role?

The ax::mojo::State enum is defined as strictly powers of two? i.e. there's no state kFoo that happens to be kBar | kEditable I assume? Agreed that at first glance, it certainly looks like this is probably dead code.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like these are defined as enum class so the answer appears to be that at least today, this is unused code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh just to make sure it's clear: semantic nodes have both state bit flags and a role enum. These are separate :)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is copied code from chromium, I don't think flutter have such widget that would run this code. We may in the future though, and we would need to update the common a11y_bridge to support that, but I am ok if we delete this code path.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha. I'll leave it in for now given we may have such a widget in the future.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM

@dkwingsmt
Copy link
Contributor

Probably need opinions from people who are more familiar. Also, shouldn't you mark it Ready For Review?

// can query semantics information from.
engine.semanticsEnabled = YES;
auto bridge = std::reinterpret_pointer_cast<AccessibilityBridgeMacSpy>(
viewController.accessibilityBridge.lock());
Copy link
Member

@cbracken cbracken Mar 15, 2023

Choose a reason for hiding this comment

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

#40334 ... you saw nothing 🤫

@loic-sharma loic-sharma marked this pull request as ready for review March 16, 2023 01:38
@loic-sharma
Copy link
Member Author

loic-sharma commented Mar 16, 2023

Also, shouldn't you mark it Ready For Review?

I had left this as a draft due to this comment above that might affect this pull request substantially. I'll mark it as ready for now though :)

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -187,9 +187,7 @@
if (ax_node.data().HasState(ax::mojom::State::kEditable)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is copied code from chromium, I don't think flutter have such widget that would run this code. We may in the future though, and we would need to update the common a11y_bridge to support that, but I am ok if we delete this code path.

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2023
@auto-submit auto-submit bot merged commit f585d4b into flutter:main Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
zanderso pushed a commit to flutter/flutter that referenced this pull request Mar 18, 2023
…122942)

* e6334f166 [web] Remove image codecs from Canvaskit Chromium (flutter/engine#40309)

* 56727d62c Revert "[Impeller] mark decoded images as optimized for GPU access (#40356)" (flutter/engine#40387)

* 2cd19e3d1 Wrap the iOS platform message handler in an autorelease pool block (flutter/engine#40373)

* bab7853ad Update analyzer for api_conform_test (flutter/engine#40386)

* 87b2e82d1 Roll Fuchsia Mac SDK from z32cF6YFs6CvZbY3g... to 4ZrEK2uzGdp_Gz3DU... (flutter/engine#40385)

* fc57995fe Ignore some MTLCompiler failures in impeller unit tests (flutter/engine#40391)

* 2398c5222 Add doc comment to Pipeline (flutter/engine#40388)

* f585d4bc5 [macOS] Remove a single accessibility root assumption (flutter/engine#40316)

* 940cf3c98 remove temporary flag and make FlutterTest the default font for real (flutter/engine#40352)

* a1bf9fd2a drawTextBlob should not be compatible with opacity inheritance (flutter/engine#40396)

* 55bf0d85e Use bundled analyzer everywhere (flutter/engine#40398)

* 8e580414a Roll Skia from 9bfb45d3e065 to 49b902e5fb91 (11 revisions) (flutter/engine#40397)

* 77c53d25e Default the CanvasKit base URL to local artifacts. (flutter/engine#40293)

* 625ea5395 Roll Skia from 49b902e5fb91 to aa983f5486f0 (7 revisions) (flutter/engine#40404)

* 867679fac [Impeller] Add playground flag to render for a specific amount of time. (flutter/engine#40377)

* d74169608 [Impeller] Remove unused bounds method from typographer interface (flutter/engine#40406)

* 941323d77 Provisional iOS impeller flag flip (flutter/engine#40405)

* bb971ab55 Revert "Default the CanvasKit base URL to local artifacts. (#40293)" (flutter/engine#40415)
zanderso pushed a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-macos
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants