Skip to content
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

Summary: fix slowness due to layout thrashing when reloading a large … #12661

Merged
merged 6 commits into from
Dec 29, 2019

Conversation

panarom
Copy link
Contributor

@panarom panarom commented Dec 21, 2019

…set of status updates

in order to limit the maximum size of a status in a list view (e.g. the home timeline), so as to avoid having to scroll all the way through an abnormally large status update (see #8205), the following steps are taken:
•the element containing the status is rendered in the browser
•its height is calculated, to determine if it exceeds the maximum height threshold.
Unfortunately for performance, these steps are carried out in the componentDidMount(/Update) method, which also performs style modifications on the element. The combination of height request and style modification during javascript evaluation in the browser leads to layout-thrashing, where the elements are repeatedly re-laid-out (see https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing & https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Performance_best_practices_for_Firefox_fe_engineers).
The solution implemented here is to memoize the collapsed state in Redux the first time the status is seen (e.g. when fetched as part of a small batch, to populate the home timeline) , so that on subsequent re-renders, the value can be queried, rather than recalculated. This strategy is derived from #4439 & #4909, and should resolve #12455.

Andrew Lin (https://github.com/onethreeseven) is thanked for his assistance in root cause analysis and solution brainstorming

@panarom
Copy link
Contributor Author

panarom commented Dec 21, 2019

hold off on merging this: I've introduced a bug when viewing a status thread where if the text is too long it's hidden by a too-small div

@Gargron
Copy link
Member

Gargron commented Dec 21, 2019

Please also check code style errors found by CodeClimate!

@panarom panarom force-pushed the issue-12455—slow-back-button branch from 58f21c4 to ee1abd6 Compare December 27, 2019 15:53
…set of status updates

in order to limit the maximum size of a status in a list view (e.g. the home timeline), so as to avoid having to scroll all the way through an abnormally large status update (see mastodon#8205), the following steps are taken:
•the element containing the status is rendered in the browser
•its height is calculated, to determine if it exceeds the maximum height threshold.
Unfortunately for performance, these steps are carried out in the componentDidMount(/Update) method, which also performs style modifications on the element.  The combination of  height request and style modification during javascript evaluation in the browser leads to layout-thrashing, where the elements are repeatedly re-laid-out (see https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing & https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Performance_best_practices_for_Firefox_fe_engineers).
The solution implemented here is to memoize the collapsed state in Redux the first time the status is seen (e.g. when fetched as part of a small batch, to populate the home timeline) , so that on subsequent re-renders, the value can be queried, rather than recalculated.  This strategy is derived from mastodon#4439 & mastodon#4909, and should resolve mastodon#12455.

Andrew Lin (https://github.com/onethreeseven) is thanked for his assistance in root cause analysis and solution brainstorming
…t is restored

e.g. when navigating from home-timeline to a status conversational  thread and <Back again
@panarom panarom force-pushed the issue-12455—slow-back-button branch from b1e88da to c5f8fd5 Compare December 28, 2019 02:03
@Gargron Gargron merged commit 31f7c3f into mastodon:master Dec 29, 2019
zunda added a commit to zunda/mastodon that referenced this pull request Dec 30, 2019
Gargron added a commit that referenced this pull request Dec 30, 2019
zunda added a commit to zunda/mastodon that referenced this pull request Dec 30, 2019
Gargron added a commit that referenced this pull request Dec 30, 2019
panarom added a commit to panarom/mastodon that referenced this pull request Jan 2, 2020
…lableList is restored"

This reverts commit 07e2614.

accidentally merged spurious code in mastodon#12661.  mastodon#12735 removes the slowdown that this code was trying to solve; and other functionality successfully restores the view state of the list
panarom added a commit to panarom/mastodon that referenced this pull request Jan 2, 2020
… identical value"

This reverts commit c93df21.

accidentally merged spurious code in mastodon#12661.  mastodon#12735 removes the slowdown that this code was trying to solve; and other functionality successfully restores the view state of the list
@panarom panarom mentioned this pull request Jan 2, 2020
Gargron pushed a commit that referenced this pull request Jan 2, 2020
* Revert "persist last-intersected status update and restore when ScrollableList is restored"

This reverts commit 07e2614.

accidentally merged spurious code in #12661.  #12735 removes the slowdown that this code was trying to solve; and other functionality successfully restores the view state of the list

* Revert "cache currently-viewing status id to avoid calling redux with identical value"

This reverts commit c93df21.

accidentally merged spurious code in #12661.  #12735 removes the slowdown that this code was trying to solve; and other functionality successfully restores the view state of the list
@impiaaa
Copy link

impiaaa commented Feb 18, 2020

My instance is on 3.1 now, and it does seem better! Thanks!

@ClearlyClaire
Copy link
Contributor

This reintroduces a lot of issues with the TL moving on its own when a status is deleted etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing "back" takes 5 seconds
4 participants