Closed perdolka closed 6 years ago
UPD If you install a both addons at the same time (tab-unloader-for-tree-style-tab and auto-tab-discard) and use an option "Unload tabs via the auto-tab-discard extension." then the problem doesn't arise.
@perdolka I have released a new version (v5.2) that includes a fix for this issue. Unfortunately the fix requires the tabs
permission to work and therefore it is disabled by default. To enable it you need to open the options page and request the tabs
permission from the Optional Permissions
section. You also need to expand the Fix for failed tab restore
section and change the first number input there (the one called Time to wait for tab to navigate to correct URL before fixing it
) from -1
to something like 500
.
@perdolka I made some more improvements to the fix and in version 5.5 it is now enabled with default settings. However, it will only work if it has the "tabs" permission or if Tree Style Tab is installed. Since this extension is made to help with Tree Style Tab this should be most users.
The fix will probably have slightly better performance with the "tabs" permission since it won't need to get a tab's URL from Tree Style Tab every time a tab is discarded but it shouldn't be noticeable. There are also some edge cases where a tab won't be fixed if the "tabs" permission isn't granted.
The code for the fix is located in the common/common.js file at line 3778 in the TabRestoreFixer
class.
I have investigated this problem some more and there are still cases where my fix won't work.
If a tab is discarded with the WebExtension browser.tabs.discard
function then the tab can be broken so that it won't restore correctly. I haven't observed any "broken" tabs from tabs that are discarded when a window is closed and then re-opened.
I can't find any difference between "broken" tabs and "working" tabs from the information provided by the WebExtensions API, they look the same and seems to have the same onUpdate
events before they are discarded.
If a "broken" tab is activated or reloaded then it will change to the about:blank
URL and its original URL is lost. (It has the correct URL while it is unloaded.) (This is the issue that my workaround fixes.)
If a "broken" tab is closed then it won't show up in the recently closed tab list and can't be re-opened.
If a window is closed and it contains "broken" tabs then the window will still be added to the recently closed windows. The entry will say that it contains the correct number of tabs but when the window is restored all the "broken" tabs will be created with the about:blank
URL and their original URL is lost.
If you close Firefox and then use "restore last session" when you start it again (either automatically or manually from the hamburger menu) then none of the "broken" tabs will be opened at all.
I added this bug to bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1465558 Can you repeat this information there (if you have an account there) or can I copy it?
I don't have an account there yet. You can copy anything you want, I don't mind.
OK, thank you.
I have released a new version (v5.8) of the extension. It includes a new option that will reload "broken" tab and then unload them again until they are fixed. This will hopefully ensure that no tabs are lost to this bug. It is not enabled by default since it requires the "tabs" permission and some users might be confused why the unloaded tab is reloading.
The option is a checkbox located in the Fix for failed tab restore
section. It has quite a long description:
When a tab is unloaded with the WebExtensions API it can sometimes be put in a \"broken\" state. A \"broken\" tab can't be re-opened if it is closed (not even with session restore at startup) and when its loaded again it will lose its URL. This option will reload (actually re-setting the tab's URL) \"broken\" tabs and then unload them again. \"Broken\" tabs might need to be reloaded many times before they are fixed. (Compatible with other tab unloaders.)
The Firefox bug that causes this issue seems to be fixed in Firefox 62 (current release version) and I can no longer reproduce the issue. This is not true for Firefox 60 (ESR) where I could still reproduce the issue. So the workaround can still be useful for some users.
tab-unloader-for-tree-style-tab (5.1) has the same bug: https://github.com/rNeomy/auto-tab-discard/issues/24 The bug has been fixed in this commit https://github.com/rNeomy/auto-tab-discard/commit/7836ef1cd936fb62ea927d44b91e31638e760bc0 I hope it will help to find a similar solution.
Steps to reproduce