Skip to content

Caret performance is poor, high GPU time per frame. #24522

@sommestad

Description

@sommestad

When writing to TextFields in my Flutter application, I am seeing serious drops in performance while typing. The frame rate goes from 60 -> 25 fps (and red bars).

Oddly enough, if using a single-line textfield and typing "outside" the screen, the frame rate goes back up to ~60 (with no red bars in perf monitor). (Could also be related to number of characters, but that seems less likely given my observations).

From what I can see, the surrounding widgets does not seem to have any substantial impact, i.e. it happens on both simpler and more complex screens.

The sluggish performance is even more obvious when using the label decorations that comes with material TextFields.
However, I am seeing the same on both Cupertino and Material textfields. I have also tried with very "clean" textfields, i.e. without any text controllers or similar attached to it.

Is this expected? Or could there be any issues with the TextField widget?
(I do not see any behavior like this in native or even web applications I've built.)

Steps to Reproduce

  1. Create a StatefulWidget and add a TextField to it. In my case, the hierarchy is ~3-4 levels deep before appending the TextField.
  2. Start typing in the TextField (I've tested both on iOS 8 device and on iPhone 7 simulator).
  3. To see differences in performance; make the textfield single line with a fixed width.

Logs

Launching lib/main.dart on iPhone 7 in debug mode...
Starting Xcode build...
Xcode build done.                                           10,2s
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:

let db = Firestore.firestore()
let settings = db.settings
settings.areTimestampsInSnapshotsEnabled = true
db.settings = settings

With this change, timestamps stored in Cloud Firestore will be read back as Firebase Timestamp objects instead of as system Date objects. So you will also need to update code expecting a Date to instead expect a Timestamp. For example:

// old:
let date: Date = documentSnapshot.get("created_at") as! Date
// new:
let timestamp: Timestamp = documentSnapshot.get("created_at") as! Timestamp
let date: Date = timestamp.dateValue()

Please audit all existing usages of Date when you enable the new behavior. In a future release, the behavior will be changed to the new behavior, so if you do<…>
Syncing files to device iPhone 7...
[VERBOSE-2:FlutterObservatoryPublisher.mm(145)] FlutterObservatoryPublisher is ready!

Analyzing my_app...                                         

   info • Unused import: 'package:cloud_firestore/cloud_firestore.dart' • lib/screens/account.dart:3:8 • unused_import
   info • Unused import: 'package:my_app/screens/widgets/credits.dart' • lib/screens/create_thread.dart:4:8 • unused_import
   info • This function has a return type of 'Future<String>', but doesn't end with a return statement • lib/screens/login.dart:166:3 • missing_return
   info • This class inherits from a class marked as @immutable, and therefore should be immutable (all instance fields must be final) • lib/screens/thread.dart:17:7 • must_be_immutable
   info • Avoid using braces in interpolation when not needed • lib/screens/thread.dart:178:32 • unnecessary_brace_in_string_interps


[✓] Flutter (Channel dev, v0.11.3, on Mac OS X 10.14.1 18B75, locale sv-SE)
    • Flutter version 0.11.3 at /Users/my_user/Dev/Libs/flutter
    • Framework revision 72bf075e8d (9 days ago), 2018-11-09 20:36:17 -0800
    • Engine revision 5646e86a6f
    • Dart version 2.1.0 (build 2.1.0-dev.9.3 9c07fb64c4)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    • Android SDK at /Users/my_user/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.6)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 28.0.2
    • Dart plugin version 181.5616

[✓] Connected device (2 available)
    • Iphone S • <obfuscated> • ios • iOS 12.1
    • iPhone 7 • <obfuscated>     • ios • iOS 12.1 (simulator)

• No issues found!

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsc: performanceRelates to speed or footprint issues (see "perf:" labels)customer: crowdAffects or could affect many people, though not necessarily a specific customer.engineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions