rNeomy / auto-tab-discard

Use native tab discarding method to automatically reduce memory usage of inactive tabs

Home Page:https://webextension.org/listing/tab-discard.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Freezes firefox on startup when using 'Prepend a symbol' feature witha large number of tabs

pallaswept opened this issue · comments

I've been using another addon to suspend my tabs for some time, and it works well, but it's UX was a little cumbersome - I had to open the add-on's UI, change tabs, and press a button, to manually trigger suspension of all tabs. I went to look for an alternative, and this one is by far the most popular on AMO, and is a "recommended" addon (Congrats on both counts!) and had a much easier way to manually trigger the suspension, so I installed it and gave it a try.

At first, it seemed to work perfectly well, I disabled the other addon, and switched to this one instead, I found it to be equally (perhaps more) featured, but also it had a better UX. I was very happy. I used it for at least an entire day before I had any trouble, and had restarted Firefox several times during that period.

Then I restarted my PC today, after closing a fully-working Firefox session, and when I started Firefox, it froze up. Presuming I had some kind of corruption, I restored from a backup earlier in the day (I use BTRFS so I had hourly snapshots), started up this restored session which had been working fine when I used it, and Firefox still froze up at startup. I then restored from a backup from the previous day, a past Firefox session, which had worked, shut down, and started up again with no problem, so that one had to be OK....annnnd nope, still froze. I went through my profile trying to think of things I might have changed, disabled this addon and CookieAutoDelete, since I'd changed both of their configurations in that past 24 hours)... and it STILL froze up at start.

In the end, I started in private mode, so I could entirely disable this addon and CAD, then started a normal session, and it was still freezing up - but realised that while the browser was largely unresponsive, it would in fact respond to mouse clicks, maybe after several minutes passed for each click, so I waited patently for about 30 minutes until the browser became sufficiently responsive that I could reload all of the tabs, so as to bring them out of their suspended state. I then restarted FF, and boom, fixed. I enabled CAD again, restarted, still good. Enabled this addon, restarted, and....frozen again.

At this point, I had 10 browser windows open, with 50-100 tabs in each. So, that amounted to a LOT of suspended tabs. Total suspender is currently reporting 448 suspended tabs, so it would have been in that neighbourhood, likely more. Quite possibly >500 (thinking round numbers) or >512 (thinking about binary number limitations). It seems that there's some kind of limit to the number of suspended tabs which this addon can handle, and beyond that, it freezes up, and freezes the whole browser along with it.

Another theory I have, as to why it seemed to work, is that in previous restarts, I had 9 windows open, but when it failed, I had 10 browser windows open, and this add-on set to suspend tabs when there are 10 tabs open (after 30 minutes). So maybe it was that it was suspending instantly and started sooner than expected?

I also had changed the setup to change the icon, to the 'power' icon given in the UI, so perhaps it was something to do with it changing the titles? I'm not sure.

Whatever it was, I suspended all the same tabs, using that other add-on, and Firefox restarts perfectly happily. If I suspended them with this addon, Firefox would freeze up on startup.

I tried increasing the maximum number of tabs to discard to 1000 (so it was >500 & >512 as mentioned earlier), and disabled changing the tab favicon.....and after that, triggering the tab discard just did nothing at all. After that, I reduced the maximum from 1000 to 100 (ie, increasing it from 500 to 1000 didn't work, it broke it, so let's try going the other way)...and it still did nothing at all.

Sorry I can't give more info here. I can't really test it because as soon as I enable it, my browser freezes. I did start Firefox from the terminal, so I could see if any errors were returned, but none were. If you have any suggestion as to how I might help, please let me know.... but my experience with is addon has either been that it fails to function whatsoever, or it completely breaks my browser.

By a process of elimination I have narrowed this down to an issue with the "Prepend a symbol to the discarded tabs (e.g. 💤 or ⏻︎) (if possible)" Feature. Reproduction steps follow:

It may be relevant that I have Firefox configured to load ALL tabs at startup (browser.sessionstore.restore_on_demand=false) - I have a powerful machine that can handle it just fine, and I don't want to wait around every time I click on a tab from the saved previous session which has not been loaded. I have not altered the setting to load them 'lazily' (browser.sessionstore.restore_tabs_lazily=true as per default), so if the session contains 1000 tabs across 5 windows, I am not loading 1000 tabs simultaneously, but all 1000 tabs will eventually be loaded when I start.

I did not always have this issue, I did not see this issue occur until I had 10 browser windows and over 500 tabs, so a session with at least 10 windows and at least 600 tabs should be used for this process.

  • Configure Firefox to load the previous session on startup, and to load all tabs (the above setting in about:config)
  • Enable the 'Prepend a symbol...' feature by putting a character in that box (I went with the ⏻︎ character since I use a monochrome theme/userChrome - probably best to do the same, for reproduction to be identical to mine)
  • Discard all tabs - It must be large number of tabs (in the region of 600+ tabs)
  • Note the titles' change with the character inserted as intended
  • Exit Firefox
  • Start Firefox
  • Firefox will appear to freeze (but is actually just taking some 60+ times longer, to start - as in, a session which normally takes 30 seconds, will take >30 minutes, and the browser will be unresponsive the entire time
  • Note that in spite of all tabs being loaded due to the abovementioned setting, many of them will have the prepended character, as though they are discarded, even though none should have been discarded yet because the time limit has not been reached.

Steps to recover and work around this bug:

  • Wait for the faulty session to eventually become responsive. It will take dozens of minutes on a fast system. Possibly hours. It will be a LONG time, sorry!
  • Remove the character in the abovementioned option, so that tab titles will not be modified when discarded. Don't forget to save settings
  • To ensure that the addon does not discard tabs while we follow this process, disable the addon temporarily - the aim here is to have zero discarded tabs / zero tabs with modified titles
  • Select all tabs in the window, then refresh them all (so as to un-discard them)
  • Repeat the above for all windows, so that all tabs are now loaded and not discarded
  • Re-enable the addon
  • Discard all tabs
  • Note that tabs are discarded, but titles are unaltered
  • Quit Firefox
  • Start Firefox
  • Note normal startup

Steps to confirm that this feature is the cause:

  • Disable the addon temporarily (to allow us to ensure all tabs are loaded / not discarded)
  • Select all tabs in window, reload them all to ensure they are all loaded / not discarded
  • Repeat for all windows (repeating the above process to ensure a direct comparison of behaviour)
  • Re-enable the addon
  • Re-enable the 'Prepend a symbol...' feature by putting a character in the textbox and save your settings.
  • Discard all tabs (same process as above)
  • Note the titles changing when the tabs are discarded
  • Quit Firefox
  • Start Firefox
  • Watch it effectively freeze

So obviously, there's some kind of problem with loading tabs from a saved session, which have the modified title. It seems to only occur under certain other circumstances, or a mix of them, those being:

  • 10+ Windows
  • Greater than 500 discarded tabs (at least, maybe it needs 512 or 600, I can't say.)
  • Disabled loading tabs on demand (ie, load all tabs in the session, immediately on startup)
    but any or all of these criteria can be met, and the browser will function normally, even with ATD running, and the only change is to prepend a character to the title.

Hope this helps you to narrow down the code that is to blame here. I now have a workaround, so I an enjoy this addon and it's more pleasant UX, but I really do like the 'prepend a symbol' feature, so it would be awesome if we could get it fully working. Please let me know if there is anything I can do to assist.