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 "2" key on keyboard produces error #92

Closed
barribarrier opened this issue Apr 12, 2022 · 7 comments
Closed

Pressing "2" key on keyboard produces error #92

barribarrier opened this issue Apr 12, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@barribarrier
Copy link

Flutter version: 2.10.3

flutter-elinux create keyboard_test
cd keyboard_test
flutter-elinux run

Press "2" key (not numpad) on keyboard.

Launching lib/main.dart on eLinux in debug mode...
Building an eLinux application with wayland backend in debug mode for x64 target...        15.1s
Syncing files to device eLinux...                                  348ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

💪 Running with sound null safety 💪

An Observatory debugger and profiler on eLinux is available at: http://127.0.0.1:40117/q_XKyqr8RUQ=/
The Flutter DevTools debugger and profiler on eLinux is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:40117/q_XKyqr8RUQ=/

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown during a platform message callback:
Attempted to send a key down event when no keys are in keysPressed. This state can occur if the key
event being sent doesn't properly set its modifier flags. This was the event:
RawKeyDownEvent#57305(logicalKey: LogicalKeyboardKey#00032(keyId: "0x00000032", keyLabel: "2",
debugName: "Digit 2"), physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName:
"Shift Left"), repeat: false) and its data: RawKeyEventDataLinux#b18e7(toolkit: GLFW,
unicodeScalarValues: 50, scanCode: 50, keyCode: 50, modifiers: 0, isDown: true)
'package:flutter/src/services/raw_keyboard.dart':
Failed assertion: line 685 pos 7: 'event is! RawKeyDownEvent || _keysPressed.isNotEmpty'

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      RawKeyboard.handleRawKeyEvent (package:flutter/src/services/raw_keyboard.dart:685:7)
#3      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:818:33)
#4      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:77:49)
#5      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:76:47)
#6      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:377:35)
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:374:46)
#8      _invoke2.<anonymous closure> (dart:ui/hooks.dart:190:15)
#12     _invoke2 (dart:ui/hooks.dart:189:10)
#13     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#14     _Channel.push (dart:ui/channel_buffers.dart:132:31)
#15     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#16     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:583:22)
#17     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)
(elided 5 frames from class _AssertionError and dart:async)

No error is produced when running the same project with flutter linux.

flutter run -d linux
@barribarrier
Copy link
Author

More debugging:

With this code

RawKeyboardListener(
  autofocus: true,
  focusNode: FocusNode(),
  onKey: (event) {
    print(event);
  },
  child: Text('Test'),
),

when I press "1", it prints this:

flutter: RawKeyDownEvent#cea90(logicalKey: LogicalKeyboardKey#00031(keyId: "0x00000031", keyLabel: "1", debugName: "Digit 1"), physicalKey: PhysicalKeyboardKey#70035(usbHidUsage: "0x00070035", debugName: "Backquote"), repeat: false)
flutter: RawKeyUpEvent#3d2af(logicalKey: LogicalKeyboardKey#00031(keyId: "0x00000031", keyLabel: "1", debugName: "Digit 1"), physicalKey: PhysicalKeyboardKey#70035(usbHidUsage: "0x00070035", debugName: "Backquote"))

when I press "3":

flutter: RawKeyDownEvent#758d1(logicalKey: LogicalKeyboardKey#00033(keyId: "0x00000033", keyLabel: "3", debugName: "Digit 3"), physicalKey: PhysicalKeyboardKey#70031(usbHidUsage: "0x00070031", debugName: "Backslash"), repeat: false)
flutter: RawKeyUpEvent#d9b22(logicalKey: LogicalKeyboardKey#00033(keyId: "0x00000033", keyLabel: "3", debugName: "Digit 3"), physicalKey: PhysicalKeyboardKey#70031(usbHidUsage: "0x00070031", debugName: "Backslash"))

when I press "4":

flutter: RawKeyDownEvent#1c337(logicalKey: LogicalKeyboardKey#00034(keyId: "0x00000034", keyLabel: "4", debugName: "Digit 4"), physicalKey: PhysicalKeyboardKey#7001d(usbHidUsage: "0x0007001d", debugName: "Key Z"), repeat: false)
flutter: RawKeyUpEvent#60a92(logicalKey: LogicalKeyboardKey#00034(keyId: "0x00000034", keyLabel: "4", debugName: "Digit 4"), physicalKey: PhysicalKeyboardKey#7001d(usbHidUsage: "0x0007001d", debugName: "Key Z"))

@barribarrier
Copy link
Author

Pressing "Shift + 2" aka: "@"

══╡ 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#d8c5b(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1",
debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel:
"Shift Left", debugName: "Shift Left"), character: null, timeStamp: 9:01:18.604940, 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> (package:flutter/src/services/hardware_keyboard.dart:437:16)
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:544:5)
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35)
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:77:49)
#7      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:76:47)
#8      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:377:35)
#9      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:374:46)
#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)
════════════════════════════════════════════════════════════════════════════════════════════════════

Then any further key presses produces this error:

Another exception was thrown: 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#d8c5b(physicalKey:
PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId:
"0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 9:01:18.604940, synthesized)

@barribarrier
Copy link
Author

From the debug messages, it looks like PhysicalKeyboardKey' is getting mapped to a wrong key. Maybe something wrong with the GLFW key handling?

@barribarrier
Copy link
Author

Might be related/helpful
go-flutter-desktop/go-flutter#539

@HidenoriMatsubayashi HidenoriMatsubayashi added the bug Something isn't working label Apr 12, 2022
@HidenoriMatsubayashi
Copy link
Collaborator

HidenoriMatsubayashi commented Apr 12, 2022

Thank you for reporting the bug. It seems like a flutter-elinux tools bug?

@barribarrier
Copy link
Author

Hi @HidenoriMatsubayashi

Have you identified the bug yet? May I ask if this will get fixed or not?

Thank you.

@barribarrier
Copy link
Author

Moved to sony/flutter-embedded-linux#261. Don't think it is flutter-elinux bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants