Skip to content

Infinite loop in Mac text field #77855

Closed
Closed

Description

@justinmc
  1. Run an app on Mac with any sort of text field, such as the example code below.
  2. Click to focus the input.
  3. Quickly hammer down on some keys like "asdf".

The text will oscillate back and forth in the field and the following error will be logged over and over again in the console:

2021-03-10 15:06:45.620 sandbox[35149:395097] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Center(
          child: TextField(),
        ),
      ),
    );
  }
}

Not sure if I or someone else broke this recently or if it's been around awhile. CC @gspencergoog @dkwingsmt

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    platform-macosBuilding on or for macOS specifically
    on Mar 10, 2021
  2. added
    P1High-priority issues at the top of the work list
    on Mar 11, 2021
  3. gspencergoog commented on Mar 11, 2021

    @gspencergoog
    Contributor

    @justinmc I'm unable to repro this. Can you give me some more info about what you're synced to, OS, etc. (Probably just flutter doctor -v would be good enough).

    And how easy is it to repro for you?

  4. justinmc commented on Mar 11, 2021

    @justinmc
    ContributorAuthor

    It's 100% on the first try for me. I'm on a MacBook running Big Sur at v11.2.1 and I just pulled master.

    Screen.Recording.2021-03-11.at.12.36.37.PM.mov
    flutter doctor -v
    [✓] Flutter (Channel master, 2.1.0-11.0.pre.212, on macOS 11.2.1 20D74 darwin-x64, locale en-US)
        • Flutter version 2.1.0-11.0.pre.212 at /Users/jmccandless/Projects/flutter
        • Framework revision c6dbb6f2b5 (74 minutes ago), 2021-03-11 11:25:02 -0800
        • Engine revision 1b68503bc8
        • Dart version 2.13.0 (build 2.13.0-125.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
        • Android SDK at /Users/jmccandless/Library/Android/sdk
        • Platform android-30, build-tools 30.0.1
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode-beta.app/Contents/Developer
        • Xcode 12.5, Build version 12E5220o
        • CocoaPods version 1.10.0
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • 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 1.8.0_242-release-1644-b3-6915495)
    
    [✓] VS Code (version 1.53.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension can be installed from:
          🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.1 20D74 darwin-x64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 89.0.4389.82
    
    • No issues found!
    ➜  sandbox
    
  5. lukepighetti commented on Mar 17, 2021

    @lukepighetti
    Contributor

    Saw this yesterday on dev channel on macOS.

    We're also having issues with flutter_masked_text offsetting the selection when it adds in characters that weren't typed, however this behavior is not present on stable or beta branch. Not sure if it's related.

    I think I've bisected both issues to: b0d4d44 ... will report back when confirmed

    • ✅ macOS infinite loop bisected to b0d4d44
    • ✅ the issue I described with flutter_masked_text is also bisected to b0d4d44

    Revert PR

    #78439

    Repro

    name: issue_77855_b0d4d44
    description: A new Flutter project.
    publish_to: "none"
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.7.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
    
      cupertino_icons: ^1.0.2
      flutter_masked_text: ^0.8.0
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
    flutter:
      uses-material-design: true
    import 'package:flutter/material.dart';
    import 'package:flutter_masked_text/flutter_masked_text.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatefulWidget {
      MyApp({Key key}) : super(key: key);
    
      @override
      _MyAppState createState() => _MyAppState();
    }
    
    class _MyAppState extends State<MyApp> {
      TextEditingController _controller;
    
      @override
      void initState() {
        _controller = MaskedTextController(mask: '(000) 000-0000');
        super.initState();
      }
    
      @override
      void dispose() {
        _controller.dispose();
        super.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: Scaffold(
            appBar: AppBar(
              title: Text('#77855'),
            ),
            body: Padding(
              padding: const EdgeInsets.all(25),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text('Try to type a phone number here on any platform'),
                  TextField(
                    controller: _controller,
                  ),
                  SizedBox(height: 20),
                  Text('Smash your keys on macOS'),
                  TextField(),
                ],
              ),
            ),
          ),
        );
      }
    }
  6. chunhtai commented on Mar 17, 2021

    @chunhtai
    Contributor

    Hi @justinmc @lukepighetti
    I can't seem to reproduce the infinite loop in regular textfield in macos. I tried to type multiple character at once, and it works as expected. I am testing on master branch

    I can reproduce the MaskedTextController one though

  7. chunhtai commented on Mar 17, 2021

    @chunhtai
    Contributor
    Screen.Recording.2021-03-17.at.11.34.07.AM.mov
  8. lukepighetti commented on Mar 17, 2021

    @lukepighetti
    Contributor
    % flutter devices
    4 connected devices:
    
    SM S102DL (mobile)     • RF8N737S2CR                              • android-arm    • Android 10 (API 29)
    Luke's iPhone (mobile) • 0bc0c4864d8e08aac4456893cded68bf0b6767d5 • ios            • iOS 14.4
    macOS (desktop)        • macos                                    • darwin-x64     • macOS 11.2.1 20D74 darwin-x64
    Chrome (web)           • chrome                                   • web-javascript • Google Chrome 89.0.4389.90
    
  9. lukepighetti commented on Mar 17, 2021

    @lukepighetti
    Contributor

    You gotta really go for it. Smash them keys! 😅

    Screen.Recording.2021-03-17.at.1.29.02.PM.mov
  10. chunhtai commented on Mar 17, 2021

    @chunhtai
    Contributor

    Talked to @justinmc offline, none of us can reproduce it on latest master. Not sure what may have fixed it. @lukepighetti Can you check if you are on the latest master?

  11. gspencergoog commented on Mar 17, 2021

    @gspencergoog
    Contributor

    @dkwingsmt recently landed engine changes for macOS key event handling (flutter-team-archive/engine#23469), so that may have fixed it.

  12. lukepighetti commented on Mar 17, 2021

    @lukepighetti
    Contributor

    The macOS issue appears to be resolved on latest master, but the conflict with the mask remains.

    % flutter doctor                           
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel master, 2.1.0-13.0.pre.138, on macOS 11.2.1 20D74 darwin-x64, locale en-US)
    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 4.1)
    [✓] VS Code (version 1.54.3)
    [✓] Connected device (4 available)
    
    • No issues found!
    
    Screen.Recording.2021-03-17.at.2.58.33.PM.mov
  13. chunhtai commented on Mar 17, 2021

    @chunhtai
    Contributor

    I would like to close this issue as not reproducible. The commit is likely a breaking change for the flutter_masked_text, but is overlooked because our current breaking change policy only consider breaking change if it fails customer tests in https://github.com/flutter/tests
    I have not look too deep into that package, but i think the fix should be in there instead of the flutter framework.

    Feel free to reopen if you think otherwise

  14. lukepighetti commented on Mar 17, 2021

    @lukepighetti
    Contributor

    That's fair, thanks!

  15. github-actions commented on Aug 4, 2021

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

  16. locked as resolved and limited conversation to collaborators on Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsplatform-macosBuilding on or for macOS specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions