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, Keyboard] Fix crash on Up-only IME event #33746

Merged
merged 10 commits into from
Jun 16, 2022

Conversation

dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Jun 1, 2022

This PR fixes flutter/flutter#104169, where a specific combination of environments leads to the following key events:

  • KeyDown, ScanCode ShiftLeft, VirtualKey ShiftLeft.
  • KeyUp, ScanCode ShiftLeft, VirtualKey VK_PROCESSKEY.

Besides fixing the exact part, this PR also reorganized much of the synthesization algorithm, adopting the terminology and process from the latest version used in Android.

Cause

The previous algorithm always looks for the critical key by virtual key, and thus fails to consider this event as the target key, synthesizing a key up event. However, the "main event" stage uses the pressing records before the synthesization, therefore also dispatching a key up event.

What is changed

The most important parts of the change are as follows:

  1. The synthesization algorithm now looks for the critical key by physical key if the key is pressed. In this way, the extra key up event are no longer synthesized. https://github.com/flutter/engine/pull/33746/files#diff-d948a303b1d747955e0f2b1e73bd03b8b4d103fd1dfda7df97dc620603e08c8aR431-R442

  2. The information for the main event is computed after synthesization. In this way, even if the synthesization is incorrect, the main-event stage won't exacerbate the problem. https://github.com/flutter/engine/pull/33746/files#diff-d948a303b1d747955e0f2b1e73bd03b8b4d103fd1dfda7df97dc620603e08c8aR171-R208

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 dkwingsmt force-pushed the win-key-fix-up-only-ime-synth branch from 7ad9e01 to c1fd021 Compare June 4, 2022 03:58
@dkwingsmt dkwingsmt requested a review from gspencergoog June 4, 2022 04:32
@dkwingsmt dkwingsmt marked this pull request as ready for review June 4, 2022 04:43
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@@ -114,10 +114,13 @@ class KeyboardKeyEmbedderHandler
uint64_t logical_key);
// Check each key's state from |get_key_state_| and synthesize events
// if their toggling states have been desynchronized.
void SynchronizeCritialToggledStates(int virtual_key, bool is_down);
void SynchronizeCritialToggledStates(int this_virtual_key,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think adding "this_" helps explain anything.

Copy link
Contributor Author

@dkwingsmt dkwingsmt Jun 16, 2022

Choose a reason for hiding this comment

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

You're right. It is the leftover of an intermediate state during development. I've changed them to be event_virtual_key and alike, which should be more helpful.

@dkwingsmt dkwingsmt 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 Jun 16, 2022
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Linux Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite Mac Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite Windows Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jun 16, 2022
@chinmaygarde
Copy link
Member

Not sure how the presubmit is running for 12 hours. I can't get to the status page either. cc @godofredoc

@godofredoc
Copy link
Contributor

Not sure how the presubmit is running for 12 hours. I can't get to the status page either. cc @godofredoc

@drewroengoogle @yusuf-goog can you please take a look to identify if the task never run or if it was github not updating the check? some instructions on how to triage the problem can be found here: go/flutter-luci-playbook#debug-builds-not-being-scheduled

@drewroengoogle
Copy link
Contributor

Not sure how the presubmit is running for 12 hours. I can't get to the status page either. cc @godofredoc

@drewroengoogle @yusuf-goog can you please take a look to identify if the task never run or if it was github not updating the check? some instructions on how to triage the problem can be found here: go/flutter-luci-playbook#debug-builds-not-being-scheduled

If I'm understanding this correctly, it does look like this run did fail: https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20iOS%20Engine/32658/overview

@yusuf-goog
Copy link
Contributor

Kicking off a retry to see if that reports back.

@godofredoc
Copy link
Contributor

If I'm understanding this correctly, it does look like this run did fail: https://ci.chromium.org/ui/p/flutter/builders/try/Mac%20iOS%20Engine/32658/overview

@dkwingsmt to validate the first build failed and after clicking the re-run button the check was not updated, am I correct?

@yusuf-goog @drewroengoogle any 500s in the reset-try api?

@dkwingsmt
Copy link
Contributor Author

@godofredoc I found that the test failed with this error last night and clicked rerun. I don't remember if the check is updated after that (I tend to saying that it did become a green dot but don't count me on that.)

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 17, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
* Impl and test

* Format and some doc

* Rewrite algorithm

* Format

* Simplify

* Fix

* Fix params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants