Skip to content

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

@p1318k

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!

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 consolef: material designflutter/packages/flutter/material repository.found 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 onr: 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