-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Increase Win32 trackpad polling rate, fix repeated swipes issue #37154
Conversation
shell/platform/windows/window.h
Outdated
@@ -294,7 +294,7 @@ class Window : public KeyboardManager::WindowDelegate { | |||
const static int kDirectManipulationTimer = 1; | |||
|
|||
// Frequency (Hz) to poll for DirectManipulation updates. | |||
int directManipulationPollingRate_ = 60; | |||
int directManipulationPollingRate_ = 240; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining this magic value?
shell/platform/windows/window.cc
Outdated
@@ -110,7 +110,7 @@ void Window::InitializeChild(const char* title, | |||
ZeroMemory(&dmi, sizeof(dmi)); | |||
dmi.dmSize = sizeof(dmi); | |||
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dmi)) { | |||
directManipulationPollingRate_ = dmi.dmDisplayFrequency; | |||
directManipulationPollingRate_ = 4 * dmi.dmDisplayFrequency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 240Hz and this 4 * frequency
, are we assuming a 60Hz of something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming the display is 60 Hz in case we aren't able to get the actual value. When calling Update()
at 60 Hz I have seen 30 Hz or worse actual updates. Not sure what is the root cause, but when polling rate is increased the experience feels a lot better. At worst I saw 200ms between events. I did x4 to be safe as the velocity tracker which controls momentum only looks at the latest 100ms of events.
I didn't spend much time on optimization here, it may be that with further testing 3 * displayFrequency
might work just as well.
I'm ok with the logic change. But I'm not so sure about the polling frequency change. If it resolves an issue that observable from a hardware device, we can land it, but I think it's better to split it into a separate PR, with more explanation (the issue it resolves, how to reproduce and verify the fix), as well as a test exempt if necessary. |
OK I can split it out and also collect some data as to update polling rate vs actual update rate |
Looked into it and I had 2 mistakes in my |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4d008d2
to
16ae4cb
Compare
…114720) * d413cc511 Add unreachable for vulkan switches (flutter/engine#37324) * e32bff47e Copy Windows gen_snapshot to a standard location (flutter/engine#37318) * af1a2da13 Increase Win32 trackpad polling rate, fix repeated swipes issue (flutter/engine#37154) * 28e1ea0cc Roll Fuchsia Mac SDK from JKfnEvEVIL_Cg3_9f... to jAKH68TYoKUA5HNS2... (flutter/engine#37325)
…ter#37154) * Windows trackpad improvements * Address feedback, remove dynamic polling rate * Adjust comment
…lutter#114720) * d413cc511 Add unreachable for vulkan switches (flutter/engine#37324) * e32bff47e Copy Windows gen_snapshot to a standard location (flutter/engine#37318) * af1a2da13 Increase Win32 trackpad polling rate, fix repeated swipes issue (flutter/engine#37154) * 28e1ea0cc Roll Fuchsia Mac SDK from JKfnEvEVIL_Cg3_9f... to jAKH68TYoKUA5HNS2... (flutter/engine#37325)
…lutter#114720) * d413cc511 Add unreachable for vulkan switches (flutter/engine#37324) * e32bff47e Copy Windows gen_snapshot to a standard location (flutter/engine#37318) * af1a2da13 Increase Win32 trackpad polling rate, fix repeated swipes issue (flutter/engine#37154) * 28e1ea0cc Roll Fuchsia Mac SDK from JKfnEvEVIL_Cg3_9f... to jAKH68TYoKUA5HNS2... (flutter/engine#37325)
Increase polling rate from 60 Hz to 240 Hz or 4 times the monitor refresh rate. It seems like the polling rate does not match 1:1 with the returned updates, eventually leading to scrolls with missing framework momentum. This was because the gap between updates was too large (above 40 ms), so the velocity tracker in the framework returned an estimate of zero.
Also fix an issue introduced in #34452, where the transition to using inertia means that repeated swipes had no opportunity to reset the transform matrix. Now pan zoom updates will compare with the gesture data at pan zoom start time. Eventually, once swipes stop, the matrix will be reset to zero.
Fixes flutter/flutter#114082
Pre-launch Checklist
///
).