Repository: flutter
Issue: Critical error on Linux desktop: assertion 'lookup_hash_table(self->pressing_records, physical_key) != 0' failed
Labels: a: text input,engine,platform-linux,a: desktop,P2,team-text-input,triaged-text-input

### Steps to reproduce

- Run the code in debug mode on Linux.
- Input, paste, delete some text from the text box. I'm not quite clear what actions triggerred the errors but it's fairly easy to trigger. One sequence that consistently triggers the error is: paste some text using ctrl-V -> delete any character from the end using backspace.

### Expected results

No error.

### Actual results

Tons of errors:
```
** (text_field_test:353067): CRITICAL **: 14:40:20.078: void update_pressing_state(FlKeyEmbedderResponder *, uint64_t, uint64_t): assertion 'lookup_hash_table(self->pressing_records, physical_key) != 0' failed
```

And if I ignore the error, the text box acts wierdly. It feels like ctrl key is being hold. For example, if I press `a`, it will select all the text. If I press backspace, it will delete a whole word.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: MainScreen(),
    );
  }
}

class MainScreen extends StatelessWidget {
  const MainScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Test'),
      ),
      body: const Row(
        children: [
          Expanded(
            child: TextField(),
          ),
        ],
      ),
    );
  }
}
```

</details>


### Screenshots or Video

[Screencast_20240616_143424.webm](https://github.com/flutter/flutter/assets/889871/45e5a96b-a32d-49bc-8311-9d0505778115)


### Logs

Output of `flutter --verbose run -d Linux`:
[flutter_run_log.txt](https://github.com/user-attachments/files/15859918/flutter_run_log.txt)



### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.0, on Arch Linux 6.9.4-arch1-1, locale en_US.UTF-8)
    • Flutter version 3.22.0 on channel stable at /home/cuihao/opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (5 weeks ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/cuihao/opt/Android-Sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /home/cuihao/opt/Android-Sdk
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/google-chrome-stable

[✓] Linux toolchain - develop for Linux desktop
    • clang version 17.0.6
    • cmake version 3.29.5
    • ninja version 1.12.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2023.3)
    • Android Studio at /opt/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 17.0.10+0-17.0.10b1087.21-11572160)

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Arch Linux 6.9.4-arch1-1
    • Chrome (web)    • chrome • web-javascript • Google Chrome 126.0.6478.61

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>