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

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Sep 11, 2023

Fixes flutter/flutter#133424

The -[TextInputDelegate selectionDidChange:] call actually triggers some unwanted keyboard NLP actions that generate a bunch of candidates and automatically accept the first candidate. This causes -[UITextInput setMarkedText:selection] to be called with the first candidate and that inserts extraneous characters after the user types certain characters on the iPad software keyboard.

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.

@LongCatIsLooong LongCatIsLooong marked this pull request as ready for review September 11, 2023 19:26
@LongCatIsLooong
Copy link
Contributor Author

/cc @fbcouch fyi -[TextInputDelegate selectionDidChange:] is causing some unexpected issues so I'm reverting to your original approach.

@hellohuanlin
Copy link
Contributor

actually triggers some unwanted keyboard NLP actions that generate a bunch of candidates and automatically accept the first candidate.

Could you explain more about this? Did you see a bar showing up and immediately dismissed?

}

if (_viewController.engine.textInputPlugin.textInputView != nil) {
// This is needed to notify the iPadOS keyboard that it needs to update the
Copy link
Contributor

Choose a reason for hiding this comment

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

is this comment still relevant?

_viewController.engine.textInputPlugin.textInputView.inputAssistantItem;
NSArray<UIBarButtonItemGroup*>* leadingGroups = assistantItem.leadingBarButtonGroups;
assistantItem.leadingBarButtonGroups = @[];
assistantItem.leadingBarButtonGroups = leadingGroups;
Copy link
Contributor

@hellohuanlin hellohuanlin Sep 14, 2023

Choose a reason for hiding this comment

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

hy is it setting leadingBarButtonGroups to empty array, and then setting back to the original value? Adding some comments here will be helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was a workaround to notify the iPadOS keyboard to update the state of these buttons. It's been awhile, but I believe the behavior I was seeing was that state changes to canUndo/canRedo would not show up until the next keypress – so if I press a letter, the undo button should light up, but it won't until I press another key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Worth trying if it works if we simply do assistantItem.leandingBarButtonGroups = assistantItem.leandingBarButtonGroups, in case apple doesn't check for no-ops in the setter.

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW if it's iOS 17 related, feel free to contribute to the design doc which already discusses about several iOS 17 text input issues. It can be a good reference doc for future developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the original issue is reproduced on an iOS 16 device so probably not ios specific.

I tested removing the intermediate empty array step it appears the setter indeed doesn't skip even when given the same array instance. Updated. I'll file a radar later since the keyboard could just rely on notifications to properly update the undo/redo UI.

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

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

LGTM. thanks for the update.

@LongCatIsLooong LongCatIsLooong force-pushed the remove-selectionDidChange branch from 8333758 to d9da08f Compare September 15, 2023 21:58
@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2023
@auto-submit auto-submit bot merged commit 2178248 into flutter:main Sep 18, 2023
@LongCatIsLooong LongCatIsLooong deleted the remove-selectionDidChange branch September 18, 2023 17:32
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 19, 2023
…134998)

flutter/engine@e1c784e...589bde9

2023-09-19 [email protected] Roll Skia from 4122791099ce to 744807d740c7 (1 revision) (flutter/engine#46019)
2023-09-19 [email protected] [Android] Add support for setting thread affinity based on core speed. (flutter/engine#45673)
2023-09-19 [email protected] [Impeller] Fix STB backend to account for max texture sizes. (flutter/engine#46010)
2023-09-19 [email protected] [Impeller] Hold the CommandPoolVK at a higher scope. (flutter/engine#46013)
2023-09-19 [email protected] Roll Skia from 0c990ab9e097 to 4122791099ce (19 revisions) (flutter/engine#46016)
2023-09-18 [email protected] Add missing include of SkPath (flutter/engine#45996)
2023-09-18 [email protected] [Impeller] Respect max supported texture size when allocating glyph atlas texture. (flutter/engine#45992)
2023-09-18 [email protected] Roll Fuchsia Mac SDK from 3_Lh8otTpmVuf-Zwb... to qy5FU4y6sx1FscCpd... (flutter/engine#45998)
2023-09-18 [email protected] Revert "[Windows] Update vsync on raster thread (#45310)" (flutter/engine#46000)
2023-09-18 [email protected] Provide a default `--target-variant` for `clang_tidy`. (flutter/engine#45909)
2023-09-18 [email protected] Revert "[ios] use python script to generate extension safe frameworks and code sign them" (flutter/engine#46004)
2023-09-18 [email protected] Disable HardwareBuffer backed Platform Views temporarily (flutter/engine#45986)
2023-09-18 [email protected] Tighten up ImageReaderPlatformViewRenderTarget code (flutter/engine#45889)
2023-09-18 [email protected] [ios] use python script to generate extension safe frameworks and code sign them (flutter/engine#45781)
2023-09-18 [email protected] Bump impeller-cmake to HEAD. (flutter/engine#45953)
2023-09-18 [email protected] [iOS] Remove selectionDidChange call in UndoManager (flutter/engine#45657)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from 3_Lh8otTpmVu to qy5FU4y6sx1F

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…lutter#134998)

flutter/engine@e1c784e...589bde9

2023-09-19 [email protected] Roll Skia from 4122791099ce to 744807d740c7 (1 revision) (flutter/engine#46019)
2023-09-19 [email protected] [Android] Add support for setting thread affinity based on core speed. (flutter/engine#45673)
2023-09-19 [email protected] [Impeller] Fix STB backend to account for max texture sizes. (flutter/engine#46010)
2023-09-19 [email protected] [Impeller] Hold the CommandPoolVK at a higher scope. (flutter/engine#46013)
2023-09-19 [email protected] Roll Skia from 0c990ab9e097 to 4122791099ce (19 revisions) (flutter/engine#46016)
2023-09-18 [email protected] Add missing include of SkPath (flutter/engine#45996)
2023-09-18 [email protected] [Impeller] Respect max supported texture size when allocating glyph atlas texture. (flutter/engine#45992)
2023-09-18 [email protected] Roll Fuchsia Mac SDK from 3_Lh8otTpmVuf-Zwb... to qy5FU4y6sx1FscCpd... (flutter/engine#45998)
2023-09-18 [email protected] Revert "[Windows] Update vsync on raster thread (flutter#45310)" (flutter/engine#46000)
2023-09-18 [email protected] Provide a default `--target-variant` for `clang_tidy`. (flutter/engine#45909)
2023-09-18 [email protected] Revert "[ios] use python script to generate extension safe frameworks and code sign them" (flutter/engine#46004)
2023-09-18 [email protected] Disable HardwareBuffer backed Platform Views temporarily (flutter/engine#45986)
2023-09-18 [email protected] Tighten up ImageReaderPlatformViewRenderTarget code (flutter/engine#45889)
2023-09-18 [email protected] [ios] use python script to generate extension safe frameworks and code sign them (flutter/engine#45781)
2023-09-18 [email protected] Bump impeller-cmake to HEAD. (flutter/engine#45953)
2023-09-18 [email protected] [iOS] Remove selectionDidChange call in UndoManager (flutter/engine#45657)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from 3_Lh8otTpmVu to qy5FU4y6sx1F

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
Fixes flutter/flutter#133424

The `-[TextInputDelegate selectionDidChange:]` call actually triggers some unwanted keyboard NLP actions that generate a bunch of candidates and automatically accept the first candidate. This causes `-[UITextInput setMarkedText:selection]` to be called with the first candidate and that inserts extraneous characters after the user types certain characters on the iPad software keyboard.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
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-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS]When the keyboard type of the TextField is set to "numer", there is an issue of repeated characters with certain IME.

3 participants