Skip to content

ListView Builder scrolling is slow due to improper input events handling #22314

Closed

Description

@kieferlam

The ListView Builder is slow compared to native apps. I've attached a video demo-ing my experience. And my complete code (which is basically just the example on the Working with long lists guide.

The gif has the flutter listview and also shows the scrolling of Reddit Is Fun app as well just for a reference.

gif

main.dart

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(
        body: ListView.builder(
            key: Key("lvbuildertest"),
            itemCount: 200,
            itemBuilder: (context, index) {
              return ListTile(title: Text("index: $index"));
            }),
      ),
    );
  }
}
[√] Flutter (Channel master, v0.9.4-pre.31, on Microsoft Windows [Version 10.0.17134.285], locale en-GB)
    • Flutter version 0.9.4-pre.31 at F:\androidsdk\flutter
    • Framework revision 52697ef962 (11 hours ago), 2018-09-26 07:57:05 +0200
    • Engine revision 38a646e14c
    • Dart version 2.1.0-dev.5.0.flutter-4cf2d3990b

[√] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    • Android SDK at F:\androidsdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    • All Android licenses accepted.

[√] Android Studio (version 3.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[!] IntelliJ IDEA Ultimate Edition (version 2018.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.5
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.io/intellij-setup/#installing-the-plugins

[√] VS Code (version 1.27.2)
    • VS Code at C:\Users\username


\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 2.18.0

[√] Connected devices (1 available)
    • SM N9005 • 192.168.0.3:5555 • android-arm • Android 8.1.0 (API 27)

! Doctor found issues in 1 category.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    f: scrollingViewports, list views, slivers, etc.
    on Sep 27, 2018
  2. added this to the milestone on Sep 27, 2018
  3. zoechi commented on Sep 27, 2018

    @zoechi
    Contributor

    #20857 might be related

  4. iamarnas commented on Oct 6, 2018

    @iamarnas

    @kieferlam Have you tried to add physics: const AlwaysScrollableScrollPhysics (), it will make smother scrolling.

  5. kieferlam commented on Oct 6, 2018

    @kieferlam
    Author

    @iamarnas That has definitely improved scrolling performance! Thanks.

  6. bobmoff commented on Jan 6, 2019

    @bobmoff

    I am curious to why AlwaysScrollableScrollPhysics would improve the performance of scrolling ? Isn't this widget just to make scrollable widgets that have too few items (and would therefor not be scrollable atm) scrollable.

    I am also comparing scrolling in Flutter with native scrolling on iOS and there seem to be lots of missing frames here and there in Flutter and sometimes longer pauses. I am running on an iPhone X so its not some low end device. I heard that ListViewTiles are NOT recycled in Flutter, is this true? and if so, Why ? In game development, where every frame counts it is very important to have object pools to be able to show and hide render-objects fast without destroying and creating objects all the time.

  7. lirbank commented on Jan 14, 2019

    @lirbank

    Are you running the app in debug or release mode? On my Moto x4 (kinda low end device) scrolling is jerky in debug mode, but once compiled for production it is just as smooth as Native apps.

    flutter run --release
  8. kieferlam commented on Jan 14, 2019

    @kieferlam
    Author

    @lirbank The app was running in release mode. Not sure what the state of this issue is right now since newer versions have been released. My device was a Samsung Galaxy Note 3 (not sure how that compares though)

  9. kraa commented on Jan 15, 2019

    @kraa

    Same lags here. Tried both advices (AlwaysScrollableScrollPhysics and release) - no result. On some devices it's feels smoother , on some - not. And notice lots of missing frames .

  10. zoechi commented on Jan 15, 2019

    @zoechi
    Contributor

    @kraa you are testing with release or profile builds, not with debug builds, right?

  11. kraa commented on Jan 15, 2019

    @kraa

    Yeah, release build (no debug label top right corner of screen)

  12. tirnovali commented on Jan 26, 2019

    @tirnovali

    same problem here

  13. zoechi commented on Jan 27, 2019

    @zoechi
    Contributor

    @kraa @tirnovali
    To investigate we would need a minimal runnable reproduction
    as a single file so that we can just copy your code into lib/main.dart of a new project and run to reproduce.

  14. 80 remaining items

  15. klaszlo8207 commented on Apr 22, 2020

    @klaszlo8207

    Any news on this? Please it is very fustrating

  16. pilotviper134 commented on Apr 22, 2020

    @pilotviper134

    The problem still appears on my Huawei P30 Pro device. Using cacheExtent slightly helped with performance. However, the list can still be trimmed at the very end of the scrolling.

  17. Renatinaveen commented on Apr 23, 2020

    @Renatinaveen

    https://drive.google.com/file/d/1a3ZJ099XSJ-lvHDc2DVadExAYT3kAM3r/view?usp=drivesdk
    That's on iphone 6s

    https://drive.google.com/file/d/1w5dEXmKuiKXadzXSxiVbb2GjR05htY6Z/view?usp=drivesdk
    This is OnePlus 6t.

    I don't understand what the problem is while scrolling up I get this issue.

  18. leszekkrol commented on May 1, 2020

    @leszekkrol

    Why this issue is closed? Problem still occurred

  19. iamarnas commented on May 1, 2020

    @iamarnas

    @leszekkrol It's quick fix. They close many issues for no reason.

  20. fadhlisulaimi commented on May 1, 2020

    @fadhlisulaimi

    I tried switching to dev channel and updating to latest version.
    Not sure if its just a placebo effort but i feel the scrolling is smoother.

  21. firatcetiner commented on May 9, 2020

    @firatcetiner

    @firatcetiner Thanks for the information, do you have result with the memory usage with your config ?

    @x4080

    Not good actually. Every item in the list consist of:

    • A low-resolution image (50x50),
    • 5 different Text widgets, one of the may text includes a long text (400 characters) sometimes,
    • 4 buttons in a row

    The structure is like this: Container>Column>[Row[Text, Image], Text, Text, Buttons]

    With the cacheExtent = 10000.0 and assuming the average height of a child widget is 600 pixels, it should cache at least 15 items per list. Since I have 4 separate lists on different parts of the app at the same time, this means at least 60 items are in the cache. Assuming the cache size is determined for just only one direction Up or Down but not both.

    In this case, the memory usage is around ~400MB. I'm not sure this is okay but it seems like a lot.

  22. filiph commented on May 11, 2020

    @filiph
    Contributor

    Hi all, this is an outdated issue, and the explanation to it is unfortunately buried in the noise. Moreover, GitHub collapses the middle of the thread, which includes the reason for closing this issue, and it's really easy to overlook it.

    Screen Shot 2020-05-11 at 11 00 38 AM

    I want to summarize some things for better discoverability:

    • The initial issue has been fixed months ago.
    • Please do not look at performance in debug mode. It is understood that debug mode is much slower than profile or release. There's only so much the Flutter SDK can do while also allowing for hot reloading, failing fast, etc. If you want to push the Flutter team to make debug mode faster in a specific scenario, please file a separate issue.
    • If you have a scrolling performance problem, do file a separate bug. A video is helpful. A piece of code that reproduces the issue is extremely helpful.
    • If you're new to Flutter and wondering about performance, you should know that it is very much possible to have smooth scrolling in Flutter. Many apps out there have complex ListViews and they scroll without missing a frame. On the other hand, it is also possible that Flutter has bugs that make scrolling slow in a particular case (if you suspect this, please file a bug), and it's also possible to make scrolling janky via other code (if you suspect this, please read flutter.dev/docs/perf/rendering or watch my video from Flutter Europe)

    @Hixie, @liyuqian: Would it make sense to rename this issue to something more specific? Would it make sense to close comments on this issue so people don't accidentally bury this information again?

  23. esDotDev commented on May 11, 2020

    @esDotDev

    I have filed a fairly specific issue:
    #52207

    It is quite easy to get janky scrolling performance once you attach it to a Scrollbar that calls JumpTo.

    1. Make a large list > 5000 items with variable size height rows (ie, don't set itemExtent)
    2. Scroll rapidly from top to bottom with scrollbar

    Builder just doesn't seem optimized for successive calls to JumpTo like a Scrollbar does.

  24. liyuqian commented on May 12, 2020

    @liyuqian
    Contributor

    @filiph : I also lost track of what this issue is about and what PR fixed it... Ian's comments #22314 (comment) and #22314 (comment) are the closest that I find. @Hixie : I recently noticed "lock bot" sending me a lot of emails. Shall we also lock this issue to incentivize folks to open new issues?

  25. leszekkrol commented on May 13, 2020

    @leszekkrol

    Any update in that case?

  26. Martibis commented on May 13, 2020

    @Martibis

    This is a massive problem a lot of people are facing and key to Flutters adoption in my opinion. You advertise smooth fps, but a basic functionality like scrolling dynamic content can not get the advertised native level smoothness.

  27. changed the title [-]ListView Builder scrolling is slow[/-] [+]ListView Builder scrolling is slow due to improper input events handling[/+] on May 13, 2020
  28. liyuqian commented on May 13, 2020

    @liyuqian
    Contributor

    I've changed the title per @filiph 's suggestion to clarify that this issue is about input events handling and it's fixed according to comment (1) and (2).

    If there are other performance issues related to ListView, please create a new issue following the suggestion in comment (1) and (2).

    We understand your performance concerns and we'll definitely work very hard to fix it. It's just difficult for us to follow an old Github issue with a lot of unrelated comments. So I'm locking down this issue to encourage creating new and focused issues with details of how to reproduce the performance issue. Please feel free to reference me by @liyuqian in the new issues.

  29. locked as resolved and limited conversation to collaborators on May 13, 2020
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

    c: performanceRelates to speed or footprint issues (see "perf:" labels)f: scrollingViewports, list views, slivers, etc.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