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

High CPU usage stuck in infinite loop of LoadMore waiting for isFullyLoaded #533

Closed
1 task done
sh4r1k7 opened this issue Sep 20, 2024 · 11 comments
Closed
1 task done
Labels
i-bug Something might be broken in Tab Stash
Milestone

Comments

@sh4r1k7
Copy link

sh4r1k7 commented Sep 20, 2024

OS Version

Linux

Browser Version

Firefox 130

Tab Stash Version

3.1

Number of Open Tabs

1

Number of Stashed Tabs

11

Total Number of Bookmarks

1000

Performance Profile Link

https://share.firefox.dev/4etNSB3, https://share.firefox.dev/4e91P7L

Installed Extensions

Numerous but none that conflict (I don't know an easy way to get the full list, and don't think it matters - let me know if you really need it).

Problem Description

High CPU usage even with a handful of stashed tabs.
Profiler shows tab stash is spinning inside a loop waiting for isFullyLoaded which is never set true.

Steps to Reproduce

Nothing, just being idle with the sidebar or stash tab open (and active).

Impact

Tried restarting, reinstalling, clearing etc. Bogs down FF and makes pages laggy and in extreme cases unresponsive.

This only happens when either the side-bar or tabstash-tab is open - if the tab is open but isn't active then CPU drops to <1%.

One workaround is to toggle the visibility but I prefer to always see the side-bar as I use it frequently. Apart from the context-switch and visual jitter, toggling the side-bar is slow as tabstash reloads all the bookmarks each time which takes about 2sec to finish, which is a huge disruption of flow.

Additional Details

I thought maybe I have too many tabs stashed but after reinstalling the extension and reducing the number of stashed tabs to <10 the profile shows the same issue (though of course it gets much worse with 100+ tabs).

Vote for This Issue

  • Readers: If you are also experiencing this problem, please vote for it by giving the ORIGINAL POST a thumbs-up using the 😃 button below. You are welcome to leave comments and discuss the issue if you have more details to add, but "Me too!" comments are not counted by the voting system.
@sh4r1k7 sh4r1k7 added the i-performance Everything works fine, but something is too slow label Sep 20, 2024
@josh-berry
Copy link
Owner

Hm, that's quite surprising; do you see any error logs when this happens? Normally if loading fails, an error should be printed to the console.

It might be convenient to look at the console in the full-tab view, but here's how to access the console for the sidebar: https://github.com/josh-berry/tab-stash/wiki/Collect-Error-Logs

I do see a bug that could cause Tab Stash to retry too fast when things fail, but that doesn't explain why it's trying to load bookmarks multiple times to begin with.

@sh4r1k7
Copy link
Author

sh4r1k7 commented Sep 21, 2024

Nothing at all in the console, neither the extension one nor Firefox main console (I should've mentioned that).

I'm not setup for any serious debugging of extensions but if there's something you want me to look into I can give it a shot.

Is there any reason you don't have a backoff delay instead of immediately waiting for the next idle tick?

@josh-berry
Copy link
Owner

Is there any reason you don't have a backoff delay instead of immediately waiting for the next idle tick?

I do; it turns out it's buggy and doesn't work as intended. 🤦 I will work on fixing it for the next release.

Nothing at all in the console, neither the extension one nor Firefox main console (I should've mentioned that).

Hm, so one thing I'm wondering is: does the "+" character in the count of tabs/groups in the search box ever go away? e.g. Does it always say "Search NNN+ groups, MMM+ tabs" or does it eventually change to "Search NNN groups, MMM tabs"?

If the "+" never goes away, that suggests to me that there is something amiss in your bookmarks DB itself; exporting and re-importing all your bookmarks might make the problem go away (though I'd still like to understand why it happened in the first place, heh).

If the "+" goes away fairly quickly (or doesn't appear at all), but the high CPU persists, that suggests a problem in the UI itself unrelated to bookmarks, maybe something peculiar to Firefox on Linux, or your Firefox setup in particular. (I will say I've tried to reproduce this on Linux myself, unsuccessfully, under Kubuntu with a fresh/unconfigured copy of Firefox.)

@josh-berry josh-berry added i-bug Something might be broken in Tab Stash and removed i-performance Everything works fine, but something is too slow labels Sep 21, 2024
@sh4r1k7
Copy link
Author

sh4r1k7 commented Sep 22, 2024

The '+' appears then disappears quickly once everything has loaded.

I synced my firefox to a Windows machine and cannot reproduce the issue there (with all the same extensions etc, minus the 1000+ bookmarks).

I'll try to export-import the bmarks and see if that solves it (but seems unlikely from your comment).

@josh-berry
Copy link
Owner

Okay, thanks. That tells me enough that, after spending some quality time reading the code, I think I have a pretty good theory about what's happening now.

It's not even related to the backoff (though I need to fix that too)--basically there is a corner case where we are stuck in an infinite loop doing nothing even after the folder has been loaded.

Unfortunately there is not a workaround for this, so I'll try to get a release done as soon as possible. (If you are feeling adventurous enough to help test, it's not that hard, I can point you at the instructions once I land the fix. And you'll get the fix that much faster. :) )

I am still really curious why you're hitting it consistently on Linux and nowhere else. (And why I've not been able to get it to reproduce on Linux either.)

  • Have you (or has your distro) modded Firefox at all? Created any userChrome.css files, that sort of thing?
  • Are you able to reproduce it on Linux without any extensions installed?

josh-berry added a commit that referenced this issue Sep 22, 2024
If the `<load-more>` component is unmounted while it is loading, AND
while `is-fully-loaded="false"`, the loader function will get stuck in
an infinite loop.  Stop the loader from running by explicitly noting the
component is no longer visible when it is unmounted.
@josh-berry
Copy link
Owner

josh-berry commented Sep 22, 2024

I've pushed a fix (I hope). If you'd like to try it out without waiting for a release (which might take a bit), here's how to build Tab Stash yourself and get it running in your browser:

https://github.com/josh-berry/tab-stash/blob/master/docs/contributing.md#getting-started

No worries if you don't want to spend time/energy on this, of course, but if you do want to try it out, it would be helpful to know if the fix works for you or not.

(I also did fix the exponential-backoff issue separately, fwiw, though it wouldn't have mattered here.)

@josh-berry josh-berry added this to the 3.2 milestone Sep 22, 2024
@sh4r1k7
Copy link
Author

sh4r1k7 commented Sep 25, 2024

I imported all my bmarks into a new profile with no other ext installed - same issue, in fact worse, CPU is at 20%! (my current setup sits at about 6-10%).

I'll try your fix soon if time permits, busy week - but thank you for actioning this so quickly :).

@josh-berry
Copy link
Owner

No problem, thanks for taking the time to collect the profiles and dig into it a bit—I wouldn't have been able to push a fix so quickly without your help doing that work up front. :)

@josh-berry
Copy link
Owner

I'm going to go ahead and close this since I need to get a release out soon, but do let me know if you're still seeing the issue once the release lands. Thanks again!

@sh4r1k7
Copy link
Author

sh4r1k7 commented Oct 10, 2024

Hi @josh-berry, fix confirmed! Thanks again :)

@josh-berry
Copy link
Owner

Great, I’m glad to hear it! Thanks for letting me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i-bug Something might be broken in Tab Stash
Projects
None yet
Development

No branches or pull requests

2 participants