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

Add null-aware access to semantics instance #40146

Merged
merged 10 commits into from
Mar 14, 2023

Conversation

htoor3
Copy link
Contributor

@htoor3 htoor3 commented Mar 8, 2023

We are making calls on a SemanticsTextEditingStrategy.instance that might be null in certain cases inside testing environments. We need to add conditional property access to these instances.

Fixes flutter/flutter#122131

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.

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Mar 8, 2023
@htoor3
Copy link
Contributor Author

htoor3 commented Mar 8, 2023

@yjbanov @mdebbar should we merge this for now to unblock samehere as we think of a better way to ensure these instances are initialized in testing environments?

@htoor3 htoor3 marked this pull request as ready for review March 10, 2023 17:08
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

Ship it!

@htoor3
Copy link
Contributor Author

htoor3 commented Mar 10, 2023

@mdebbar thoughts on whether I should add to this PR the change we discussed a few days ago on this line

if (ui.debugEmulateFlutterTesterEnvironment) {
- where we move that conditional out?

Are there are situations in which semantics gets enabled before we hit updateSemantics and then it goes through that code path when it shouldn't be?

@@ -460,6 +460,6 @@ class TextField extends RoleManager {
if (!isIosSafari) {
editableElement?.remove();
}
SemanticsTextEditingStrategy.instance.deactivate(this);
SemanticsTextEditingStrategy._instance?.deactivate(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to add an engine test that simulates the situation where dispose is called before the strategy is initialized?

@mdebbar
Copy link
Contributor

mdebbar commented Mar 13, 2023

@mdebbar thoughts on whether I should add to this PR the change we discussed a few days ago

It's up to you, but I would put it in a separate PR so it can be reverted independently in case it breaks something.

semantics().semanticsEnabled = false;
});

test('Calling dispose() pre-initialization will not throw an error', () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yjbanov would something like this work?

Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

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

lgtm

@htoor3 htoor3 merged commit 9adff0a into flutter:main Mar 14, 2023
@htoor3 htoor3 added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 14, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 14, 2023
…#40146) (#122610)

Roll Flutter Engine from 59e0ced91dce to 9adff0ad2c0b (1 revision)
sourcegraph-bot pushed a commit to sgtest/megarepo that referenced this pull request Mar 14, 2023
…er/engine#40146) (#122610)

Commit: 9449c4c95e9b4db03ec61c0686d180c21488bd13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
3 participants