Skip to content

Windows app crash in KeyboardKeyEmbedderHandler::KeyboardHookImpl in monkey test #97789

@tgucio

Description

@tgucio

We're having issues with Windows application crashing silently. It looks like I'm now able to observe this with a simple app with just a text field on Windows 10. Possibly (not sure though) this is triggered when the OS keyboard layout selection pop up is shown but could as well be related to windows switching.

Steps to Reproduce

  1. Enable additional keyboard layouts (so that left Shift + left Alt switch between them and Windows key + space shows the keyboard selection pop up)
  2. Execute flutter run on the code sample (just a text field)
  3. Run a "monkey keyboard stress test" pressing left and right Shift, Alt, Windows, Ctrl buttons with some keys that produce text - completely randomly and often pressing multiple buttons at a time.

Expected results: Application doesn't crash

Actual results: Application crashes

Running WinDbg, the crash happens systematically in FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable. I'll post some traces in a while.

Code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() { _counter++; });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('You have pushed the button this many times:'),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            const Expanded(
              child: TextField(maxLines: null),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
Logs
flutter doctor -v
[√] Flutter (Channel master, 2.10.0-1.0.pre.422, on Microsoft Windows [Version 10.0.19044.1469], locale en-US)
    • Flutter version 2.10.0-1.0.pre.422 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 689462e967 (3 hours ago), 2022-02-04 04:05:18 -0500
    • Engine revision 0ceed87a2d
    • Dart version 2.17.0 (build 2.17.0-79.0.dev)
    • DevTools version 2.10.0

[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


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

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.8)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.32002.261
    • Windows 10 SDK version 10.0.19041.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] VS Code, 64-bit edition (version 1.64.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.34.0

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

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

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.platform-windowsBuilding on or for Windows specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    Status

    Issue closed with comment

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions