Repository navigation
Hot restart breaks keyboard input #87391
Copy link
Copy link
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: desktopRunning on desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamOwned by Text Input team
Description
Steps to reproduce:
- Create an app with a TextField.
- Launch the app with
flutter run -d linux. - Type in the text field. This works fine.
- Hot restart the app.
- Type in the text field. This fails with:
** (fwml:2822048): WARNING **: 22:35:22.785: 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 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#5dafa(physicalKey: PhysicalKeyboardKey#700e7(usbHidUsage: "0x000700e7", debugName:
"Meta Right"), logicalKey: LogicalKeyboardKey#0010e(keyId: "0x10000010e", keyLabel: "Super",
debugName: "Super"), character: null, timeStamp: 1115:12:48.298000)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 441 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:441:16)
#3 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543: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:73:49)
#7 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#8 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35)
#9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46)
#10 _invoke2.<anonymous closure> (dart:ui/hooks.dart:203:15)
#14 _invoke2 (dart:ui/hooks.dart:202: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:536:22)
#19 _dispatchPlatformMessage (dart:ui/hooks.dart:90:31)
(elided 5 frames from class _AssertionError and dart:async)
════════════════════════════════════════════════════════════════════════════════════════════════════
Reactions are currently unavailable
Metadata
Metadata
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: desktopRunning on desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamOwned by Text Input team
Type
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsDone (PR merged)
Activity
goderbauer commentedon Aug 3, 2021
/cc @dkwingsmt
Andreigr0 commentedon Sep 14, 2021
Faced this issue on macOS (Apple M1) too on latest stable Flutter build 2.5.0
gidrokolbaska commentedon Sep 16, 2021
Same. Flutter 2.5.0, macos m1, throws error
dkwingsmt commentedon Sep 20, 2021
This is probably fixed on master with #88967. Let me know if it still occurs. (We'll probably cherrypick the fix into the next fix version.)lordarcadius commentedon Sep 20, 2021
@dkwingsmt Hey, I just tried it on dev channel but I am still facing the issue when I press a key on my Flutter web app!
════════ Exception caught by services library ══════════════════════════════════ Assertion failed: ../…/services/hardware_keyboard.dart:441 _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 inHardwareKeyboard`. This was the event: KeyUpEvent#29652(physicalKey: PhysicalKeyboardKey#700e3(usbHidUsage: "0x000700e3", debugName: "Meta Left"), logicalKey: LogicalKeyboardKey#4b191(keyId: "0x200000106", keyLabel: "Meta Left", debugName: "Meta Left"), character: null, timeStamp: 0:00:10.749000, synthesized)"════════════════════════════════════════════════════════════════════════════════`
This is the error I get.
SadiqMH commentedon Sep 24, 2021
I got the same error, but in my case, the key label is "Alt Left". It shows whenever I press any key on the keyboard, not just Alt Left.
The app isn't crashing, but keeps throwing this error.
Ali1Ammar commentedon Sep 25, 2021
same error
jpnurmi commentedon Sep 25, 2021
On Linux with latest Flutter master:
flutter create .flutter runFailed assertion: line 441 pos 16: '_pressedKeys.containsKey(event.physicalKey)'full output
It's specifically Alt+Tab out plus hot restart where the keyboard state machine breaks. For example, a mouse click on the terminal, hot restart, and Alt+Tab back to the app does not trigger the error.
edwardaux commentedon Sep 26, 2021
💯 this is the case for me too!
79 remaining items
flutter-triage-bot commentedon Jul 8, 2023
This issue is assigned but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
bleroux commentedon Jul 11, 2023
Monthly update:
I plan to work on Windows implementation during this summer.
[macOS] Return keyboard pressed state (#42878)
[Windows] Return keyboard pressed state (#43998)
bleroux commentedon Aug 10, 2023
Closing this issue because the work described in #87391 (comment) has landed:
There is still one known issue related to keyboard and hot restart, see #125975.
For anyone still encountering keyboard related error messages.
Multiplatform keyboard support is complex. The error messages (which are mainly warnings) could be annoying but they are helpful to isolate and fix edge cases.
When searching existing bugs or filing a new one, thank you to answer the following questions:
github-actions commentedon Aug 24, 2023
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 -vand a minimal reproduction of the issue.