-
Notifications
You must be signed in to change notification settings - Fork 1.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
Two small code changes with (hopefully) a major perf impact. #745
Conversation
- Added requestAnimationFrame wrapper to the updateGeometry module - Added will-change transform to the css wrapper class to promote to layer.
Just wrapping |
@DimitarNestorov Measurement cannot always be separated into another frame because PS sometimes decides whether |
@DimitarNestorov Happy for that approach - I haven't had loads of time to work on this, but noticed there were a couple of quick wins that I could implement in 10 mins, so I did! One approach is to reject and re-implement fully (a task I personally don't have the resources to complete myself) another is to merge because this is better than the current state (no requestAnimationFrame at all), and create an issue/task for someone to upgrade at a later date. Given there was an issue created and subsequently closed on this due to lack of resource, my feeling is that an interim 'better than nothing' approach is definitely more beneficial. I am now using my fork in my project, so I'm not really bothered either way, just thought others might benefit :) EDIT just re-read and realised you are proposing to re-create the PR yourself - I initially missed that part. I'm fine with that! 💃 |
@utatti Let's keep this PR open so that we can benchmark both implementations to see which one actually performs better. |
A turn of events has occurred. It seems I was wrong that measurements and mutations must happen at different Splitting Since all the measurements in Simply put: I would love to see this PR merged. More on the topic: wilsonpage/fastdom#35 |
- Fixes bug where only the last instance to request a geometry update would actually have its geometry update. - Only trigger one geometry instance per update per frame
I updated my branch today - I noticed that my last implementation would only cache a single instance's request to update geometry. This caused issues when there are multiple instances of perfect scrollbar on a page whereby if both needed a geometry update (e.g. resize, initial load, etc.), only the last one to register call the Furthermore, multiple |
I noticed perfectscrollbar doesn't run perfectly on mobile or low performance PCs, so have tried to make a couple of simple optimisations.
Basically I am just wrapping the exported function from
update-geometry.js
inrequestAnimationFrame
, caching the last value it was called with. This ensures the code runs at the right time (at the start of the frame), and also limits the frequency at which it is called not to be faster than the browser can render it. I have also added awill-change: transform
property to the CSS - this promotes the scrolling area to a layer, which allows it to be repainted separately (or something like that, I'm not an expert!).On a Galaxy S8 with a medium sized scrolling list, these two changes resulted in an increase from about 20fps to about 50fps average. With just one of two changes (either/or), the increase was up to about 30-35fps. I would be interested to see the numbers from other people's devices.
Note the following:
/dist
or version or anything - assume that's something @utatti will do.Comments & input very welcome!