-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
perf: switch file list to vue-virtual-scroller #40955
Conversation
Signed-off-by: Varun Patil <[email protected]>
We actually moved away from it purposely, sorry. EDIT: let me add a bit more context I feel like I should, but not gonna lie, I'm quite tired with all this Files work 🙈
There are still some performance improvements to have , that will come later like
|
@@ -50,9 +50,9 @@ | |||
<!-- Icon or preview --> | |||
<span class="files-list__row-icon" @click="execDefaultAction"> | |||
<template v-if="source.type === 'folder'"> | |||
<FolderOpenIcon v-if="dragover" /> | |||
<FolderOpenIcon v-once v-if="dragover" /> |
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.
v-once
is still a good idea! 👍
Ah I see, thanks for the explanation. I agree
Indeed it does seem better than before, but still not as fluid. Will try to profile this a bit to understand what's happening. BTW I might throw out a couple of PRs for some smaller optimizations; feel free to knock these down if they make a lot of sense. |
💯
🤗 🙇 |
So I did a deeper dive into this and thought I'd document my findings here. The reason using absolute positioning is faster is subtle. The current virtual list code does maintain the list of keys to be the same. Whenever the user scrolls down one element, the array Here's the problem: since the array was reordered, Vue needs to actually remove the first physical node and append it at the end and set up all hooks again. So even when the virtual DOM is untouched, the actual DOM is manipulated as the user scrolls down, which is quite slow. On the other hand in the case of using absolute positioning, even the actual DOM is untouched and only the CSS changes. Even better when using CSS transforms, since it all happens on the GPU. As a POC, I tried switching the list to use transforms and I can confirm that it gives the 60fps butter smooth scrolling effect. But the problem is, still, there's no easy way I've found to make this accessible. It might be possible to make the tab order work correctly using some JS, not sure how this'll fare with screenreaders though. Let me know if any thoughts @skjnldsv |
To be clear: I'm not suggesting we do this / it's a good idea. Just satisfying my academic curiosity. |
Considering the points above and the insane amount of accessibility issues we had to fix over the last months, I'm not taking any risks, especially for a subtle perf change :) But thanks for the research, this makes sense and is indeed quite insightful! 😉 |
This patch significantly improves the performance of the file list by using
vue-virtual-scroller
over the current simplistic implementation.vue-virtual-scroller
has excellent performance since it uses CSS transforms to place the virtual elements and has very good component reuse.The implementation isn't complete yet but I wanted to get some early feedback / thoughts.
It's somewhat hard to capture the improvement in a video, so here's a before and after with a 4x simulated slowdown:
Before:
https://github.com/nextcloud/server/assets/10709794/0d769798-3d85-44ea-a2b8-cd3fba0aeb53
After:
https://github.com/nextcloud/server/assets/10709794/1d2a2a83-0180-4a23-833b-12d6f69099fa