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
Re-evaluate usage of TextTruncator and optimize its performance #8124
Comments
During researching this problem a doing some study I noticed the following techniques, that might be helpful if we decide to optimize. For example, for
Source: Rendering: repaint, reflow/relayout, restyle I am not saying that we need to implement our own Resources that I've found to be helpful: And one interesting library that seems to be often recommended in relation to performance problems: FastDOM
|
Also see #7525 (comment) and #7525 (comment):
and #7525 (comment)
|
Regarding
Does anyone have any idea how to detect the initial page load reliably in a SPA? I experimented a bit with Vue lifecycle hooks and |
Were the measurements on TextTruncator taken before or after this PR was merged, btw? #8101 |
I think the basic mechanism we would probably have to use is that the SPA would need to explicitly report when it was done with initial page load, and then turn the resize sensor on after that. I don't think there would be a good way to do it systematically. The only other thing I can think of would be to do some sort of debounce across VueJS |
I have #8101 commits locally on a branch I worked on so it's possible that it was taken rather after, but I can't say for sure, because I fetched |
@rtibbles Are you referring to
Sounds interesting. It might be also good to have some fallback logic to make sure that resize sensor load won't be postponed forever, just in case there is some logic on a page that is regularly making changes. For example, to say that if it wasn't loaded after 20 seconds, load it no matter what's going in in |
Another idea regarding detection of the right moment to start the resize sensor - what about playing with |
In any case, before we dive into particular optimizations, it would be good to discuss some high-level questions raised in the description. I don't know what were the reasons for implementing |
For some context on the original motivations –
|
Closed by #8532 |
Observed behavior
TextTruncator
triggers layout reflows that on pages with many instances ofTextTruncator
can cause significant performance issues, as observed in #7525.This is the first part of the profile (at some point my laptop runs out of resources and doesn't record anymore) of Learn section of Ciencia Espacial topic containing 1151 sub-topics (which means 1151 of
TextTruncator
instances) of Ciencia NASA channel where the following bottlenecks can be observed:As can be seen from the following, for a page containing hundreds of
TextTruncator
instances, there is an enormous number of expensive style calculations and layouts/reflows run.Performance analysis for a single
TextTruncator
instance:(1)
TextTruncator
->mounted
->ResizeSensor
(KResponsiveElementMixin
) ->attachResizeEvent
(2)
TextTruncator
->ResizeSensor
(KResponsiveElementMixin
) ->resetExpandShrink
(3)
TextTruncator
->handleUpload
->shave
Currently, we use
TextTruncator
in the following components and can expect similar performance issues on all pages utilizing them:LessonContentCard
ChannelCard
ContentCard
Related
KResponsiveElementMixin
background by @indirectlylitLet's re-evaluate what are our requirements for text truncation in Kolibri while taking these performance issues into account:
TextTruncator
build aroundKResponsiveElementMixin
andshave
for so many instances of the component on one page valid?ResizeSensor
in some situations?Based on the outcome of the discussion, do we need to ask KDS team for any updates of
KResponsiveElementMixin
?This issue could set a precedent for recommended usage of
KResponsiveElementMixin
elsewhere that will be together with performance warnings ideally documented in KDS.Errors and logs
Source performance profile (can be loaded in Chrome)
Expected behavior
The components mentioned above are performance-wise optimized
User-facing consequences
Steps to reproduce
Context
Kolibri 0.15.0.dev0+git.20210520221349
Chrome
Ubuntu
The text was updated successfully, but these errors were encountered: