Skip to content

RenderEditable.delete is racy #80226

@nt4f04uNd

Description

@nt4f04uNd

i suppose this was introduced in #79973

when framerate is low, spamming delete key may throw

note: example in code sample exaggerated to achieve low framerate on the emulator. on my redmi note 5 this happens all the time in debug mode even with much more trivial examples

logs
  ══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following RangeError was thrown during a platform message callback:
Value not in range: 7
When the exception was thrown, this was the stack:
#0      _StringBase.substring (dart:core-patch/string_patch.dart:399:7)
#1      TextRange.textBefore (dart:ui/text.dart:2750:17)
#2      RenderEditable.delete (package:flutter/src/rendering/editable.dart:1119:37)
#3      _DeleteTextAction.invoke (package:flutter/src/widgets/default_text_editing_actions.dart:88:45)
#4      ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:517:21)
#5      ShortcutManager.handleKeypress (package:flutter/src/widgets/shortcuts.dart:366:36)
#6      _ShortcutsState._handleOnKey (package:flutter/src/widgets/shortcuts.dart:708:20)
#7      FocusManager._handleRawKeyEvent (package:flutter/src/widgets/focus_manager.dart:1678:43)
#8      RawKeyboard._handleKeyEvent (package:flutter/src/services/raw_keyboard.dart:682:69)
#9      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49)
#10     BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#11     _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binding.dart:284:33)
#12     _invoke3.<anonymous closure> (dart:ui/hooks.dart:223:15)
#16     _invoke3 (dart:ui/hooks.dart:222:10)
#17     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:520:7)
#18     _dispatchPlatformMessage (dart:ui/hooks.dart:90:31)
(elided 3 frames from dart:async)
════════════════════════════════════════════════════════════════════════════════════════════════════
code sample
import 'dart:math';
import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  List<double> list;

  @override
  void initState() {
    super.initState();
    _update();
  }

  void _update() {
    setState(() {
      list = List.generate(10000, (index) => Random().nextDouble());
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'System nav back button bug',
      home: SafeArea(
        child: Scaffold(
          body: Center(
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                TextField(
                  onChanged: (_) {
                    _update();
                  },
                ),
                Expanded(
                  child: ListView(
                    children: list
                        .map((el) => ListTile(title: Text(el.toString())))
                        .toList(),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
flutter doctor -v
[✓] Flutter (Channel master, 2.1.0-13.0.pre.574, on Microsoft Windows [Version 10.0.19041.867], locale ru-RU)
    • Flutter version 2.1.0-13.0.pre.574 at c:\dev\src\flutter
    • Framework revision 02efffc134 (33 hours ago), 2021-04-10 03:49:01 -0400
    • Engine revision 8863afff16
    • Dart version 2.13.0 (build 2.13.0-222.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\danya\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[✓] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.3.3
    • 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

[✓] VS Code (version 1.55.1)
    • VS Code at C:\Users\danya\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.21.0

[✓] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19041.867]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 89.0.4389.114
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 89.0.774.63

• No issues found!
video.mp4

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsfound in release: 2.1Found to occur in 2.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: solvedIssue is closed as solved

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions