autonome / Dormancy

Firefox add-on that frees inactive tabs from memory, restoring their contents next time you access the tab.
47 stars 14 forks source link

Tab activity accounting is wrong #35

Open sfleiter opened 5 years ago

sfleiter commented 5 years ago

Dormancy today accounts a tab, that is not the current tab of the browser window, as active exactly at the point in time it was switched to. This time is remembered and compared to in tabIsOld(tabId). With a Dormancy timeout of 10 minutes today a tab that is active for 9 minutes and 59 seconds can, after a switch to another tab, be discarded the next second.

For me a tab is active from the activation time until another tab is activated. In the above example the tab would not be discarded earlier than 10 minutes after it was switched away from.

I see different ways of doing this (and have code already for this):

Depending on decission for issue #34 the optimal solution might be different, previousTabId and Tab.lastAccessed are Firefox specific.

sfleiter commented 5 years ago

Forgot to mention: Solution 2 above (Tab.lastAccessed) would actually allow to remove the existing code for remembering last active time of tabs and the need to save that in sessionstore. This would automatically fix issue #36. Additionally Tab.lastAccessed has the semantics I proposed above, it includes the whole time until tab is left.

Only downside is that this is Firefox specific.