You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scrolling with trackpad continues momentum animation for too long #107752
The ballistic simulation which follows a scroll when using BouncingScrollPhysics gives good behaviour for a touchscreen, but causes much more scrolling than other desktop and trackpad apps. The amount of friction should be increased of the source of the scroll is a trackpad, to match expectations and behavior of other applications.
So there could be 2 things at play here. We know that ballistic scroll animations can be triggered more than they should, see #11599 That could be contributing to what it showing here.
And then there could be some additional adjustment that needs to be made to BouncingScrollPhysics.
The first has a proposed fix in progress in #107735. After than lands, we should check this again and see if the update to the ballistic scroll animation makes this any better..
Since this is specific to only the trackpad input device, is it possible @moffatman that the trackpad input is applying too much delta? Should't the scroll physics be the same across input devices? Currently we don't have dynamic scroll physics that adapt to the input device so we will need to investigate this a bit.
I noticed there were a lot of goBallistic calls, but in BouncingScrollPhysics that doesn't matter since it's using exponential deceleration, no state is being lost and the calculation is continuous. I verified by commenting out some of the goBallistic calls to only get one at the start.
It looks like #107735 only affects clamping scroll physics? This is with BouncingScrollPhysics.
Trackpad input is the correct delta, since when scrolling without releasing, the lists track correctly. It's the scroll simulation phase which doesn't match.
I have been trying to adjust BouncingScrollPhysics to get it to match. This is going to require dynamic scroll physics, for proper trackpad scroll deceleration, there needs to be more friction. Here's where I'm at:
Screen.Recording.2022-07-19.at.3.22.06.PM.mov
Changes so far:
Apply constant deceleration on top of the friction factor (right now 2800pt/s^2). This ends up needing quite complex math to calculate the stopping point.
Change friction factor on overscroll from 0.52 to 0.07
Adjust velocity estimation algorithm to more heavily weight recent samples (also needs to be different on trackpad vs touchscreen)
Increase kMaxFlingVelocity to infinity, it's not uncommon to see ~24000pt/s velocity from the trackpad.
Still doesn't quite match though.
The easiest way to have dynamic scroll behavior would be to have a trackpad physics and touch physics, but that would make it quite complex for anyone switching from the defaults. Probably the physics object should know about the PointerDeviceKind.
Another issue: on iPadOS itself, the trackpad actually has the same friction as touch, but when iPad app is running on an M1 mac, it uses Mac-specific scrolling friction. Right now those devices show up as Platform.iOS, some refactor would be needed to represent this runtime scenario.
It looks like #107735 only affects clamping scroll physics? This is with BouncingScrollPhysics.
Yeah, it is updating clamping scroll physics, but also fixing that ballistic issue at the same time.
The easiest way to have dynamic scroll behavior would be to have a trackpad physics and touch physics
That is a really interesting idea, but probably really complex to implement. Flutter does not know what input devices are available until it actually receives the input, and there would be a lot of edge cases to account for when using both. Imagine a scroll animation running from mouse input is interrupted by a scroll animation from a trackpad... Right now all of scrolling in Flutter assumes one type of scroll physics, so supporting more than one would be tricky.
I think what it sounds like is that we might want to consider having proper desktop scroll physics. ClampingSP is based on Android, while BouncingSP is based on iOS. We have not actually compared/contrasted/considered what Mac, Linux and Windows scroll physics should be.
Another issue: on iPadOS itself, the trackpad actually has the same friction as touch, but when iPad app is running on an M1 mac, it uses Mac-specific scrolling friction.
Emulators running on desktop can make this a bit murky - it does sound like the scroll physics are different on mac from iOS. If the iPad scrolling matches on the physical device, that is the source of truth. There are a lot of things that simulators are just a bit off by. Like in the above scroll_overlay, no matter how fine tuned you get it, it will always be just a bit off because of inconsistent compositing, performance, etc on simulators.
Right now those devices show up as Platform.iOS, some refactor would be needed to represent this runtime scenario.
This is something we are really unlikely to do. Adding another target platform is a large scale breaking change for the framework, especially since iPadOS is really iOS.
So I think I will try to get a good match of Mac scrolling behavior and add it as a new default physics for Mac, and forget about different physics for trackpad vs touch. What do you think @Piinks ?
For the iOS app running in emulation, I can deal with it on my own apps, I have some code to detect if running in that environment and then I'll switch the default scroll configuration. You're right that it would be a big breaking change for a pretty small edge case.
That sounds awesome! Thank you so much for all of your contributions!
It could be that we add a platform-specific variation to BouncingScrollPhysics, rather than a whole new ScrollPhysics class, but I trust you'll be able to determine the best course there.
I don't think the scroll_overlay app has an underlying mac app in it for comparison, we'll have to add one in there to be able to compare the overlay like on iOS and Android.
I'm running the iOS version on "My Mac (Designed for iPad)". That's what those videos are from, in that mode the scroll events are generated from AppKit using the same physics as other mac apps. I don't know how to make one specifically for mac, I don't think you can put mix native and flutter on desktop yet?
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.
Activity
maheshj01 commentedon Jul 18, 2022
Hi @moffatman, Thanks for filing the issue. I do see the scroll animation is longer on the latest master channel, But not on the stable channel.
Stable
Screen.Recording.2022-07-18.at.12.47.13.PM.mov
master
Screen.Recording.2022-07-18.at.12.50.58.PM.mov
flutter doctor -v (mac)
HansMuller commentedon Jul 19, 2022
CC @Piinks @dkwingsmt
Piinks commentedon Jul 19, 2022
So there could be 2 things at play here. We know that ballistic scroll animations can be triggered more than they should, see #11599 That could be contributing to what it showing here.
And then there could be some additional adjustment that needs to be made to BouncingScrollPhysics.
The first has a proposed fix in progress in #107735. After than lands, we should check this again and see if the update to the ballistic scroll animation makes this any better..
Since this is specific to only the trackpad input device, is it possible @moffatman that the trackpad input is applying too much delta? Should't the scroll physics be the same across input devices? Currently we don't have dynamic scroll physics that adapt to the input device so we will need to investigate this a bit.
moffatman commentedon Jul 19, 2022
@Piinks
I noticed there were a lot of
goBallisticcalls, but inBouncingScrollPhysicsthat doesn't matter since it's using exponential deceleration, no state is being lost and the calculation is continuous. I verified by commenting out some of thegoBallisticcalls to only get one at the start.It looks like #107735 only affects clamping scroll physics? This is with BouncingScrollPhysics.
Trackpad input is the correct delta, since when scrolling without releasing, the lists track correctly. It's the scroll simulation phase which doesn't match.
I have been trying to adjust BouncingScrollPhysics to get it to match. This is going to require dynamic scroll physics, for proper trackpad scroll deceleration, there needs to be more friction. Here's where I'm at:
Screen.Recording.2022-07-19.at.3.22.06.PM.mov
Changes so far:
kMaxFlingVelocityto infinity, it's not uncommon to see ~24000pt/s velocity from the trackpad.Still doesn't quite match though.
The easiest way to have dynamic scroll behavior would be to have a trackpad physics and touch physics, but that would make it quite complex for anyone switching from the defaults. Probably the physics object should know about the
PointerDeviceKind.Another issue: on iPadOS itself, the trackpad actually has the same friction as touch, but when iPad app is running on an M1 mac, it uses Mac-specific scrolling friction. Right now those devices show up as
Platform.iOS, some refactor would be needed to represent this runtime scenario.Piinks commentedon Jul 19, 2022
Thank you for digging into this!
Yeah, it is updating clamping scroll physics, but also fixing that ballistic issue at the same time.
That is a really interesting idea, but probably really complex to implement. Flutter does not know what input devices are available until it actually receives the input, and there would be a lot of edge cases to account for when using both. Imagine a scroll animation running from mouse input is interrupted by a scroll animation from a trackpad... Right now all of scrolling in Flutter assumes one type of scroll physics, so supporting more than one would be tricky.
I think what it sounds like is that we might want to consider having proper desktop scroll physics. ClampingSP is based on Android, while BouncingSP is based on iOS. We have not actually compared/contrasted/considered what Mac, Linux and Windows scroll physics should be.
Emulators running on desktop can make this a bit murky - it does sound like the scroll physics are different on mac from iOS. If the iPad scrolling matches on the physical device, that is the source of truth. There are a lot of things that simulators are just a bit off by. Like in the above scroll_overlay, no matter how fine tuned you get it, it will always be just a bit off because of inconsistent compositing, performance, etc on simulators.
This is something we are really unlikely to do. Adding another target platform is a large scale breaking change for the framework, especially since iPadOS is really iOS.
moffatman commentedon Jul 19, 2022
So I think I will try to get a good match of Mac scrolling behavior and add it as a new default physics for Mac, and forget about different physics for trackpad vs touch. What do you think @Piinks ?
For the iOS app running in emulation, I can deal with it on my own apps, I have some code to detect if running in that environment and then I'll switch the default scroll configuration. You're right that it would be a big breaking change for a pretty small edge case.
Piinks commentedon Jul 19, 2022
That sounds awesome! Thank you so much for all of your contributions!
It could be that we add a platform-specific variation to BouncingScrollPhysics, rather than a whole new ScrollPhysics class, but I trust you'll be able to determine the best course there.
I don't think the scroll_overlay app has an underlying mac app in it for comparison, we'll have to add one in there to be able to compare the overlay like on iOS and Android.
Piinks commentedon Jul 19, 2022
Update: Actually it looks like that app doesn't even have mac enabled. 😜
moffatman commentedon Jul 19, 2022
I'm running the iOS version on "My Mac (Designed for iPad)". That's what those videos are from, in that mode the scroll events are generated from AppKit using the same physics as other mac apps. I don't know how to make one specifically for mac, I don't think you can put mix native and flutter on desktop yet?
Piinks commentedon Jul 19, 2022
Oh! TIL! I think it is ok to work off that then. :)
github-actions commentedon Oct 3, 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 -vand a minimal reproduction of the issue.