Skip to content

Crashes when inputting letters and arrow keys at the same time in TextField #139196

Closed

Description

@p1318k

Is there an existing issue for this?

Steps to reproduce

Steps to reproduce the issue.

  1. flutter create example
  2. replace 'Text' widget to 'TextField'
  3. type letters, arrow keys at the same time in 'TextField'

Tested Enviroments

Tested Enviroments
  • device type : M1 MacBook Pro
  • macOS version : Sonoma 14.1.1

Logs

Logs
════════ Exception caught by services library ══════════════════════════════════
The following assertion was thrown during method call TextInputClient.performSelectors:
Range start 41 is out of text of length 40
'package:flutter/src/services/text_input.dart':
Failed assertion: line 960 pos 12: 'range.start >= 0 && range.start <= text.length'

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.yml

When the exception was thrown, this was the stack:
#2      TextEditingValue._textRangeIsValid (package:flutter/src/services/text_input.dart:960:12)
#3      TextEditingValue.toJSON (package:flutter/src/services/text_input.dart:915:12)
#4      _PlatformTextInputControl.setEditingState (package:flutter/src/services/text_input.dart:2262:13)
#5      TextInput._setEditingState (package:flutter/src/services/text_input.dart:1951:15)
#6      TextInputConnection.setEditingState (package:flutter/src/services/text_input.dart:1375:25)
#7      EditableTextState._updateRemoteEditingValueIfNeeded (package:flutter/src/widgets/editable_text.dart:3304:27)
#8      EditableTextState.endBatchEdit (package:flutter/src/widgets/editable_text.dart:3293:5)
#9      EditableTextState._formatAndSetValue (package:flutter/src/widgets/editable_text.dart:3844:5)
#10     EditableTextState.userUpdateTextEditingValue (package:flutter/src/widgets/editable_text.dart:4179:5)
#11     EditableTextState._updateSelection (package:flutter/src/widgets/editable_text.dart:4665:5)
#12     CallbackAction.invoke (package:flutter/src/widgets/actions.dart:597:39)
#13     Action._invoke (package:flutter/src/widgets/actions.dart:338:17)
#14     ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:641:19)
#15     Actions.invoke.<anonymous closure> (package:flutter/src/widgets/actions.dart:963:48)
#16     Actions._visitActionsAncestors (package:flutter/src/widgets/actions.dart:745:18)
#17     Actions.invoke (package:flutter/src/widgets/actions.dart:957:30)
#18     _UpdateTextSelectionVerticallyAction.invoke (package:flutter/src/widgets/editable_text.dart:5565:13)
#19     _OverridableContextAction.invokeDefaultAction (package:flutter/src/widgets/actions.dart:1811:28)
#20     _OverridableActionMixin.invoke (package:flutter/src/widgets/actions.dart:1676:9)
#21     Action._invoke (package:flutter/src/widgets/actions.dart:336:19)
#22     ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:641:19)
#23     Actions.invoke.<anonymous closure> (package:flutter/src/widgets/actions.dart:963:48)
#24     Actions._visitActionsAncestors (package:flutter/src/widgets/actions.dart:745:18)
#25     Actions.invoke (package:flutter/src/widgets/actions.dart:957:30)
#26     EditableTextState.performSelector (package:flutter/src/widgets/editable_text.dart:4347:17)
#27     ListBase.forEach (dart:collection/list.dart:51:13)
#28     TextInput._handleTextInputInvocation (package:flutter/src/services/text_input.dart:1880:19)
#29     TextInput._loudlyHandleTextInputInvocation (package:flutter/src/services/text_input.dart:1759:20)
#30     MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:559:55)
#31     MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:552:34)
#32     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:567:35)
#33     _invoke2 (dart:ui/hooks.dart:344:13)
#34     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
#35     _Channel.push (dart:ui/channel_buffers.dart:135:31)
#36     ChannelBuffers.push (dart:ui/channel_buffers.dart:343:17)
#37     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:722:22)
#38     _dispatchPlatformMessage (dart:ui/hooks.dart:257:31)
(elided 2 frames from class _AssertionError)

call: MethodCall(TextInputClient.performSelectors, [1, [moveDown:]])
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by services library ══════════════════════════════════
Range start 48 is out of text of length 47
'package:flutter/src/services/text_input.dart':
Failed assertion: line 960 pos 12: 'range.start >= 0 && range.start <= text.length'
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by services library ══════════════════════════════════
Range start 68 is out of text of length 67
'package:flutter/src/services/text_input.dart':
Failed assertion: line 960 pos 12: 'range.start >= 0 && range.start <= text.length'
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by services library ══════════════════════════════════
Range start 71 is out of text of length 70
'package:flutter/src/services/text_input.dart':
Failed assertion: line 960 pos 12: 'range.start >= 0 && range.start <= text.length'
════════════════════════════════════════════════════════════════════════════════

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.1, on macOS 14.1.1 23B81 darwin-arm64, locale en-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
[✓] VS Code (version 1.84.2)
[✓] Connected device (2 available)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated
      with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

Activity

  1. added
    in triagePresently being triaged by the triage team
    on Nov 29, 2023
  2. huycozy commented on Nov 29, 2023

    @huycozy
    Member

    Thanks for the report. I also can reproduce this on macOS and Android platforms whilst it doesn't occur on Web.

    Looking at the stack trace, a part of it is similar to #139201.

    Reproduced this on the latest stable and master channel. It also appears on the previous release 3.13.9.

    Exception log
    ======== Exception caught by services library ======================================================
    The following assertion was thrown during method call TextInputClient.performSelectors:
    Range start 31 is out of text of length 30
    'package:flutter/src/services/text_input.dart':
    Failed assertion: line 960 pos 12: 'range.start >= 0 && range.start <= text.length'
    
    
    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.yml
    
    When the exception was thrown, this was the stack: 
    #2      TextEditingValue._textRangeIsValid (package:flutter/src/services/text_input.dart:960:12)
    #3      TextEditingValue.toJSON (package:flutter/src/services/text_input.dart:915:12)
    #4      _PlatformTextInputControl.setEditingState (package:flutter/src/services/text_input.dart:2262:13)
    #5      TextInput._setEditingState (package:flutter/src/services/text_input.dart:1951:15)
    #6      TextInputConnection.setEditingState (package:flutter/src/services/text_input.dart:1375:25)
    #7      EditableTextState._updateRemoteEditingValueIfNeeded (package:flutter/src/widgets/editable_text.dart:3304:27)
    #8      EditableTextState.endBatchEdit (package:flutter/src/widgets/editable_text.dart:3293:5)
    #9      EditableTextState._formatAndSetValue (package:flutter/src/widgets/editable_text.dart:3844:5)
    #10     EditableTextState.userUpdateTextEditingValue (package:flutter/src/widgets/editable_text.dart:4179:5)
    #11     EditableTextState._updateSelection (package:flutter/src/widgets/editable_text.dart:4665:5)
    #12     CallbackAction.invoke (package:flutter/src/widgets/actions.dart:597:39)
    #13     Action._invoke (package:flutter/src/widgets/actions.dart:338:17)
    #14     ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:641:19)
    #15     Actions.invoke.<anonymous closure> (package:flutter/src/widgets/actions.dart:963:48)
    #16     Actions._visitActionsAncestors (package:flutter/src/widgets/actions.dart:745:18)
    #17     Actions.invoke (package:flutter/src/widgets/actions.dart:957:30)
    #18     _UpdateTextSelectionVerticallyAction.invoke (package:flutter/src/widgets/editable_text.dart:5565:13)
    #19     _OverridableContextAction.invokeDefaultAction (package:flutter/src/widgets/actions.dart:1811:28)
    #20     _OverridableActionMixin.invoke (package:flutter/src/widgets/actions.dart:1676:9)
    #21     Action._invoke (package:flutter/src/widgets/actions.dart:336:19)
    #22     ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:641:19)
    #23     Actions.invoke.<anonymous closure> (package:flutter/src/widgets/actions.dart:963:48)
    #24     Actions._visitActionsAncestors (package:flutter/src/widgets/actions.dart:745:18)
    #25     Actions.invoke (package:flutter/src/widgets/actions.dart:957:30)
    #26     EditableTextState.performSelector (package:flutter/src/widgets/editable_text.dart:4347:17)
    #27     ListBase.forEach (dart:collection/list.dart:51:13)
    #28     TextInput._handleTextInputInvocation (package:flutter/src/services/text_input.dart:1880:19)
    #29     TextInput._loudlyHandleTextInputInvocation (package:flutter/src/services/text_input.dart:1759:20)
    #30     MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:559:55)
    #31     MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:552:34)
    #32     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:567:35)
    #33     _invoke2 (dart:ui/hooks.dart:344:13)
    #34     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
    #35     _Channel.push (dart:ui/channel_buffers.dart:135:31)
    #36     ChannelBuffers.push (dart:ui/channel_buffers.dart:343:17)
    #37     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:722:22)
    #38     _dispatchPlatformMessage (dart:ui/hooks.dart:257:31)
    (elided 2 frames from class _AssertionError)
    call: MethodCall(TextInputClient.performSelectors, [1, [moveDown:]])
    ====================================================================================================
    flutter doctor -v (stable and master)
    [✓] Flutter (Channel stable, 3.16.1, on macOS 14.1 23B74 darwin-x64, locale en-VN)
        • Flutter version 3.16.1 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7f20e5d18c (9 hours ago), 2023-11-27 09:47:30 -0800
        • Engine revision 22b600f240
        • Dart version 3.2.1
        • DevTools version 2.28.3
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15A507
        • CocoaPods version 1.13.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [!] Android Studio (version unknown)
        • Android Studio at /Applications/Android Studio Preview.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
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build 17.0.8+0-17.0.8b1000.22-10799086)
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Applications/Android Studio Giraffe Patch 3.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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] Android Studio (version 2022.2)
        • 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
        • android-studio-dir = /Applications/Android Studio.app/
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.84.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.76.0
    
    [✓] Connected device (3 available)
        • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64  • Android 11 (API 30)
        • macOS (desktop)  • macos            • darwin-x64     • macOS 14.1 23B74 darwin-x64
        • Chrome (web)     • chrome           • web-javascript • Google Chrome 119.0.6045.159
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    [!] Flutter (Channel master, 3.17.0-17.0.pre.47, on macOS 14.1 23B74 darwin-x64, locale en-VN)
        • Flutter version 3.17.0-17.0.pre.47 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7a0508e5de (10 minutes ago), 2023-11-28 22:01:04 -0500
        • Engine revision 4beaa1195b
        • Dart version 3.3.0 (build 3.3.0-170.0.dev)
        • DevTools version 2.30.0-dev.4
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15A507
        • CocoaPods version 1.13.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [!] Android Studio (version unknown)
        • Android Studio at /Applications/Android Studio Preview.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
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build 17.0.8+0-17.0.8b1000.22-10799086)
    
    [✓] Android Studio (version 2022.3)
        • Android Studio at /Applications/Android Studio Giraffe Patch 3.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 17.0.6+0-17.0.6b829.9-10027231)
    
    [✓] Android Studio (version 2022.2)
        • 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
        • android-studio-dir = /Applications/Android Studio.app/
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.84.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.76.0
    
    [✓] Connected device (4 available)
        • RMX2001 (mobile) • EUYTFEUSQSRGDA6D                         • android-arm64  • Android 11 (API 30)
        • iPhone (mobile)  • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios            • iOS 15.8 19H370
        • macOS (desktop)  • macos                                    • darwin-x64     • macOS 14.1 23B74 darwin-x64
        • Chrome (web)     • chrome                                   • web-javascript • Google Chrome 119.0.6045.159
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 2 categories.
  3. changed the title [-][macOS][Desktop]: Crashes when inputting letters and arrow keys at the same time in "TextField"[/-] [+]Crashes when inputting letters and arrow keys at the same time in `TextField`[/+] on Nov 29, 2023
  4. added
    a: text inputEntering text in a text field or keyboard related problems
    c: crashStack traces logged to the console
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    p: material_uimaterial_ui package in flutter/packages
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Nov 29, 2023
  5. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Nov 30, 2023
  6. added a commit that references this issue on Jan 3, 2024
    f3b6505
  7. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 3, 2024
  8. github-actions commented on Jan 17, 2024

    @github-actions

    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 -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consolefound in release: 3.16Found to occur in 3.16found in release: 3.17Found to occur in 3.17frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions