Skip to content

Conversation

@pulsejet
Copy link
Member

Some optimizations in the virtual scroller @skjnldsv

There are comments on the individual changes. Again, it's hard to measure performance here.

@pulsejet pulsejet requested a review from skjnldsv October 18, 2023 02:06
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import CustomElementRender from '../CustomElementRender.vue'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing import

class="files-list__row-icon-favorite"
:aria-label="t('files', 'Favorite')">
<FavoriteIcon />
<FavoriteIcon v-once />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icons don't need re-rendering

// Table head, body and footer
tbody {
will-change: scroll-position, padding;
contain: layout paint style;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some CSS tricks to improve rendering performance

// Adding scroll listener AFTER the initial scroll to index
this.$el.addEventListener('scroll', this.onScroll)
this.$el.addEventListener('scroll', this.onScroll, { passive: true })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passive listeners are faster

// Max 0 to prevent negative index
this.index = Math.max(0, index)
this.$emit('scroll')
this._onScrollHandle ??= requestAnimationFrame(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throttling this call to once per frame. Notably, this.$el.scrollTop is a getter and causes layout thrashing, so this is the most important change here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's something I wanted to experiment with! Nice take at this issue! It make sense :)

&::v-deep {
// Table head, body and footer
tbody {
will-change: scroll-position, padding;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about padding. Is it even a valid value for will-change ? 🤔

Copy link
Member Author

@pulsejet pulsejet Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well will-change takes <custom-ident> as a valid value so it's all up to the browser. I don't think there are any real optimizations for padding changes right now though 🤷🏻

@skjnldsv
Copy link
Member

Pushed some fixes, performances are definitely positively impacted!! 🚀

@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Oct 18, 2023
@skjnldsv skjnldsv marked this pull request as ready for review October 18, 2023 09:11
@skjnldsv skjnldsv requested review from a team, artonge, nfebe and sorbaugh and removed request for a team October 18, 2023 09:11
@pulsejet
Copy link
Member Author

Thanks for fixing this up @skjnldsv 😄

@skjnldsv skjnldsv requested a review from susnux October 18, 2023 18:12
@skjnldsv skjnldsv force-pushed the pulsejet/files-list-perf branch from fdca64b to 08c641d Compare October 19, 2023 06:23
@skjnldsv
Copy link
Member

/compile amend /

Signed-off-by: John Molakvoæ <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
@skjnldsv
Copy link
Member

Drone failure unrelated: https://drone.nextcloud.com/nextcloud/server/42176

@skjnldsv skjnldsv merged commit 4d5b794 into master Oct 19, 2023
@skjnldsv skjnldsv deleted the pulsejet/files-list-perf branch October 19, 2023 07:27
@juliusknorr
Copy link
Member

juliusknorr commented Oct 20, 2023

This seems to have caused a regression where file list headers are broken now and not rendering anymore. Namely recommendations app and text app readme rendering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants