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

[Windows] Introduce an accessibility plugin #50898

Closed

Conversation

loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Feb 23, 2024

This moves the logic to handle flutter/accessibility messages to a new type, AccessibilityPlugin.

Notable changes:

  1. Windows app no longer crashes if it receives accessibility events it does not support
  2. Windows app no longer crashes if it receives accessibility events while in headless mode

@yaakovschectman After playing around with this, I ended up using a different pattern than what what I suggested on #50598 (comment). This message handler is simple enough that splitting into a child/base types felt like unnecessary boilerplate. The key thing is separating messaging and implementation logic, which was achieved through the SetUp method. Let me know what you think, and sorry for all my flip-flopping on this topic! 😅

This is preparation for: flutter/flutter#143765

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 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.

const auto& type_itr = map->find(EncodableValue{kTypeKey});
const auto& data_itr = map->find(EncodableValue{kDataKey});
if (type_itr == map->end() || data_itr == map->end()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this produce an error if type or data is missing?

Copy link
Member Author

@loic-sharma loic-sharma Feb 26, 2024

Choose a reason for hiding this comment

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

I'm not sure why, but the flutter/accessibility channel does not follow the normal method call protocol. AFAICT it does not support error handling. Ignoring malformed messages appears to be the "correct" implementation:

  1. The framework ignores the embedder's reply.
  2. Android - Throws on malformed messages. Always replies with null.
  3. iOS - Ignores malformed messages. Does not reply
  4. macOS - Ignores malformed messages. Does not reply.
  5. Web - Ignores malformed messages and always replies with true.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to log an error message? Or just ignore it if the other platforms do so?

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent idea, added!

Copy link
Member Author

@loic-sharma loic-sharma Feb 26, 2024

Choose a reason for hiding this comment

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

Hmm, GitHub seems to be broken... it isn't showing the latest commit... I tried force pushing my changes too 🙃

You can find the latest implementation here: https://github.com/loic-sharma/flutter-engine/blob/c5be9d79e3c55835ece522bd8e3b8261ee19f529/shell/platform/windows/accessibility_plugin.cc#L27-L69

shell/platform/windows/fixtures/main.dart Outdated Show resolved Hide resolved
@loic-sharma loic-sharma force-pushed the windows_accessibility_plugin branch from 61a9d2d to afbf2e7 Compare February 26, 2024 18:16
@loic-sharma
Copy link
Member Author

loic-sharma commented Feb 26, 2024

Something broke on GitHub... New commits aren't showing up. I'll close this pull request and open a new one: #50975

@loic-sharma loic-sharma force-pushed the windows_accessibility_plugin branch from de41bb5 to c5be9d7 Compare February 26, 2024 19:08
auto-submit bot pushed a commit that referenced this pull request Feb 27, 2024
_This is the same pull request as #50898. GitHub broke on the previous pull request so I re-created it_

This moves the logic to handle `flutter/accessibility` messages to a new type, `AccessibilityPlugin`. 

Notable changes:

1. Windows app no longer crashes if it receives accessibility events it does not support
2. Windows app no longer crashes if it receives accessibility events while in headless mode

@yaakovschectman After playing around with this, I ended up using a different pattern than what what I suggested on #50598 (comment). This message handler is simple enough that splitting into a child/base types felt like unnecessary boilerplate. The key thing is separating messaging and implementation logic, which was achieved through the `SetUp` method. Let me know what you think, and sorry for all my flip-flopping on this topic! �

This is preparation for: flutter/flutter#143765

Sample app for manual testing: flutter/flutter#113059

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants