-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix: [Zoom] Performance improvements (especially w/ trackpad zoom) #3396
Conversation
Still a work-in-progress. Standard mouse wheeling is a bit wonky now (doesn't always zoom). Delta accumulation logic needs tweaks. Also, unsure if this is a breaking API change. IMO, the default behavior should be the zoom detents ( Open to any ideas, changes, etc. This is just a start! |
This might help explain why throttling wasn't the right approach: In Audition, you can scroll as quickly as you want, but it's a stepped zoom rather than a fluid one. Also, maybe a Audition.mp4 |
src/plugins/zoom.ts
Outdated
} | ||
|
||
// Reset the accumulated delta | ||
this.accumulatedDelta %= this.options.deltaThreshold |
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.
Here it can probably be just set to 0?
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.
I'm gonna rework some of this. I'll mark the PR as ready for review once I think it's in a good spot.
Co-authored-by: katspaugh <[email protected]>
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.
Thanks! 👍
Sure, thanks for the review! Thoughts on the option itself? |
So to clarify, you ideally want the waveform to re-render every time the mouse wheel clicks, but we cannot count clicks, only a (pixel?) delta? Looking at this MDN article, it looks like we can only see what mode the mouse wheel is in (scrolling per page, per line or per pixel). And of course touchpads and trackballs don't have notches at all... So I think 10 is a sensible default, especially if your two mice are around that ballbark. @HoodyHuo @cmorbitzer good with you? |
Right. Too many re-renders = bad news for those on lighter-weight computers. Step zoom is just the safer route. Even when I compare Adobe Audition vs. iZotope RX with trackpad zoom, RX has smooth zoom, and my CPU usage jumps to 150-200+. With Audition (step zoom), my computer doesn't even get its heart rate going. 😁 |
LGTM I don't have an opinion on performance, but 10 felt choppy to me as a user, where 5 felt seamless enough. Do we get much of the same resource benefit by setting the threshold to 5? |
A setting of 5 had more spikes for me (on a Mac Studio), but still better than totally smooth zoom. Maybe we default delta threshold to 5? I can test in a bit, and I'd like to update the docs a bit to explain this setting better. |
Yep, 5 is good. Not as good as 10, but a good middle ground. Just updated the code, and I think the description for this setting will do. |
Thanks! |
@ffxsam Even setting the Could we not use a throttling instead? I mean user scrolls very quickly, but we only re-draw once after the scroll is over. It would not be as fluid but more stable. |
@bernardwiesner Hey Bernard! I'm honestly not sure. If we used throttle, that would mean that scroll events would have no visible effect until the user stopped scrolling, which is not ideal. If you're experiencing any kind of bug or performance issue, please feel free to open a new issue. Thanks! |
Short description
Zooming with a trackpad was causing huge CPU spikes due to constant redraws. This PR imposes rate limiting via a delta threshold before actually redrawing the waveform.
Implementation details
Debounce & throttle were not appropriate here, as we don't necessarily want to throttle the events, we just want to ignore the "in-between" delta values and have a more notched zoom (a la Adobe Audition).
How to test it
Test using any trackpad with smooth scrolling (i.e. lots of event firing when scrolling).
Checklist