-
Notifications
You must be signed in to change notification settings - Fork 273
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
[Bug] Closing multiple tabs is slow if animation is disabled #3383
Comments
@piroor, I just wanted to make sure you saw this one. Still has the "needs-triage" tag. |
Thank you for detailed investigation! I agree that the current mechanism can trigger too many function calls to update tree indentation. Such needless calls needs to be reduced. My concern about the PR #3384 is: it will introduce a regression around some situations like tree collapsion/expansion. With the present version, you'll see shallowly indented tree without delay when you expand a deeply nested tree. But with the change you proposed, you'll see "very deeply indented tree" at first and it will be updated to "shallowly indented tree" with a delay. (TST automatically adjusts indent width of tree based on currently visible tree at all time.) I'm afraid that such a visual flicking may stress people suffered from an epileptic seizure - we need to remind that the disabled animation mode is used by no only performance oriented people but handicapped people also. Anyway the performance issue you mentioned is really serious with large number tabs. As a compromise, I've introduced a change. The main idea is based on your PR but there is a difference: the delayed update is activated only when the function is called over 10 times at a time. I hope the change helps you. |
After more experiments, now TST updates max indent of collapsed/expanded tree with less function call and without delay. Of course the threshold mechanism is also still available and it should be effective for other cases like reported here - it is mostly equivalent to your PR. Thanks to mention about this performance issue I missed! |
Abstract
When closing multiple tabs, it appears that
updateVisualMaxTreeLevel
is called once per tab closed if animation is disabled.Every time a tab is closed,
reserveToUpdateVisualMaxTreeLevel
is called, which is supposed to queue/debounce calls toupdateVisualMaxTreeLevel
.If animation is enabled,
reserveToUpdateVisualMaxTreeLevel
sets a timeout to ensure thatupdateVisualMaxTreeLevel
is only called when the tabs are all finished closing. However, if animation is disabled,reserveToUpdateVisualMaxTreeLevel
will always callupdateVisualMaxTreeLevel
.This is a problem because not only does
updateVisualMaxTreeLevel
require an expensive CSS update, but it looks through every tab in order to determine the maximum tree level. This makes performance quadratic.For example, let's say you have 200 tabs open. That's a lot, so you decide to clean up after yourself and close 150 of them. Here's what will happen:
reserveToUpdateVisualMaxTreeLevel
, and it queries 199 tabs to figure out what the max tree level is.reserveToUpdateVisualMaxTreeLevel
queries 198 tabs.reserveToUpdateVisualMaxTreeLevel
queries 197 tabs.reserveToUpdateVisualMaxTreeLevel
queries 196 tabs.reserveToUpdateVisualMaxTreeLevel
queries 50 tabs.In total, we end up making 150 individual CSS updates and performing queries on 18825 tabs. This gets much worse the more tabs you close--if you close 1000 tabs, for instance, TST will search through at least 500,500 tabs.
Steps to reproduce
reserveToUpdateVisualMaxTreeLevel
.Here's a performance profile that I recorded which demonstrates the problem.
Expected result
Closing multiple tabs should be relatively fast.
Actual result
Closing multiple tabs freezes the entire WebExtensions process for a good few minutes, and it gets worse the more tabs you have open.
Environment
The text was updated successfully, but these errors were encountered: