Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent selection effect and huge FPS drop when selecting text from a TextFormField with focusNode set to false #148027

Closed
GabrielCR99 opened this issue May 9, 2024 · 6 comments
Labels
r: fixed Issue is closed as already fixed in a newer version

Comments

@GabrielCR99
Copy link

Steps to reproduce

Create a simple TextFormField with a custom FocusNode class that overrides the property hasFocus to false. Now, when the TextFormField has any text inside of it, try to select it with your fingers (like selecting a text to copy/cut/paste). You can see that the rendering (?) of the selection will still be there until we close the app completely. Also happens on the emulator, as seen on the video

Expected results

Selecting a TextFormField with FocusNode set to false should be rendered normally

Actual results

Example in a not reproducible project (my company) and also using a Samsung Galaxy S23 Ultra with Android 14

Screen_Recording_20240508_154853.mp4

Code sample

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

void main() => runApp(const MaterialApp(home: MainApp()));

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

  @override
  State<MainApp> createState() => _MainAppState();
}

final class _MainAppState extends State<MainApp> {
  final _controller = TextEditingController(text: 'W' * 20);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 16),
        child: Center(
          child: TextFormField(
            controller: _controller,
            focusNode: _AlwaysDisabledFocusNode(),
            decoration: const InputDecoration(
              labelText: 'Date',
              hintText: 'Initial - Final',
              hintStyle: TextStyle(
                color: Color(0xFFBEBEBE),
                fontSize: 12,
                fontStyle: FontStyle.italic,
              ),
              floatingLabelBehavior: FloatingLabelBehavior.always,
              isDense: true,
              contentPadding: EdgeInsets.all(10),
              suffixIcon: Padding(
                padding: EdgeInsets.all(8),
                child: Icon(Icons.date_range, size: 24),
              ),
            ),
            keyboardType: TextInputType.datetime,
            style: const TextStyle(fontSize: 12),
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}

final class _AlwaysDisabledFocusNode extends FocusNode {
  @override
  bool get hasFocus => false;
}

Screenshots or Video

Screenshots / Video demonstration
Recording.2024-05-08.211136.mp4

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3527], locale en-US)
    • Flutter version 3.19.6 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (3 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\gabri\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.35)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.34729.46
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 2023.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.10+0--11572160)

[✓] VS Code (version 1.89.0)
    • VS Code at C:\Users\gabri\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.88.0

[✓] Connected device (3 available)
    • sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 11 (API 30) (emulator)
    • Windows (desktop)          • windows       • windows-x64    • Microsoft Windows [Version 10.0.22631.3527]
    • Edge (web)                 • edge          • web-javascript • Microsoft Edge 124.0.2478.80

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 9, 2024
@darshankawar
Copy link
Member

Thanks for the report @GabrielCR99
I am assuming you are seeing this in debug mode when running on device as well as on emulator. Can you try the same in release or profile mode and check if you still get same performance behavior ?

Flutter's performance is very different between debug mode and release mode. As a result, it's rarely a good idea to measure a Flutter app's performance in debug mode, because the answers will be very different from those in release mode.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 9, 2024
@GabrielCR99
Copy link
Author

Hello @darshankawar! Unfortunately, I'm not running in debug mode. On my Samsung Galaxy S23 Ultra, it was a production build (release mode) and I was presenting it to our PO, showing new features developed. Whereas on the emulator, I'm also running release mode with flutter run --release, using Windows 11

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 9, 2024
@GabrielCR99
Copy link
Author

Here's another proof that I'm running in release mode, and this time I'm using showPerformanceOverlay property from MaterialApp. Running the sample code, the same thing happens on my real device - Samsung Galaxy S23 Ultra, Android 14. Looks like the rastering is struggling

Screen_Recording_20240509_082451.mp4

@GabrielCR99 GabrielCR99 changed the title Huge FPS drop when selecting a TextFormField with focus set to false Persistent selection effect and huge FPS drop when selecting text from a TextFormField with focusNode set to false May 9, 2024
@darshankawar
Copy link
Member

Thanks for the details @GabrielCR99
I tried the code sample on S10 running on Android 12 OS in stable version, in which I do see the performance drop / jank as shown below in release mode:

Screen_Recording_20240510_111941.mp4

However, on latest master version, the performance and behavior is very smooth as shown below:

Screen_Recording_20240510_111247.mp4

I also confirmed that on latest beta as well, the performance and behavior is smooth and as expected.

Indicating, the issue seems to be in stable but not in master and beta, in which you can check and confirm.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 10, 2024
@GabrielCR99
Copy link
Author

Hi @darshankawar ! Thanks for letting me know about that. I tested it on beta and master and it's working perfectly fine. I wonder, how can I see which commit solved this issue? Is it possible? Many thanks anyway!

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 10, 2024
@darshankawar
Copy link
Member

how can I see which commit solved this issue? Is it possible?

Exactly which commit fixed it, will be difficult to find out, but we will get a new stable release very soon, so hopefully you'll not need to wait for long to verify this in new stable, so I suggest you to keep an eye on stable version.

As the reported behavior works as expected in master, per our triage policy, I'll go ahead and close this as fixed.

@darshankawar darshankawar added r: fixed Issue is closed as already fixed in a newer version and removed in triage Presently being triaged by the triage team labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

No branches or pull requests

2 participants