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

Merge AccessibilityBridge and AccessibilityBridgeDelegate #36597

Merged
merged 26 commits into from
Nov 4, 2022

Conversation

dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Oct 4, 2022

This PR merges AccessibilityBridgeDelegate into AccessibilityBridge, affecting common, mac, and windows. As a result, accessibility bridges and node delegates no longer call the engine for the bridge or the view, but get them as constructor arguments. AccessibilityBridge classes still refer to the engine, but only to dispatch events to embedder APIs.

Part of the multiwindow project (design doc for macOS): This reduces the usage of the following single-view APIs:

  • mac/FlutterEngine#accessibilityBridge
  • mac/FlutterEngine#viewController
  • windows/FlutterWindowsEngine::accessibilityBridge
  • windows/FlutterWindowsEngine::viewController

TODO:

  • Isolate FlutterPlatformNodeDelegateMac from the engine
  • Apply the same change to the Windows embedding
  • Documentations change
  • Update design doc (internal doc)

Why do we choose this method?

In the current HEAD:

The ultimate goal of the change is get rid of the usage of FlutterEngine#accessibilityBridge and FlutterEngine#viewController. Instead, the delegate will be provided a bridge and a view controller at initialization. In this way, the engine can initialize multiple sets of bridge-and-delegates, each for a window.

However, if we still keep the bridge and the delegate separated, the bridge must be created with a delegate, and a delegate must be created with a bridge. To resolve this circular dependency, we might either assign the delegate with the bridge later, or assign the bridge with the delegate later. Neither way is error-prone enough though: we can not guarantee at compile time that both classes have all dependents ready when other methods are called.

But since both the bridge and the delegate correspond to one window, there's no reason to separate them. If we merge the two classes, then their communication becomes intra-class.

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.

@dkwingsmt
Copy link
Contributor Author

dkwingsmt commented Oct 4, 2022

@chunhtai This PR is an alternative proposal to from #36573 by merging AccessibilityBridgeDelegate into AccessibilityBridge so that there are no circular referencing problem.

I haven't implemented everything yet (see PR body for TODOs), however the current state should be a sufficient POC that the "merging" strategy works (the mac unittests pass). Let me know if you think it's worth moving forward.

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.

I have a bit concern about using inheritence vs composition which may add more complexity if embedding starts overriding existing default method. but I think this is probably a better way to approach the dependency cycle problem. Should probably loop in @cbracken who wrote the code to wire up bridge in windows embedding.

@dkwingsmt
Copy link
Contributor Author

dkwingsmt commented Oct 4, 2022

Can you illustrate what you mean by

using inheritence vs composition which may add more complexity if embedding starts overriding existing default method

I don't think I'm adding extra inheritance, since the current engine also needs to inherit the delegate node.

About overriding existing default method, the FlutterEngine's new method is just for unit testing.

@chunhtai
Copy link
Contributor

chunhtai commented Oct 4, 2022

Can you illustrate what you mean by

using inheritence vs composition which may add more complexity if embedding starts overriding existing default method

I meant it used to be composition (the bridge compose bridge delegate to call native API), but it becomes inheritance now. which may be a bit hard to maintain if embedding starts overriding method like AddFlutterSemanticsNodeUpdate or CommitUpdates to inject their own call loop. It is not a strong opinion to not to merge delegate and bridge though.

#Edit: you can prevent override by using final keyword. so probably not too big of a deal

@cbracken
Copy link
Member

cbracken commented Oct 31, 2022

@dkwingsmt can you elaborate a bit (in the description) on the circular reference issue you mention in the comments above?

I'm also a bit on the fence in terms of inheritance vs composition. Agreed that we're effectively trading subclassing one class rather than another, but curious to understand the circular reference issue you mention above to understand why this form is an improvement.

@dkwingsmt
Copy link
Contributor Author

dkwingsmt commented Oct 31, 2022

@cbracken Sure. (I've added the following text to the PR description.)

The circular dependency can be seen in the previous PR, #36573.

  • In the current HEAD:
  • The ultimate goal of the change is get rid of the usage of FlutterEngine#accessibilityBridge and FlutterEngine#viewController. Instead, the delegate should use a provided bridge and a provided view controller.
  • But in this way, the bridge must be created with a delegate, and a delegate must be created with a bridge. This is the circular dependency.
  • In the previous PR, I tried either assigning the delegate with the bridge later, or assigning the bridge with the delegate later. But neither is error-prone enough.
  • I discovered that, since both the bridge and the delegate correspond to one window, there is no reason to separate them. Therefore in this PR, I propose to merge the two classes, resolving the circular dependency.

@dkwingsmt dkwingsmt marked this pull request as ready for review November 3, 2022 00:11
@dkwingsmt
Copy link
Contributor Author

@cbracken @chunhtai This PR should be ready to review. Although, I might need some help on the documentations, since it feels like I should merge the two classes' the documentation but I don't know enough to do so.

@dkwingsmt dkwingsmt self-assigned this Nov 3, 2022
//------------------------------------------------------------------------------
/// @brief Update the AccessibilityBridgeDelegate stored in the
/// accessibility bridge to a new one.
void UpdateDelegate(std::unique_ptr<AccessibilityBridgeDelegate> delegate);
void Reset();
Copy link
Member

Choose a reason for hiding this comment

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

The comment above needs to be updated

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 3, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 3, 2022

auto label is removed for flutter/engine, pr: 36597, due to - The status or check suite Windows Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 4, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 4, 2022

auto label is removed for flutter/engine, pr: 36597, due to - The status or check suite Mac Host clang-tidy has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 4, 2022
@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 4, 2022
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 4, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 4, 2022

auto label is removed for flutter/engine, pr: 36597, due to - The status or check suite Linux linux_arm_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 4, 2022
@auto-submit auto-submit bot merged commit 2f90bda into flutter:main Nov 4, 2022
sourcegraph-bot pushed a commit to sgtest/megarepo that referenced this pull request Nov 4, 2022
…elegate (flutter/engine#36597) (#114674)

Commit: 55fac571b396375f41282f0e5783d65ce1f24c02
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 4, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Nov 4, 2022
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 4, 2022
* 0943693 Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (flutter/flutter#114615)

* a440c46 Do not assume that pub is the first command run by "flutter create" (flutter/flutter#114621)

* 33b81ed fixes for incoming linter (flutter/flutter#113794)

* 0186b14 Fix the path where footer is written. (flutter/flutter#114469)

* 44ecbbc Roll Flutter Engine from 840a7b346216 to 66b244d9fa0a (25 revisions) (flutter/flutter#114640)

* 2ce62b3 Roll Flutter Engine from 66b244d9fa0a to e3c51631a9b5 (2 revisions) (flutter/flutter#114643)

* 8a9ddad [tools]validation basic Xcode settings for build ipa (#113412) (flutter/flutter#114634)

* 009fa69 Revert "Scribble mixin (#104128)" (flutter/flutter#114647)

* 125b9a7 Roll Flutter Engine from e3c51631a9b5 to ed31c3d76df5 (2 revisions) (flutter/flutter#114648)

* 9f6090c Revert "Fix text field label animation duration and curve" (flutter/flutter#114646)

* 44b6cd2 Roll Flutter Engine from ed31c3d76df5 to fb7cde697062 (2 revisions) (flutter/flutter#114651)

* fca260a Roll Flutter Engine from fb7cde697062 to 69a275300a28 (7 revisions) (flutter/flutter#114667)

* 7bee6e8 4b970fca0 Roll Dart SDK from c6e0307f3849 to 35b0cc8ac48b (2 revisions) (flutter/engine#37308) (flutter/flutter#114668)

* 43606d1 0a2d451b3 Roll Skia from b8209dce9a48 to 7eac7e7547e7 (1 revision) (flutter/engine#37309) (flutter/flutter#114670)

* 55fac57 2f90bda40 Merge AccessibilityBridge and AccessibilityBridgeDelegate (flutter/engine#36597) (flutter/flutter#114674)

* 4b7106c c5cc559db Roll Fuchsia Linux SDK from -0Xq1c-TncmWBWzqg... to 7e3H7isxOF6vqMDTT... (flutter/engine#37311) (flutter/flutter#114678)

* 55e8cd1 449fcc8b8 Roll Skia from 7eac7e7547e7 to c901cb6ae66f (1 revision) (flutter/engine#37313) (flutter/flutter#114683)
auto-submit bot pushed a commit to flutter/plugins that referenced this pull request Nov 4, 2022
* 0943693 Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (flutter/flutter#114615)

* a440c46 Do not assume that pub is the first command run by "flutter create" (flutter/flutter#114621)

* 33b81ed fixes for incoming linter (flutter/flutter#113794)

* 0186b14 Fix the path where footer is written. (flutter/flutter#114469)

* 44ecbbc Roll Flutter Engine from 840a7b346216 to 66b244d9fa0a (25 revisions) (flutter/flutter#114640)

* 2ce62b3 Roll Flutter Engine from 66b244d9fa0a to e3c51631a9b5 (2 revisions) (flutter/flutter#114643)

* 8a9ddad [tools]validation basic Xcode settings for build ipa (#113412) (flutter/flutter#114634)

* 009fa69 Revert "Scribble mixin (#104128)" (flutter/flutter#114647)

* 125b9a7 Roll Flutter Engine from e3c51631a9b5 to ed31c3d76df5 (2 revisions) (flutter/flutter#114648)

* 9f6090c Revert "Fix text field label animation duration and curve" (flutter/flutter#114646)

* 44b6cd2 Roll Flutter Engine from ed31c3d76df5 to fb7cde697062 (2 revisions) (flutter/flutter#114651)

* fca260a Roll Flutter Engine from fb7cde697062 to 69a275300a28 (7 revisions) (flutter/flutter#114667)

* 7bee6e8 4b970fca0 Roll Dart SDK from c6e0307f3849 to 35b0cc8ac48b (2 revisions) (flutter/engine#37308) (flutter/flutter#114668)

* 43606d1 0a2d451b3 Roll Skia from b8209dce9a48 to 7eac7e7547e7 (1 revision) (flutter/engine#37309) (flutter/flutter#114670)

* 55fac57 2f90bda40 Merge AccessibilityBridge and AccessibilityBridgeDelegate (flutter/engine#36597) (flutter/flutter#114674)

* 4b7106c c5cc559db Roll Fuchsia Linux SDK from -0Xq1c-TncmWBWzqg... to 7e3H7isxOF6vqMDTT... (flutter/engine#37311) (flutter/flutter#114678)

* 55e8cd1 449fcc8b8 Roll Skia from 7eac7e7547e7 to c901cb6ae66f (1 revision) (flutter/engine#37313) (flutter/flutter#114683)
IVLIVS-III pushed a commit to IVLIVS-III/flutter_plugins_fork that referenced this pull request Nov 11, 2022
* 0943693 Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (flutter/flutter#114615)

* a440c46 Do not assume that pub is the first command run by "flutter create" (flutter/flutter#114621)

* 33b81ed fixes for incoming linter (flutter/flutter#113794)

* 0186b14 Fix the path where footer is written. (flutter/flutter#114469)

* 44ecbbc Roll Flutter Engine from 840a7b346216 to 66b244d9fa0a (25 revisions) (flutter/flutter#114640)

* 2ce62b3 Roll Flutter Engine from 66b244d9fa0a to e3c51631a9b5 (2 revisions) (flutter/flutter#114643)

* 8a9ddad [tools]validation basic Xcode settings for build ipa (#113412) (flutter/flutter#114634)

* 009fa69 Revert "Scribble mixin (#104128)" (flutter/flutter#114647)

* 125b9a7 Roll Flutter Engine from e3c51631a9b5 to ed31c3d76df5 (2 revisions) (flutter/flutter#114648)

* 9f6090c Revert "Fix text field label animation duration and curve" (flutter/flutter#114646)

* 44b6cd2 Roll Flutter Engine from ed31c3d76df5 to fb7cde697062 (2 revisions) (flutter/flutter#114651)

* fca260a Roll Flutter Engine from fb7cde697062 to 69a275300a28 (7 revisions) (flutter/flutter#114667)

* 7bee6e8 4b970fca0 Roll Dart SDK from c6e0307f3849 to 35b0cc8ac48b (2 revisions) (flutter/engine#37308) (flutter/flutter#114668)

* 43606d1 0a2d451b3 Roll Skia from b8209dce9a48 to 7eac7e7547e7 (1 revision) (flutter/engine#37309) (flutter/flutter#114670)

* 55fac57 2f90bda40 Merge AccessibilityBridge and AccessibilityBridgeDelegate (flutter/engine#36597) (flutter/flutter#114674)

* 4b7106c c5cc559db Roll Fuchsia Linux SDK from -0Xq1c-TncmWBWzqg... to 7e3H7isxOF6vqMDTT... (flutter/engine#37311) (flutter/flutter#114678)

* 55e8cd1 449fcc8b8 Roll Skia from 7eac7e7547e7 to c901cb6ae66f (1 revision) (flutter/engine#37313) (flutter/flutter#114683)
schwa423 pushed a commit to schwa423/engine that referenced this pull request Nov 16, 2022
)

* Impl

* FlutterPlatformNodeDelegateMac

* Format

* Rename file

* Windows: Compile

* format

* Fix tests

* Fix doc

* More doc

* More comments

* Format

* Update names

* Format

* Compile

* Change to unique

* Revert as shared

* Doc fixes

* Make windows bridge weak

* Fix win compile

* Format

* move weak
percula pushed a commit to percula/packages that referenced this pull request Nov 17, 2022
* 0943693 Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (flutter/flutter#114615)

* a440c46 Do not assume that pub is the first command run by "flutter create" (flutter/flutter#114621)

* 33b81ed fixes for incoming linter (flutter/flutter#113794)

* 0186b14 Fix the path where footer is written. (flutter/flutter#114469)

* 44ecbbc Roll Flutter Engine from 840a7b346216 to 66b244d9fa0a (25 revisions) (flutter/flutter#114640)

* 2ce62b3 Roll Flutter Engine from 66b244d9fa0a to e3c51631a9b5 (2 revisions) (flutter/flutter#114643)

* 8a9ddad [tools]validation basic Xcode settings for build ipa (#113412) (flutter/flutter#114634)

* 009fa69 Revert "Scribble mixin (#104128)" (flutter/flutter#114647)

* 125b9a7 Roll Flutter Engine from e3c51631a9b5 to ed31c3d76df5 (2 revisions) (flutter/flutter#114648)

* 9f6090c Revert "Fix text field label animation duration and curve" (flutter/flutter#114646)

* 44b6cd2 Roll Flutter Engine from ed31c3d76df5 to fb7cde697062 (2 revisions) (flutter/flutter#114651)

* fca260a Roll Flutter Engine from fb7cde697062 to 69a275300a28 (7 revisions) (flutter/flutter#114667)

* 7bee6e8 4b970fca0 Roll Dart SDK from c6e0307f3849 to 35b0cc8ac48b (2 revisions) (flutter/engine#37308) (flutter/flutter#114668)

* 43606d1 0a2d451b3 Roll Skia from b8209dce9a48 to 7eac7e7547e7 (1 revision) (flutter/engine#37309) (flutter/flutter#114670)

* 55fac57 2f90bda40 Merge AccessibilityBridge and AccessibilityBridgeDelegate (flutter/engine#36597) (flutter/flutter#114674)

* 4b7106c c5cc559db Roll Fuchsia Linux SDK from -0Xq1c-TncmWBWzqg... to 7e3H7isxOF6vqMDTT... (flutter/engine#37311) (flutter/flutter#114678)

* 55e8cd1 449fcc8b8 Roll Skia from 7eac7e7547e7 to c901cb6ae66f (1 revision) (flutter/engine#37313) (flutter/flutter#114683)
adam-harwood pushed a commit to adam-harwood/flutter_plugins that referenced this pull request Nov 21, 2022
* 0943693 Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (flutter/flutter#114615)

* a440c46 Do not assume that pub is the first command run by "flutter create" (flutter/flutter#114621)

* 33b81ed fixes for incoming linter (flutter/flutter#113794)

* 0186b14 Fix the path where footer is written. (flutter/flutter#114469)

* 44ecbbc Roll Flutter Engine from 840a7b346216 to 66b244d9fa0a (25 revisions) (flutter/flutter#114640)

* 2ce62b3 Roll Flutter Engine from 66b244d9fa0a to e3c51631a9b5 (2 revisions) (flutter/flutter#114643)

* 8a9ddad [tools]validation basic Xcode settings for build ipa (#113412) (flutter/flutter#114634)

* 009fa69 Revert "Scribble mixin (#104128)" (flutter/flutter#114647)

* 125b9a7 Roll Flutter Engine from e3c51631a9b5 to ed31c3d76df5 (2 revisions) (flutter/flutter#114648)

* 9f6090c Revert "Fix text field label animation duration and curve" (flutter/flutter#114646)

* 44b6cd2 Roll Flutter Engine from ed31c3d76df5 to fb7cde697062 (2 revisions) (flutter/flutter#114651)

* fca260a Roll Flutter Engine from fb7cde697062 to 69a275300a28 (7 revisions) (flutter/flutter#114667)

* 7bee6e8 4b970fca0 Roll Dart SDK from c6e0307f3849 to 35b0cc8ac48b (2 revisions) (flutter/engine#37308) (flutter/flutter#114668)

* 43606d1 0a2d451b3 Roll Skia from b8209dce9a48 to 7eac7e7547e7 (1 revision) (flutter/engine#37309) (flutter/flutter#114670)

* 55fac57 2f90bda40 Merge AccessibilityBridge and AccessibilityBridgeDelegate (flutter/engine#36597) (flutter/flutter#114674)

* 4b7106c c5cc559db Roll Fuchsia Linux SDK from -0Xq1c-TncmWBWzqg... to 7e3H7isxOF6vqMDTT... (flutter/engine#37311) (flutter/flutter#114678)

* 55e8cd1 449fcc8b8 Roll Skia from 7eac7e7547e7 to c901cb6ae66f (1 revision) (flutter/engine#37313) (flutter/flutter#114683)
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
* 0943693 Revert "[tools]validation basic Xcode settings for build ipa (#113412)" (flutter/flutter#114615)

* a440c46 Do not assume that pub is the first command run by "flutter create" (flutter/flutter#114621)

* 33b81ed fixes for incoming linter (flutter/flutter#113794)

* 0186b14 Fix the path where footer is written. (flutter/flutter#114469)

* 44ecbbc Roll Flutter Engine from 840a7b346216 to 66b244d9fa0a (25 revisions) (flutter/flutter#114640)

* 2ce62b3 Roll Flutter Engine from 66b244d9fa0a to e3c51631a9b5 (2 revisions) (flutter/flutter#114643)

* 8a9ddad [tools]validation basic Xcode settings for build ipa (#113412) (flutter/flutter#114634)

* 009fa69 Revert "Scribble mixin (#104128)" (flutter/flutter#114647)

* 125b9a7 Roll Flutter Engine from e3c51631a9b5 to ed31c3d76df5 (2 revisions) (flutter/flutter#114648)

* 9f6090c Revert "Fix text field label animation duration and curve" (flutter/flutter#114646)

* 44b6cd2 Roll Flutter Engine from ed31c3d76df5 to fb7cde697062 (2 revisions) (flutter/flutter#114651)

* fca260a Roll Flutter Engine from fb7cde697062 to 69a275300a28 (7 revisions) (flutter/flutter#114667)

* 7bee6e8 4b970fca0 Roll Dart SDK from c6e0307f3849 to 35b0cc8ac48b (2 revisions) (flutter/engine#37308) (flutter/flutter#114668)

* 43606d1 0a2d451b3 Roll Skia from b8209dce9a48 to 7eac7e7547e7 (1 revision) (flutter/engine#37309) (flutter/flutter#114670)

* 55fac57 2f90bda40 Merge AccessibilityBridge and AccessibilityBridgeDelegate (flutter/engine#36597) (flutter/flutter#114674)

* 4b7106c c5cc559db Roll Fuchsia Linux SDK from -0Xq1c-TncmWBWzqg... to 7e3H7isxOF6vqMDTT... (flutter/engine#37311) (flutter/flutter#114678)

* 55e8cd1 449fcc8b8 Roll Skia from 7eac7e7547e7 to c901cb6ae66f (1 revision) (flutter/engine#37313) (flutter/flutter#114683)
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 platform-windows
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants