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

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Feb 25, 2021

Added a catch all workaround to make sure semantics is enabled.
flutter/flutter#75887

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.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

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

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

This in itself doesn't fix any issue right? There should be an update to FlutterEngine who implements FlutterViewEngineDelegate

asBase64Encoded:(BOOL)base64Encode;

- (std::shared_ptr<flutter::FlutterPlatformViewsController>&)platformViewsController;
- (void)ensureSemanticsEnabled;
Copy link
Member

Choose a reason for hiding this comment

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

I'd add a docstring since it isn't clear what this method is used for.

@chunhtai
Copy link
Contributor Author

chunhtai commented Mar 1, 2021

This in itself doesn't fix any issue right? There should be an update to FlutterEngine who implements FlutterViewEngineDelegate

Without this patch, the voice control will not work for flutter application, because flutter can't detect whether voice control is turned on or off. If it can't detect, it won't enable the semantics

iOS does not provide a public API to listen to the notification for voice control either, that is why I have to use this workaround to catch all...

Not sure about what update is needed to FlutterEngine, the ensureSemanticsEnabled is an existing selector defined in header/FlutterEngine.h, I am not sure if this is a good practice, should i define a different selector?

@gaaclarke
Copy link
Member

@chunhtai Right, I'm just saying there is more to come, right? You have added a method to a protocol, but you didn't implement that method. Maybe you forgot to push a change to the FlutterEngine?

@chunhtai
Copy link
Contributor Author

chunhtai commented Mar 2, 2021

@chunhtai Right, I'm just saying there is more to come, right? You have added a method to a protocol, but you didn't implement that method. Maybe you forgot to push a change to the FlutterEngine?

The method i added to the protocol matches an existing method in FlutterEngine,

@gaaclarke
Copy link
Member

gaaclarke commented Mar 2, 2021

Ahh ok. Here's some food for thought. In Apple's API's delegates are typically called with a pointer to the class like this:

@class Foo;
@protocol FooDelegate
-(void)somethingHappened:(Foo*)foo;
@end

I think you are leaking FlutterEngine implementation details into the FlutterView. The protocol is meant to be an abstraction, not just a limited view of the FlutterEngine. I think you'd be better off calling it something generic instead of calling it something specific to FlutterEngine such that you'll end up with:

@implementation FlutterView
- (BOOL)isAccessibilityElement {
  if (self.accessibilityElements == nil) {
    [_delegate flutterViewDidReceiveAccessibilityPing:self];
  }
  return NO;
}
@end

@implementation FlutterEngine
- (BOOL)flutterViewDidReceiveAccessibilityPing:(FlutterView*)flutterView {
  [self ensureSemanticsEnabled];
}
@end

This way it's much more clear about the relationship between the FlutterView and the FlutterEngine and mocking out the delegate makes more sense since the abstraction is talking about what it is notifying about, not what to do about it.

@chunhtai
Copy link
Contributor Author

chunhtai commented Mar 3, 2021

Thanks @gaaclarke this is ready for another look

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

LGTM once you fix the test


@implementation FakeDelegate

- (void)ensureSemanticsEnabled {
Copy link
Member

Choose a reason for hiding this comment

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

This method has to be updated, this test should be failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I inherited from the FlutterEngine so I only need to override ensureSemanticsEnabled. I want to test the FlutterView.isAccessibilityElement call eventually lead to ensureSemanticsEnabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

otheriwse, I will need to write two tests.
one for FlutterView.isAccessibilityElement calls FlutterViewEngineDelegate.flutterViewAccessibilityDidCall

the other one for FlutterEngine.flutterViewAccessibilityDidCall calls FlutterEngine.ensureSemanticsEnabled

Copy link
Member

Choose a reason for hiding this comment

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

Ahh yea, sorry missed that. I think you should use a mock object to keep the test hermetic. Now you're tying your testing of functionality on FlutterView to implementation details in FlutterEngine which is fragile. It easy to replace it if you use OCMock, there are examples in other tests.

@chunhtai chunhtai added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Mar 4, 2021
@fluttergithubbot fluttergithubbot merged commit 4bef5f8 into flutter:master Mar 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 4, 2021
cbracken pushed a commit to flutter/flutter that referenced this pull request Mar 4, 2021
* aa3bb5e [web] Fix painting of last placeholder in paragraph (flutter/engine#24716)

* a5ae18b [web] Fix pointer events for Wacom pen (flutter/engine#24719)

* 4993c8e Roll Skia from d863ae52d4bb to 036ba86489d7 (3 revisions) (flutter/engine#24732)

* 7f1de85 Roll Dart SDK from f209e60a5415 to 761ed531161f (1 revision) (flutter/engine#24730)

* 44ba1cc Roll Skia from 036ba86489d7 to 786d42c6dac4 (1 revision) (flutter/engine#24733)

* 735876e Fix memory leak and bug in the RunsOnCreationTaskRunner check (flutter/engine#24690)

* 454d29c Roll Skia from 786d42c6dac4 to 12e760e958a7 (10 revisions) (flutter/engine#24738)

* 2c605fd Roll Fuchsia Linux SDK from tJbtmEE4Q... to YhRvbuj9c... (flutter/engine#24739)

* bf97442 Roll Skia from 12e760e958a7 to e80e169ba4c1 (1 revision) (flutter/engine#24740)

* 4d2caac Fix UWP build for UpdateCursorRect rename (flutter/engine#24697)

* 83b2f8f Roll Fuchsia Mac SDK from PRe0w0i4z... to 4TE5n81B-... (flutter/engine#24745)

* 410dd6f Roll Dart SDK from 761ed531161f to f527ddd39bb1 (3 revisions) (flutter/engine#24746)

* 91d9278 Roll Dart SDK from f527ddd39bb1 to 041a6dd2e76b (1 revision) (flutter/engine#24749)

* 03e0a11 Roll Fuchsia Linux SDK from YhRvbuj9c... to _0kewDFPJ... (flutter/engine#24750)

* f5b1351 Roll Skia from e80e169ba4c1 to acf26501fb5a (4 revisions) (flutter/engine#24752)

* 21de22a Roll Skia from acf26501fb5a to a1e30a3a280a (5 revisions) (flutter/engine#24753)

* e29fd6d Roll Fuchsia Mac SDK from 4TE5n81B-... to kPp_BF0q3... (flutter/engine#24759)

* de78d2a Roll Skia from a1e30a3a280a to f0de96f7b82a (7 revisions) (flutter/engine#24760)

* a33687d Roll Skia from f0de96f7b82a to 46d9bb255df4 (2 revisions) (flutter/engine#24762)

* 95215b7 Roll Dart SDK from 041a6dd2e76b to b9302efc8d9a (3 revisions) (flutter/engine#24764)

* 4aeffbe Move CIPD package creation tools under tools/cipd (flutter/engine#24766)

* 8ef7b63 Roll Skia from 46d9bb255df4 to e4ef35caa1bc (9 revisions) (flutter/engine#24769)

* 4bef5f8 Enables semantics when voice control is turned on (flutter/engine#24640)

* a546f16 Roll Fuchsia Linux SDK from _0kewDFPJ... to _vRi_XkB7... (flutter/engine#24771)

* e31cdad Added dependency on CppWinRT for UWP builds (flutter/engine#24770)

* a5ba994 Roll Skia from e4ef35caa1bc to 4db57264955f (1 revision) (flutter/engine#24772)

* 3cf4f1d Revert "[web] Fix painting of last placeholder in paragraph (#24716)" (flutter/engine#24773)

* 91120b3 Roll Skia from 4db57264955f to 21c8ad62cd82 (2 revisions) (flutter/engine#24774)
hjfreyer pushed a commit to hjfreyer/engine that referenced this pull request Mar 22, 2021
chriscraws pushed a commit to chriscraws/engine that referenced this pull request Mar 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-ios waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants