Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[macOS] Inconsitent keyboard modifier state after unfocusing window with modifier key present #135349

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

Closed
knopp opened this issue Sep 23, 2023 · 3 comments · Fixed by flutter/engine#46230
Labels
a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems engine flutter/engine repository. See also e: labels. found in release: 3.13 Found to occur in 3.13 found in release: 3.15 Found to occur in 3.15 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-mac Building on or for macOS specifically r: fixed Issue is closed as already fixed in a newer version team-macos Owned by the macOS platform team

Comments

@knopp
Copy link
Member

knopp commented Sep 23, 2023

Sample code:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Listener(
          behavior: HitTestBehavior.opaque,
          onPointerDown: (e) {
            print('RAW: ${RawKeyboard.instance.keysPressed}');
            print('HW: ${HardwareKeyboard.instance.logicalKeysPressed}');
          },
          child: Container(),
        ),
      ),
    );
  }
}

To reproduce, focus the flutter window, hold shift key and click on another window to unfocus flutter window. After that, depress the shift key and click anywhere in the Flutter window.

Expected output (keys currently pressed):

flutter: RAW: {}
flutter: HW: {}

Actual output (raw keyboard has shift key stuck):

flutter: RAW: {LogicalKeyboardKey#df100(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left")}
flutter: HW: {}

HW keyboard does not have the shift key pressed anymore, but when you shift+click now, the HW keyboard will not register the shift until keyboard event.

The problem here is, as far as I can tell, that only FlutterKeyboardManager only synchronizes modifiers for FlutterEmbedderKeyResponder, not doing anything for FlutterChannelKeyResponder.

@knopp
Copy link
Member Author

knopp commented Sep 23, 2023

This has been done for hardware keyboard in flutter/engine#37870, but is missing implementation for raw keyboard.

@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label Sep 25, 2023
@danagbemava-nc
Copy link
Member

Reproducible using the code sample and steps outlined above.

flutter doctor -v
[!] Flutter (Channel stable, 3.13.5, on macOS 13.5.2 22G91 darwin-arm64, locale en-GB)
    • Flutter version 3.13.5 on channel stable at /Users/nexus/dev/sdks/flutter
    ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12fccda598 (5 days ago), 2023-09-19 13:56:11 -0700
    • Engine revision bd986c5ed2
    • Dart version 3.1.2
    • DevTools version 2.25.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
    • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

[✓] VS Code (version 1.82.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.72.0

[✓] Connected device (3 available)
    • Nexus (mobile)  • 00008020-001875E83A38002E • ios            • iOS 17.0.1 21A340
    • macOS (desktop) • macos                     • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm64
    • Chrome (web)    • chrome                    • web-javascript • Google Chrome 117.0.5938.92
    ! Error: Browsing on the local area network for Dean’s iPad. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
[✓] Flutter (Channel master, 3.15.0-7.0.pre.5, on macOS 13.5.2 22G91 darwin-arm64, locale en-GB)
    • Flutter version 3.15.0-7.0.pre.5 on channel master at /Users/nexus/dev/sdks/flutters
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be085a9229 (3 hours ago), 2023-09-25 00:37:04 -0400
    • Engine revision 3ea1174ecf
    • Dart version 3.2.0 (build 3.2.0-191.0.dev)
    • DevTools version 2.28.0-dev.12

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode-15.0.0-Release.Candidate.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
    • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

[✓] VS Code (version 1.82.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.72.0

[✓] Connected device (3 available)
    • Nexus (mobile)  • 00008020-001875E83A38002E • ios            • iOS 17.0.1 21A340
    • macOS (desktop) • macos                     • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm64
    • Chrome (web)    • chrome                    • web-javascript • Google Chrome 117.0.5938.92
    ! Error: Browsing on the local area network for Dean’s iPad. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

@danagbemava-nc danagbemava-nc added a: text input Entering text in a text field or keyboard related problems engine flutter/engine repository. See also e: labels. platform-mac Building on or for macOS specifically has reproducible steps The issue has been confirmed reproducible and is ready to work on team-desktop found in release: 3.13 Found to occur in 3.13 found in release: 3.15 Found to occur in 3.15 a: desktop Running on desktop and removed in triage Presently being triaged by the triage team labels Sep 25, 2023
knopp added a commit to flutter/engine that referenced this issue Sep 27, 2023
Fixes flutter/flutter#135349

This has been done for FlutterEmbedderKeyResponder in
#37870, but has not been
implemented for FlutterChannelKeyResponder, which results in RawKeyboard
being out of sync with HardwareKeyboard.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] 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.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
@danagbemava-nc danagbemava-nc added the r: fixed Issue is closed as already fixed in a newer version label Sep 28, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2023
harryterkelsen pushed a commit to flutter/engine that referenced this issue Oct 23, 2023
Fixes flutter/flutter#135349

This has been done for FlutterEmbedderKeyResponder in
#37870, but has not been
implemented for FlutterChannelKeyResponder, which results in RawKeyboard
being out of sync with HardwareKeyboard.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] 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.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
@cbracken cbracken added team-macos Owned by the macOS platform team and removed team-desktop labels Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems engine flutter/engine repository. See also e: labels. found in release: 3.13 Found to occur in 3.13 found in release: 3.15 Found to occur in 3.15 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-mac Building on or for macOS specifically r: fixed Issue is closed as already fixed in a newer version team-macos Owned by the macOS platform team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants