Skip to content

TextInput.attach causes crash on macOS with Flutter 3.32.0 #169204

Closed
@Amir-P

Description

@Amir-P

Steps to reproduce

  1. Run the sample code
  2. Press on FAB

Expected results

The connection should be created with the text input control as with Flutter 3.29.x.

Actual results

The app crashes.

Code sample

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

void main() {
  runApp(MaterialApp(
    debugShowCheckedModeBanner: false,
    theme: ThemeData.light(),
    home: const HomePage(),
  ));
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final client = _TextInputClient();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Demo')),
      floatingActionButton: FloatingActionButton(
        onPressed: () => client.openConnection(),
        child: const Icon(Icons.warning),
      ),
    );
  }
}

class _TextInputClient with TextInputClient {
  void openConnection() {
    TextInput.attach(this, TextInputConfiguration());
  }

  @override
  void connectionClosed() {}

  @override
  AutofillScope? get currentAutofillScope => throw UnimplementedError();

  @override
  TextEditingValue? get currentTextEditingValue => throw UnimplementedError();

  @override
  void performAction(TextInputAction action) {}

  @override
  void performPrivateCommand(String action, Map<String, dynamic> data) {}

  @override
  void showAutocorrectionPromptRect(int start, int end) {}

  @override
  void updateEditingValue(TextEditingValue value) {}

  @override
  void updateFloatingCursor(RawFloatingCursorPoint point) {}
}

Screenshots or Video

No response

Logs

Logs
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull longLongValue]: unrecognized selector sent to instance 0x1f57ec4a0'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018564ddf0 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x0000000185112b60 objc_exception_throw + 88
	2   CoreFoundation                      0x000000018570ace0 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00000001855bbefc ___forwarding___ + 1500
	4   CoreFoundation                      0x00000001855bb860 _CF_forwarding_prep_0 + 96
	5   FlutterMacOS                        0x0000000103ebde34 -[FlutterTextInputPlugin handleMethodCall:result:] + 2324
	6   FlutterMacOS                        0x0000000104b734b4 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 180
	7   FlutterMacOS                        0x0000000103ea6748 -[FlutterEngine engineCallbackOnPlatformMessage:] + 416
	8   FlutterMacOS                        0x0000000104777024 _ZNSt3_fl10__function6__funcIZ23FlutterEngineInitializeE3$_3NS_9allocatorIS2_EEFvNS_10unique_ptrIN7flutter15PlatformMessageENS_14default_deleteIS7_EEEEEEclEOSA_ + 128
	9   FlutterMacOS                        0x000000010478a7f4 _ZN7flutter20PlatformViewEmbedder21HandlePlatformMessageENSt3_fl10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 76
	10  FlutterMacOS                        0x000000010478b384 _ZNSt3_fl10__function6__funcIN3fml8internal14CopyableLambdaIZN7flutter20PlatformViewEmbedder30EmbedderPlatformMessageHandler21HandlePlatformMessageENS_10unique_ptrINS5_15PlatformMessageENS_14defa	11  FlutterMacOS                        0x00000001047873c4 _ZN7flutter18EmbedderTaskRunner8PostTaskEy + 652
	12  FlutterMacOS                        0x000000010477b95c _ZN7flutter14EmbedderEngine7RunTaskEPK11FlutterTask + 56
	13  FlutterMacOS                        0x000000010476e890 FlutterEngineRunTask + 68
	14  FlutterMacOS                        0x0000000103ea9aa8 __60-[FlutterEngine postMainThreadTask:targetTimeInNanoseconds:]_block_invoke + 72
	15  FlutterMacOS                        0x0000000103eb9734 -[FlutterRunLoop performExpiredTasks] + 524
	16  CoreFoundation                      0x00000001855dcde4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
	17  CoreFoundation                      0x00000001855dcd78 __CFRunLoopDoSource0 + 172
	18  CoreFoundation                      0x00000001855dcae4 __CFRunLoopDoSources0 + 232
	19  CoreFoundation                      0x00000001855db738 __CFRunLoopRun + 840
	20  CoreFoundation                      0x00000001855dad68 CFRunLoopRunSpecific + 572
	21  HIToolbox                           0x0000000190d8b27c RunCurrentEventLoopInMode + 324
	22  HIToolbox                           0x0000000190d8e4e8 ReceiveNextEventCommon + 676
	23  HIToolbox                           0x0000000190f19484 _BlockUntilNextEventMatchingListInModeWithFilter + 76
	24  AppKit                              0x000000018922dab4 _DPSNextEvent + 684
	25  AppKit                              0x0000000189bcacd4 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
	26  AppKit                              0x0000000189220c64 -[NSApplication run] + 480
	27  AppKit                              0x00000001891f735c NSApplicationMain + 880
	28  example.debug.dylib                 0x00000001008ff838 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ + 40
	29  example.debug.dylib                 0x00000001008ff800 $s7example11AppDelegateC5$mainyyFZ + 44
	30  example.debug.dylib                 0x00000001008ff8a0 __debug_main_executable_dylib_entry_point + 28
	31  dyld                                0x0000000185152b4c start + 6000
)
libc++abi: terminating due to uncaught exception of type NSException

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.4 24E248 darwin-arm64, locale
    en-US) [1,391ms]
    • Flutter version 3.32.0 on channel stable at
      /fvm/versions/3.32.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (2 days ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [3.8s]
    • Android SDK at /SDK
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /SDK
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on
      this machine.
      To manually set the JDK path, use: `flutter config
      --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,499ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [11ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [11ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 21.0.5+-13047016-b750.29)

[✓] VS Code (version 1.100.2) [9ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (2 available) [11.3s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 136.0.7103.114

[✓] Network resources [1,568ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions