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

Pressing shiftkey to insert ( or ) in textfield crashes flutter application #108646

Closed
n7484443 opened this issue Jul 29, 2022 · 4 comments · Fixed by flutter/engine#35046
Closed
Labels
a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems found in release: 3.3 Found to occur in 3.3 has reproducible steps The issue has been confirmed reproducible and is ready to work on

Comments

@n7484443
Copy link
Contributor

After upgrading flutter version from 3.1.0-9.0.pre to 3.3.0-0.1.pre, this bug appeared.
I am using windows 11

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. press left Shift Key a little
  3. press 9 to input '('
  4. press left Shift Key a little
  5. press 0 to input ')' and then flutter program crash.

Expected results:

Actual results:

2022-07-30.06-40-32.mp4
Code sample
import 'package:flutter/material.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Center(
          child: Focus(
            onFocusChange: (bool hasFocus) => print(hasFocus),
            child: TextField(
              controller: TextEditingController(),
              textAlign: TextAlign.left,
              decoration: const InputDecoration(hintText: 'sample'),
            ),
          ),
        ),
      ),
    );
  }
}
flutter doctor -v [√] Flutter (Channel beta, 3.3.0-0.1.pre, on Microsoft Windows [Version 10.0.22622.436], locale ko-KR) • Flutter version 3.3.0-0.1.pre on channel beta at C:\Users\kimjuhwan\Documents\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d952ca8 (2 days ago), 2022-07-27 10:33:00 -0700 • Engine revision fd131c385e • Dart version 2.18.0 (build 2.18.0-271.4.beta) • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\kimjuhwan\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.5)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32414.318
• Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• 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 11.0.10+0-b96-7249189)

[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2
• Flutter plugin version 64.0.3
• Dart plugin version 212.5632

[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2
• Flutter plugin version 69.0.4
• Dart plugin version 221.6008.15

[√] VS Code (version 1.61.1)
• VS Code at C:\Users\kimjuhwan\AppData\Local\Programs\Microsoft VS Code
• Flutter extension can be installed from:
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22622.436]
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
• Edge (web) • edge • web-javascript • Microsoft Edge 103.0.1264.49

[√] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

Logs
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Debug service listening on ws://127.0.0.1:56752/YX01-kncxQ4=/ws
Syncing files to device Windows...
flutter: true
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.
Unable to parse JSON message:
The document is empty.

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)
#8      _invoke2 (dart:ui/hooks.dart:186:13)
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 2 frames from class _AssertionError)
====================================================================================================

======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyRepeatEvent#6b474(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 10:17:53.432358)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      HardwareK
@christopherfujino
Copy link
Member

@christopherfujino christopherfujino added a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems found in release: 3.3 Found to occur in 3.3 has reproducible steps The issue has been confirmed reproducible and is ready to work on labels Jul 29, 2022
@n7484443 n7484443 changed the title Press shiftkey to insert ( or ) in textfield crash flutter application Pressing shiftkey to insert ( or ) in textfield crashes flutter application Jul 29, 2022
@ccchp
Copy link

ccchp commented Aug 1, 2022

same issue. Have you found a solution?

@xu-baolin
Copy link
Member

xu-baolin commented Aug 1, 2022

Long press will trigger the issue.
The engine will send a repeat event after a key up.

flutter: _eventFromData KeyData(key down, physical: 0x700e0, logical: 0x200000100 (Flutter), character: <none>)
flutter: handleKeyEvent KeyDownEvent#bdb23(physicalKey: PhysicalKeyboardKey#700e0(usbHidUsage: "0x000700e0", debugName: "Control Left"), logicalKey: LogicalKeyboardKey#00100(keyId: "0x200000100", keyLabel: "Control Left", debugName: "Control Left"), character: null, timeStamp: 1495:33:25.625872) [0][{}]
flutter: _eventFromData KeyData(key up, physical: 0x700e0, logical: 0x200000100 (Flutter), character: <none>, synthesized)
flutter: handleKeyEvent KeyUpEvent#aaab6(physicalKey: PhysicalKeyboardKey#700e0(usbHidUsage: "0x000700e0", debugName: "Control Left"), logicalKey: LogicalKeyboardKey#00100(keyId: "0x200000100", keyLabel: "Control Left", debugName: "Control Left"), character: null, timeStamp: 1495:33:26.129481, synthesized) [1][{PhysicalKeyboardKey#700e0(usbHidUsage: "0x000700e0", debugName: "Control Left"): LogicalKeyboardKey#00100(keyId: "0x200000100", keyLabel: "Control Left", debugName: "Control Left")}]
flutter: _eventFromData KeyData(key repeat, physical: 0x700e0, logical: 0x200000100 (Flutter), character: <none>)
flutter: handleKeyEvent KeyRepeatEvent#14d2a(physicalKey: PhysicalKeyboardKey#700e0(usbHidUsage: "0x000700e0", debugName: "Control Left"), logicalKey: LogicalKeyboardKey#00100(keyId: "0x200000100", keyLabel: "Control Left", debugName: "Control Left"), character: null, timeStamp: 1495:33:26.129573) [0][{}]

This will happen for 'shift' or 'ctrl' key.
CC @dkwingsmt

@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 Aug 15, 2022
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 found in release: 3.3 Found to occur in 3.3 has reproducible steps The issue has been confirmed reproducible and is ready to work on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants