rNeomy / auto-tab-discard

Use native tab discarding method to automatically reduce memory usage of inactive tabs
https://webextension.org/listing/tab-discard.html
Mozilla Public License 2.0
906 stars 79 forks source link

Discard inactive tabs after X minutes doesn't work #276

Open icetbr opened 2 years ago

icetbr commented 2 years ago

Hi, I don't know if there is a limit, but I set it to 1440 minutes (one day) and it makes no difference.

Using latest firefox

beyhh commented 2 years ago

Hi there, same here. I'm glad it's not just me. This feature is actually really cool and needed on my side ;-) Would love to see this fixed.

rNeomy commented 2 years ago

Can you provide more info?

Turn the debugging mode on from the options page then open your browser console (Ctrl + Shift + J). See if you get any info on why there is no automatic discarding.

@beyhh, do you have the issue on Firefox too?

beyhh commented 2 years ago

Confirmed. I also use Firefox. Will try the Debugging mode...

beyhh commented 2 years ago

I tried the debugging mode but I'm not familiar enough here so I cannot interpret this correctly and don't even know if Auto TAB is creating those. Simple test: open a bunch of tabs, set the time to close the tab to 1h and you will see that the tabs are still open the next day. In the log window I see mainly two messages:

Promise rejected after context unloaded: Actor 'Conduits' destroyed before query 'RuntimeMessage' was resolved

and

Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.

Less frequent:

[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMWindowUtils.addSheet]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/ExtensionCommon.jsm :: runSafeSyncWithoutClone :: line 73" data: no]

and

Exception { name: "NS_ERROR_NOT_AVAILABLE", message: "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIHttpChannelInternal.remoteAddress]", result: 2147746065, filename: "resource://devtools/server/actors/network-monitor/network-observer.js", lineNumber: 990, columnNumber: 0, data: null, stack: "_onResponseHeader@resource://devtools/server/actors/network-monitor/network-observer.js:990:5\n_dispatchActivity@resource://devtools/server/actors/network-monitor/network-observer.js:563:14\nNetworkObserver.prototype.observeActivity<@resource://devtools/server/actors/network-monitor/network-observer.js:672:12\nexports.makeInfallible/<@resource://devtools/shared/ThreadSafeDevToolsUtils.js:103:22\n", location: XPCWrappedNative_NoHelper }

icetbr commented 2 years ago

I don't know if this helps

image

rNeomy commented 2 years ago

Thanks guys, will take a look. btw does it work for instance if you set the period to 10 minutes?

icetbr commented 2 years ago

It does, although not all tabs are put to sleep, but this might be another issue.

icetbr commented 2 years ago

It is very random, there are tabs that never sleep, others that sleep after a few seconds. Then the ones that doesn't sleep suddenly... sleeps.

beyhh commented 2 years ago

But this ticket is actually about discarding the tab all together. That does not seem to work, even when I put in Firefox to 10 minutes. I would need this feature so badly - you have no idea... ;-)

icetbr commented 2 years ago

I still think the extension is pretty usable, indispensable even.

I white list some sites to never sleep, I use Vide Resumer so I don't loose my play position in youtube.

My tabs are organized so the right most are the ones I keep using most often, so they usually don't get discarded, and when they do they come back very fast anyway.

askeydev commented 2 years ago

Yes, I just installed today and tested at 1 minute. Tabs did not discard after one minute, but seems to mostly discard by 15 minutes. My plan is to use 60 minutes normally to avoid excessive reloading. I turned on "Display logs" for debugging, but not sure where these logs are. (Firefox on Win 10)

askeydev commented 2 years ago

Round 2: Oddly, the one tab it did not close within 5 minutes the first round, it closed at 1 minute this time. That was the only tab I saw close at 1 minute. After 2 minutes, must of the rest of the expected tabs closed, but not all. Note: I probably have 50-60 tabs open in 8-10 windows across 6 virtual desktops. I am only monitoring one screen with two Firefox windows and at least 4 tabs per window (not including the add-on tabs). After 6 minutes, one of the tabs that closed previously is still not closed. My testing is manual, so timings may be plus or minus 30 seconds. After reactivating(clicking) all the tabs, 1 tab is discarded after 2 minutes. The one tab that did not discard in the initial Round 2 test was still active for 5-10 minutes after reactivating all the other tabs, but did discard by the 20 minute (overall from the start of Round 2) mark. All the other tabs are still active 12 minutes after reactivating them (about 22 minutes overall). 31 minutes in on Round 2, 21 minutes after reactivating the tabs, multiple discarded, still leaving one that should have discarded. One note: at the 31 minute mark I switched from the options page tab to a normal tab and within seconds I saw the icon change for 4 tabs. I was going to send my settings export, but even though I saved the period at 1 minute, the export shows "period": 60, It looks like all other values may be correct, so will send. Attachments are not working, so here it is: { "chrome.storage.local": { "./plugins/blank/core.js": true, "./plugins/dummy/core.js": false, "./plugins/focus/core.js": false, "./plugins/force/core.js": false, "./plugins/new/core.js": false, "./plugins/next/core.js": false, "./plugins/previous/core.js": false, "./plugins/trash/core.js": false, "./plugins/unloaded/core.js": false, "./plugins/youtube/core.js": true, "audio": true, "battery": false, "click": "click.popup", "faqs": true, "favicon": false, "favicon-delay": 500, "force.hostnames": [], "form": true, "go-hidden": false, "idle": false, "idle-timeout": 300, "last-update": 1649541078237, "link.context": true, "log": true, "max.single.discard": 50, "memory-enabled": false, "memory-value": 60, "mode": "time-based", "notification.permission": true, "number": 6, "online": true, "page.context": false, "period": 60, "pinned": false, "prepends": "💤", "simultaneous-jobs": 10, "startup-pinned": false, "startup-release-pinned": false, "startup-unpinned": false, "tab.context": true, "trash.period": 24, "trash.unloaded": false, "trash.whitelist-url": [], "use-cache": false, "whitelist": [ "google.com" ], "whitelist-url": [], "whitelist.session": [] }, "localStorage": { "click": "popup", "explore-count": "100" } }

Hope this helps

icetbr commented 2 years ago

Maybe this has to do with this flag?

browser.tabs.unloadOnLowMemory

It defaults to true, I'm testing it now with false, too soon to tell for sure, but I think this is the culprit

askeydev commented 2 years ago

Also, I noticed that some tabs don't seem to ever go to sleep. Your idea about "unload" reminded me that I restart Firefox sometimes and I don't view all the tabs in every window for days/weeks. Is it possible that Firefox may not have loaded them until I click on them after a restart? Would this impact the extension from triggering for those tabs?
And, yes, my unloadOnLowMemory is set to "true". Testing with "false" and Discard still set at 1 min, results seem to be the same.

askeydev commented 2 years ago

This time, I clicked on a bunch of tabs (20-30). The Firefox Task Manager tasks went down from 62 to 31. Some of those tabs I had not clicked on since before the install of the extension and now have the ZZZ for the first time. I am watching the Firefox task manager to get a better view of what is running. After another ~5 minutes, still 31 tabs/processes in Task Manager, 11 are plugin for Firefox settings/tasks related. One has the ZZZ icon in front ... not sure why a discarded tab would still show in task manager. The currently viewed tab is not discarded for each window, and I have 13 Firefox windows open. 31-11-13= 7 I have 3 google tabs which are not supposed to be discarded, but one has the ZZZ icon. After activating all 3, it looks like they are staying active. 7-3=4 and I could have easily missed clicking on 4 tabs. Note: I did not activate all tabs, so the few that remain may never have been loaded after the last Firefox restart and maybe not visible to Auto Tab Discard. ... Thus, no ZZZ icon on those tabs, but they are still not consuming resources. So maybe just a misunderstanding on my part of how it works and ZZZ will not appear on every tab.

askeydev commented 2 years ago

Setting period to 1440 appears to be working for the most part (best I can tell). I activated all tabs I could find about 26 hours ago and the Firefox task manager showed 79 tasks. Currently I have 39 tasks. I used some tabs since the start, but I don't think I close any of the original tabs. Some windows appeared to not be touched (no discarded tabs). I'm not sure if minimizing a window had any impact on the results. One error on my part ... I think I need to change the "google.com" whitelist filter to a regular expression "re:google.com" because gmail was discarded. For others experiencing issue: 1) Did you click on each tab (active them) since the last browser restart? if not, there may be no need to discard 2) At least one tab per window will not be discarded 3) Firefox setup/system tabs will not be discarded 4) Plugin tasks will remain active in the Firefox task manager 5) Use Firefox task manager to get a better view of what is active

c02y commented 2 years ago

I got the same problem for Firefox, I set it "60" minutes ( I changed the value several times since I found it is not working from time to time), but after I switched to other tabs for a few minutes, the old tab is discarded and reloaded when I switched to it.

icetbr commented 2 years ago

For those experiencing this issue, please set browser.tabs.unloadOnLowMemory to false in about:config. This flag completely invalidates any kind of testing using this extension.

Still, I haven't tested extensively like @askeydev

WHiZSTA commented 2 years ago

the best i can tell, the discard after # min, isnt about discarding specific tabs after that # sadly. It instead is a trigger to launch a batch of discards where every tab not active will be discarded when one tab hits that limit based on your other settings of how many tabs to check.

jficz commented 1 year ago

I'm getting this error on latest LibreWolf, auto discard doesn't work for me:

Uncaught (in promise) Error: Type error for parameter queryInfo (Unexpected property "autoDiscardable") for tabs.query.
    apply moz-extension://42c364e0-093b-4f82-b82e-529b31d3f5a7/v2/chrome.tabs.query.js:4
    query moz-extension://42c364e0-093b-4f82-b82e-529b31d3f5a7/worker/core/utils.mjs:12
    query moz-extension://42c364e0-093b-4f82-b82e-529b31d3f5a7/worker/core/utils.mjs:12
    check moz-extension://42c364e0-093b-4f82-b82e-529b31d3f5a7/worker/modes/number.mjs:100
chrome.tabs.query.js:4:22

Haven't tested clean profile yet.