flutter
flutter copied to clipboard
[Linux] Pressing left alt+shift throws Exception: A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key
0
I have a very basic textfield:
TextField(
controller: controller,
keyboardType: TextInputType.text,
decoration: InputDecoration(
hintText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: CustomColors.primary),
borderRadius: BorderRadius.circular(10),
),
),
),
In my application when I type in !, @, #, $ and % the application crashes and throws the following error:
════════ Exception caught by services library ══════════════════════════════════
A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key. 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: KeyUpEvent#bd44b(physicalKey: PhysicalKeyboardKey#7001f(usbHidUsage: "0x0007001f", debugName: "Digit 2"), logicalKey: LogicalKeyboardKey#00032(keyId: "0x00000032", keyLabel: "2", debugName: "Digit 2"), character: null, timeStamp: 3:02:01.034000) and the recorded logical key LogicalKeyboardKey#00040(keyId: "0x00000040", keyLabel: "@", debugName: "At")
'package:flutter/src/services/hardware_keyboard.dart':
package:flutter/…/services/hardware_keyboard.dart:1
Failed assertion: line 444 pos 16: '_pressedKeys[event.physicalKey] == event.logicalKey'
Tried with some other special chars, seems to work fine. Running on:
Flutter (Channel stable, 2.5.3, on Ubuntu 21.10 5.13.0-22-generic, locale en_US.UTF-
N.B: The break is frequent but the case on special characters is not. As for an example @
breaks less than other chars. For me 1, #, $ and %
will definitely break
@fahimhoque This looks similar to the one fixed https://github.com/flutter/flutter/issues/89982, so I suggest you to upgrade to latest master or stable and try again to see if you still get the same exception.
Currently running:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on Ubuntu 21.10 5.13.0-22-generic, locale
en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Community Edition (version 2021.3)
[✓] VS Code
[✓] Connected device (2 available)
• No issues found!
And inside my project:
environment:
sdk: ">=2.15.1 <3.0.0"
Still getting the same error
@darshankawar - can you reproduce this problem? Is it platform-specific?
can you reproduce this problem? Is it platform-specific?
I tried to replicate this on macOS and Windows using latest stable, but didn't get the said exception. Maybe it's specific to Linux as OP is on. Since I don't have Linux, I'll request my colleague @maheshmnj to verify and confirm the behavior.
This issue seems to be partially fixed on the latest master channel. I am able to reproduce this error when pressing shift shortcuts (@,#,! etc) on stable 2.8.1
when this exception occurs all keys are locked and the keyboard does not work. But on the master channel, a similar exception occurs when pressing left alt+shift
, WIth this exception the keyboard continues to work except for the backspace and the arrow keys.
logs (stable 2.8.1)
Launching lib/main.dart on Linux in debug mode...
lib/main.dart:1
Connecting to VM Service at ws://127.0.0.1:43505/34iPjOE2uaM=/ws
** (counter:4580): WARNING **: 12:21:53.462: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
The following assertion was thrown during a platform message callback:
A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key. 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: KeyUpEvent#21f5f(physicalKey: PhysicalKeyboardKey#7001f(usbHidUsage: "0x0007001f", debugName: "Digit 2"), logicalKey: LogicalKeyboardKey#00032(keyId: "0x00000032", keyLabel: "2", debugName: "Digit 2"), character: null, timeStamp: 0:10:23.621000) and the recorded logical key LogicalKeyboardKey#00040(keyId: "0x00000040", keyLabel: "@", debugName: "At")
'package:flutter/src/services/hardware_keyboard.dart':
package:flutter/…/services/hardware_keyboard.dart:1
Failed assertion: line 444 pos 16: '_pressedKeys[event.physicalKey] == event.logicalKey'
2
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/…/services/hardware_keyboard.dart:444
#3 HardwareKeyboard._assertEventIsRegular
package:flutter/…/services/hardware_keyboard.dart:452
#4 HardwareKeyboard.handleKeyEvent
package:flutter/…/services/hardware_keyboard.dart:544
#5 KeyEventManager.handleRawKeyMessage
package:flutter/…/services/hardware_keyboard.dart:821
#6 BasicMessageChannel.setMessageHandler.<anonymous closure>
package:flutter/…/services/platform_channel.dart:77
#7 BasicMessageChannel.setMessageHandler.<anonymous closure>
package:flutter/…/services/platform_channel.dart:76
#8 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure>
package:flutter/…/services/binding.dart:389
#9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure>
package:flutter/…/services/binding.dart:386
#10 _invoke2.<anonymous closure> (dart:ui/hooks.dart:189:15)
#14 _invoke2 (dart:ui/hooks.dart:188:10)
#15 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#16 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#17 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#18 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#19 _dispatchPlatformMessage (dart:ui/hooks.dart:83:31)
(elided 5 frames from class _AssertionError and dart:async)
════════════════════════════════════════════════════════════════════════════════
** (counter:4580): WARNING **: 12:21:53.623: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key. 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: KeyUpEvent#21f5f(physicalKey: PhysicalKeyboardKey#7001f(usbHidUsage: "0x0007001f", debugName: "Digit 2"), logicalKey: LogicalKeyboardKey#00032(keyId: "0x00000032", keyLabel: "2", debugName: "Digit 2"), character: null, timeStamp: 0:10:23.621000) and the recorded logical key LogicalKeyboardKey#00040(keyId: "0x00000040", keyLabel: "@", debugName: "At")
'package:flutter/src/services/hardware_keyboard.dart':
package:flutter/…/services/hardware_keyboard.dart:1
Failed assertion: line 444 pos 16: '_pressedKeys[event.physicalKey] == event.logicalKey'
════════════════════════════════════════════════════════════════════════════════
** (counter:4580): WARNING **: 12:21:53.786: Unable to retrieve framework response: Message is not valid JSON
logs (master)
Restarted application in 430ms.
** (counter:6870): CRITICAL **: 12:37:54.805: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) == 0' failed
════════ Exception caught by services library ══════════════════════════════════
The following assertion was thrown during a platform message callback:
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 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>
#3 HardwareKeyboard._assertEventIsRegular
#4 HardwareKeyboard.handleKeyEvent
#5 KeyEventManager.handleRawKeyMessage
#6 BasicMessageChannel.setMessageHandler.<anonymous closure>
#7 BasicMessageChannel.setMessageHandler.<anonymous closure>
#8 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure>
#9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure>
#10 _invoke2.<anonymous closure> (dart:ui/hooks.dart:190:15)
#14 _invoke2 (dart:ui/hooks.dart:189:10)
#15 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#16 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#17 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#18 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:583:22)
#19 _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 5 frames from class _AssertionError and dart:async)
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:37:54.856: Unable to retrieve framework response: Message is not valid JSON
** (counter:6870): WARNING **: 12:37:55.008: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): CRITICAL **: 12:37:55.088: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) == 0' failed
** (counter:6870): WARNING **: 12:37:55.092: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:37:55.226: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): CRITICAL **: 12:37:55.300: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) == 0' failed
** (counter:6870): WARNING **: 12:37:55.307: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:37:55.606: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:37:59.941: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.499: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.512: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.595: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.642: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.661: Unable to retrieve framework response: Message is not valid JSON
** (counter:6870): WARNING **: 12:38:04.744: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.763: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.771: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.863: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.871: Unable to retrieve framework response: Message is not valid JSON
** (counter:6870): WARNING **: 12:38:04.910: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
** (counter:6870): WARNING **: 12:38:04.942: Unable to retrieve framework response: Message is not valid JSON
** (counter:6870): WARNING **: 12:38:05.056: Unable to retrieve framework response: Message is not valid JSON
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#9ac96(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 0:26:25.016000, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
════════════════════════════════════════════════════════════════════════════════
flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on Ubuntu 20.04.3 LTS 5.11.0-43-generic, locale en_GB.UTF-8)
• Flutter version 2.8.1 at /home/mahesh/Development/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (3 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /home/mahesh/Android/Sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/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 google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[✓] Android Studio (version 2020.3)
• Android Studio at /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio
• Flutter plugin version 63.2.1
• Dart plugin version 203.8452
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /usr/share/code
• Flutter extension version 3.29.0
[✓] Connected device (3 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.3 LTS 5.11.0-43-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
• No issues found!
mahesh@mahesh:~/Desktop/counter$ flutterm doctor -v
[✓] Flutter (Channel master, 2.9.0-1.0.pre.244, on Ubuntu 20.04.3 LTS 5.11.0-43-generic, locale en_GB.UTF-8)
• Flutter version 2.9.0-1.0.pre.244 at /home/mahesh/Development/master
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7444ad8da4 (74 minutes ago), 2022-01-04 22:00:40 -0800
• Engine revision a6ce607b13
• Dart version 2.16.0 (build 2.16.0-134.0.dev)
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /home/mahesh/Android/Sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/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 google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[✓] Android Studio (version 2020.3)
• Android Studio at /home/mahesh/Downloads/android-studio-2020.3.1.25-linux/android-studio
• Flutter plugin version 63.2.1
• Dart plugin version 203.8452
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /usr/share/code
• Flutter extension version 3.32.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.3 LTS 5.11.0-43-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
/cc @dkwingsmt
This issue is reproducible on web too on both stable and master.
logs (web)
mahesh@mahesh:~/Desktop/counter$ flutter run -d chrome
Running "flutter pub get" in counter... 2,144ms
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 19.4s
This app is linked to the debug service: ws://127.0.0.1:44405/A27ah1NR6TU=/ws
Debug service listening on ws://127.0.0.1:44405/A27ah1NR6TU=/ws
💪 Running with sound null safety 💪
🔥 To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".
An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:44405/A27ah1NR6TU=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:44405/A27ah1NR6TU=
══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown during a platform message callback:
Assertion failed:
file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
_pressedKeys.containsKey(event.physicalKey)
"A KeyUpEvent 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: KeyUpEvent#4f05b(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: \"0x000700e2\",
debugName: \"Alt Left\"), logicalKey: LogicalKeyboardKey#4b191(keyId: \"0x200000106\", keyLabel:
\"Meta Left\", debugName: \"Meta Left\"), character: null, timeStamp: 0:00:09.846299, synthesized)"
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49 throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed
packages/flutter/src/services/hardware_keyboard.dart 441:46 <fn>
packages/flutter/src/services/hardware_keyboard.dart 451:14 [_assertEventIsRegular]
packages/flutter/src/services/hardware_keyboard.dart 544:5 handleKeyEvent
packages/flutter/src/services/hardware_keyboard.dart 821:57 handleRawKeyMessage
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter/src/services/hardware_keyboard.dart 808:51 handleRawKeyMessage
packages/flutter/src/services/platform_channel.dart 77:49 <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter/src/services/platform_channel.dart 76:58 <fn>
packages/flutter/src/services/binding.dart 377:35 <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter/src/services/binding.dart 374:98 <fn>
lib/_engine/engine/platform_dispatcher.dart 1042:13 invoke2
lib/ui/src/ui/channel_buffers.dart 25:12 invoke
lib/ui/src/ui/channel_buffers.dart 65:7 push
lib/ui/src/ui/channel_buffers.dart 130:16 push
lib/_engine/engine/platform_dispatcher.dart 304:25 invokeOnPlatformMessage
lib/_engine/engine/keyboard.dart 130:39 [_handleHtmlEvent]
lib/_engine/engine/keyboard.dart 39:7 <fn>
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Another exception was thrown: Assertion failed: file:///home/mahesh/Development/master/packages/flutter/lib/src/services/hardware_keyboard.dart:441:16
Looks like the original issue is fixed and ShiftLeft issue https://github.com/flutter/flutter/issues/96082#issuecomment-1005438510 reproduced on master is from https://github.com/flutter/flutter/issues/91345, once it is triggered, pressing any key throws exception
This also happens in the iOS Simulator. I don't have to type anything. Just clicking into a text field will cause this error to happen.
Update: Been using the same code on windows(Haven't changed a character), the crashes are less but they are still there. I also found the issue when I use an external hand held bar code scanner to scan a 1D bar code. As for an example if the value of the bar code is GR13 the textfield will recieve GR!#(! and # are the two special characters on 1 and 3). I'm not sure if this is caused by the same problem or not.
@IceBreakerG, Please follow up here https://github.com/flutter/flutter/issues/96277 (IOS specific issue). Also if you can add steps to reproduce the issue along with the output of flutter doctor -v
on that issue. That would be great.
Any progress on this? We are having this issue in development all the time on iOS simulator
I'm having the same problem with the web. A quick improvement is needed.
TextField
Error: Assertion failed: file:///C:/Dev/flutter/packages/flutter/lib/src/services/hardware_keyboard.dart:444:16
_pressedKeys[event.physicalKey] == event.logicalKey
"A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key. 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: KeyUpEvent#d855c(physicalKey: PhysicalKeyboardKey#70037(usbHidUsage: \"0x00070037\", debugName: \"Period\"), logicalKey: LogicalKeyboardKey#0002e(keyId: \"0x0000002e\", keyLabel: \".\", debugName: \"Period\"), character: null, timeStamp: 0:11:41.847899, synthesized) and the recorded logical key LogicalKeyboardKey#602a3(keyId: \"0x10000070f\", keyLabel: \"Process\", debugName: \"Process\")"
at Object.throw_ [as throw] (http://localhost:49853/dart_sdk.js:5080:11)
at Object.assertFailed (http://localhost:49853/dart_sdk.js:5005:15)
at http://localhost:49853/packages/flutter/src/services/restoration.dart.lib.js:5444:98
at [_assertEventIsRegular] (http://localhost:49853/packages/flutter/src/services/restoration.dart.lib.js:5449:26)
at hardware_keyboard.HardwareKeyboard.new.handleKeyEvent (http://localhost:49853/packages/flutter/src/services/restoration.dart.lib.js:5503:34)
at hardware_keyboard.KeyEventManager.new.handleKeyData (http://localhost:49853/packages/flutter/src/services/restoration.dart.lib.js:5662:40)
at http://localhost:49853/dart_sdk.js:171955:47
at Object.invoke (http://localhost:49853/dart_sdk.js:191736:7)
at _engine.EnginePlatformDispatcher.__.invokeOnKeyData (http://localhost:49853/dart_sdk.js:171955:17)
at [_onKeyData] (http://localhost:49853/dart_sdk.js:170642:49)
at http://localhost:49853/dart_sdk.js:171008:21
at [_handleEvent] (http://localhost:49853/dart_sdk.js:170935:51)
at _engine.KeyboardConverter.new.handleEvent (http://localhost:49853/dart_sdk.js:171011:27)
at http://localhost:49853/dart_sdk.js:170648:76
at loggedHandler (http://localhost:49853/dart_sdk.js:170625:18)
Same, iOS simulator it has to do with the rate of typing. If I type fast the issue happens.
The same problem is here. In stable flutter 3.3.0. Is there any developer who has a workaround? Developers whose native language is not English must be annoyed.
Here is the stacktrace:
** (demo_flutter_admin:101594): CRITICAL **: 16:11:32.338: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) == 0' failed
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/services/hardware_keyboard.dart': Failed assertion: line 428 pos 16: '!_pressedKeys.containsKey(event.physicalKey)': A KeyDownEvent is dispatched, but the state shows that the physical key is already 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: KeyDownEvent#84cf9(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 6:17:44.597000, synthesized)
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:428: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.handleKeyData (package:flutter/src/services/hardware_keyboard.dart:808:29)
#6 PlatformDispatcher._keyDataListener.<anonymous closure>.<anonymous closure> (dart:ui/platform_dispatcher.dart:410:41)
#7 _invoke1 (dart:ui/hooks.dart:167:13)
To make it clear this issue is only about using Alt+Shift on Linux, I removed the web label. I reopened https://github.com/flutter/flutter/issues/113836 for AltGr issue on web.
Same problem on Windows after press shift
key:
A KeyUpEvent 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: KeyUpEvent#511cd(physicalKey: PhysicalKeyboardKey#00036(usbHidUsage: "0x1600000036", debugName: "Key with ID 0x1600000036"), logicalKey: LogicalKeyboardKey#00103(keyId: "0x200000103", keyLabel: "Shift Right", debugName: "Shift Right"), character: null, timeStamp: 20:27:20.877441)
'package:flutter/src/services/hardware_keyboard.dart':
package:flutter/…/services/hardware_keyboard.dart:1
Failed assertion: line 432 pos 16: '_pressedKeys.containsKey(event.physicalKey)'
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.