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

Android scroll speed deceleration rate doesn't match native #16371

Closed
korbin-w opened this issue Apr 9, 2018 · 20 comments · Fixed by #107735
Closed

Android scroll speed deceleration rate doesn't match native #16371

korbin-w opened this issue Apr 9, 2018 · 20 comments · Fixed by #107735
Labels
a: fidelity Matching the OEM platforms better a: quality A truly polished experience customer: alibaba f: scrolling Viewports, list views, slivers, etc. found in release: 1.22 Found to occur in 1.22 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version

Comments

@korbin-w
Copy link

korbin-w commented Apr 9, 2018

Steps to Reproduce

1, Scroll a ListView page on Android.
2, Observe and compare the scrolls between Flutter and Native pages.
3, The scroll is tiny bumpy in Flutter. Besides, before the end of scroll, I have a feeling that it "suddenly" stops.

screenrecord_20180409_213143.mp4.zip

Flutter Doctor

[✓] Flutter (Channel beta, v0.2.3, on Mac OS X 10.12.6 16G1314, locale zh-Hans-HK)
• Flutter version 0.2.3 at /Users/guoyou/projects/flutter
• Framework revision 5a58b36 (4 weeks ago), 2018-03-13 13:20:13 -0700
• Engine revision e61bb9a
• Dart version 2.0.0-dev.35.flutter-290c576264

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/guoyou/Library/Android/sdk
• Android NDK at /Users/guoyou/Library/Android/sdk/ndk-bundle
• Platform android-27, build-tools 27.0.3
• 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 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
• ios-deploy 1.9.2
• CocoaPods version 1.4.0

[✓] Android Studio (version 3.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[✓] IntelliJ IDEA Community Edition (version 2017.2.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin installed
• Dart plugin version 172.3968.27

[✓] Connected devices (1 available)
• iPhone X • 8D4A21F9-E417-43CE-8B40-52CEAB6B7D04 • ios • iOS 11.2 (simulator)

• No issues found!

@Hixie
Copy link
Contributor

Hixie commented Apr 10, 2018

Have you had a chance to look at https://flutter.io/ui-performance/ ?

@xster
Copy link
Member

xster commented Apr 10, 2018

Not sure what you were pointing out from the video. Is it that friction is too high and the flings slow down too quickly towards the end?

@korbin-w
Copy link
Author

@xster Yes, it is that friction is too high and the flings slow down too quickly towards the end. Comparing it with native views, there is tiny difference. I looked at the performance, it is normal.
As the difference is tiny, feel free to handle this issue. It is not blocker.

@xster
Copy link
Member

xster commented Apr 11, 2018

Yes it does look a bit off. Would you mind comparing with our gallery app (https://play.google.com/store/apps/details?id=io.flutter.demo.gallery)? Couldn't tell from the video but it does look a bit different from our default expected behaviour too.

@xster xster added the f: scrolling Viewports, list views, slivers, etc. label Apr 11, 2018
@korbin-w
Copy link
Author

@xster Thanks for your suggestion, I've compared with the gallery app, I think the difference is still existing. I'm comparing the scroll gallery with any android native app, the smooth is tiny different but I don't know how to figure the difference with test results, I'm just observing between them. Or else can you tell me the principle or code position of the scroll speed of Flutter?

@xster
Copy link
Member

xster commented Apr 11, 2018

They're different per platform but for Android, it's at https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/scroll_simulation.dart#L141 (which I believe is extracted from the Android source code). It's also all configurable via the ScrollBehavior widget.

@xster xster changed the title The scroll is not as smooth as native on Android Android fling deceleration rate doesn't match native Apr 11, 2018
@zoechi zoechi added the framework flutter/packages/flutter repository. See also f: labels. label Jul 22, 2018
@goderbauer goderbauer added platform-android Android applications specifically a: quality A truly polished experience a: fidelity Matching the OEM platforms better labels Dec 28, 2018
@goderbauer goderbauer reopened this Feb 28, 2020
@jmagman jmagman added this to Awaiting triage in Mobile - Android next adoption review via automation Mar 5, 2020
@TahaTesser
Copy link
Member

TahaTesser commented Sep 8, 2020

I can easily notice the different when using lists example from https://github.com/flutter/gallery and Play store

flutter doctor -v
✓] Flutter (Channel master, 1.22.0-10.0.pre.88, on Mac OS X 10.15.6 19G2021,
    locale en-GB)
    • Flutter version 1.22.0-10.0.pre.88 at
      /Users/tahatesser/Code/flutter_master
    • Framework revision e10bdbbd9d (18 hours ago), 2020-09-07 11:40:03 -0700
    • Engine revision ac8b9c4c52
    • Dart version 2.10.0 (build 2.10.0-86.0.dev)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • 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-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.7, Build version 11E801a
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.48.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.14.1

 
[✓] Connected device (4 available)            
    • RMX2001 (mobile)   • EUYTFEUSQSRGDA6D                     • android-arm64
      • Android 10 (API 29)
    • iPhone 11 (mobile) • 73130414-6DF8-4E37-B9AF-F81FA0F9068B • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-13-7 (simulator)
    • Web Server (web)   • web-server                           • web-javascript
      • Flutter Tools
    • Chrome (web)       • chrome                               • web-javascript
      • Google Chrome 85.0.4183.83

• No issues found!

@TahaTesser TahaTesser added found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on labels Sep 8, 2020
@GaryQian GaryQian changed the title Android fling deceleration rate doesn't match native Android scroll speed deceleration rate doesn't match native Oct 19, 2020
@GaryQian GaryQian moved this from Awaiting triage to Engineer reviewed in Mobile - Android next adoption review Oct 19, 2020
@hamberluo
Copy link

hamberluo commented Nov 18, 2020

this tiny difference of scroll behavior between native and flutter should be important to users

@hamberluo
Copy link

Changing friction smaller in ClampingScrollSimulation will help improving the speed deceleration.

But the problem is the default friction is 0.015 and algorithm also from android source, so what's wrong with flutter?

@vannevar-morgan
Copy link

I agree scrolling feels different in flutter vs native. Noticed after upgrading to flutter 2.0.0 that scrolling seems much more slippy. Using defaults, can now easily fling through a ListView of 300+ items with one flick. Whereas native it might take 3 or 4 flicks. Using ClampingScrollSimulation and increase the friction, .03 or .045 it still feels like the deceleration curve is just off. Apologies for the terms like "slippy", best I can describe it.

@heyarny
Copy link

heyarny commented Aug 27, 2021

I can confirm this. Android native scrolling behaves different to what flutter is generating.

@nt4f04uNd
Copy link
Member

nt4f04uNd commented Aug 28, 2021

I think it was fixed with #77497

@Piinks
Copy link
Contributor

Piinks commented Sep 9, 2021

I think some of the comments here may have actually been caused by #77497.
I have bisected it as the cause for #83632, which some of the comments above describe as well.

@eseidelGoogle
Copy link
Contributor

This came up today. Is it worth landing the test from https://github.com/flutter/flutter/pull/92338/files even if it's marked as failing for now?

@Piinks Piinks self-assigned this Jul 15, 2022
@Piinks Piinks added the P1 High-priority issues at the top of the work list label Jul 15, 2022
@github-actions
Copy link

github-actions bot commented Sep 2, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2022
@flutter flutter unlocked this conversation Sep 8, 2022
@Piinks
Copy link
Contributor

Piinks commented Sep 8, 2022

The PR that closed this is being reverted. Reopening.

@Piinks Piinks reopened this Sep 8, 2022
Mobile - Android next adoption review automation moved this from Engineer reviewed to Awaiting triage Sep 8, 2022
@Piinks
Copy link
Contributor

Piinks commented Sep 8, 2022

For the next crack at solving this, this reproduction should be included as a test case: #110340

Also, the latest attempt included creating and passing updated FixedScrollMetrics to createBallisticScrollAnimation. This was a breaking change for customers with their own custom scroll physics that expect a scroll position be provided to createBallisticScrollAnimation, not just ScrollMetrics. Either migrating the customer off of this currently safe assumption will be required, or a different approach that preserves that.

@Piinks Piinks removed their assignment Sep 8, 2022
@Piinks Piinks added P2 Important issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Sep 8, 2022
gnprice added a commit to gnprice/flutter that referenced this issue Feb 10, 2023
Fixes flutter#120338.
Fixes flutter#119875.
Fixes flutter#113424.

Fixes most of flutter#16371, as the combined symptom of those three.
(There's still flutter#120345, and possibly other contributing factors,
remaining.)

This replaces the implementation of ClampingScrollSimulation with
a new version that better matches the Android scroll physics it's
intended to match.

The new implementation is a version of the Android curve which has
been adjusted so that it behaves in a physically reasonable way,
in order to satisfy an invariant which the Flutter scroll protocol
relies on.

Because the old ClampingScrollSimulation didn't satisfy that
invariant either, it suffered from a bug (flutter#120338) where
restarting the simulation with new metrics would have the side
effect of adding friction, making a fling go about 15% less far.
So this fixes flutter#120338.

The new implementation also goes the same total distance as the
Android scroll physics, whereas the existing version would go about
7% less far (stacking with the 15% reduction when the other issue
was triggered.)  That fixes flutter#119875.

Finally, the new implementation comes to a smooth stop, like Android
does, whereas the existing version would speed slightly up before
abruptly stopping.  That fixes flutter#113424.

The new implementation's curve is the unique curve that both goes the
same total distance as Android's for every possible starting velocity,
and meets the Flutter scroll protocol's ballistic invariant.  So in
that sense this is the canonical way of fixing up the Android behavior
to something physically reasonable, or something that works correctly
in Flutter.
@exaby73
Copy link
Member

exaby73 commented Apr 21, 2023

@Piinks What's the status of this issue currently? The scrolling performance I see is very similar currently. Though the device I am using is an older one so I'm not confident closing this issue based on that.

@gnprice
Copy link
Member

gnprice commented Apr 21, 2023

Thanks for the bump. I believe this was fixed by the combination of the two PRs

These symptoms were a combined effect of

Those four issues were fixed by the two PRs mentioned above. In particular, see the "after" video from the latter PR (at #122338 (comment)), which compares fling-scrolls in Flutter and a native Android scrollable.

I think that covers all the reports in this thread (other than those that were #83632). For any discrepancies that remain, it's probably best to file a new issue.

@gnprice gnprice closed this as completed Apr 21, 2023
Mobile - Android next adoption review automation moved this from Awaiting triage to Engineer reviewed Apr 21, 2023
@exaby73 exaby73 added the r: fixed Issue is closed as already fixed in a newer version label Apr 23, 2023
@github-actions
Copy link

github-actions bot commented May 7, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: fidelity Matching the OEM platforms better a: quality A truly polished experience customer: alibaba f: scrolling Viewports, list views, slivers, etc. found in release: 1.22 Found to occur in 1.22 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version
Projects
Development

Successfully merging a pull request may close this issue.