NiklasGollenstede / unload-tabs

WebExtension that unloads tabs and prevents tabs from loading
https://addons.mozilla.org/addon/unload-tabs/
Mozilla Public License 2.0
69 stars 13 forks source link

Firefox 57 #12

Open rayman89 opened 6 years ago

rayman89 commented 6 years ago

Hello first I wanted to ask if this addon is on AMO and if there are plans to update it for firefox 57+

NiklasGollenstede commented 6 years ago

The first one is easy: here.


And for the second question: Yes I do plan to update it to a WebExtension, but I don't think it is possible do do a decent port yet. So far, this are my thoughts about what is possible and what not:

Current Feature FF 57 API Workaround
Styling unloaded /not-yet-loaded tabs It's not directly possible to apply styles to any part of the UI anymore
  • either use an Unicode strike-through effect or something similar
  • or work with / the same way as the reStyle extension I am also working on. Through some hackery that can apply UI styles, but I don't have a concept for integration with other extensions yet
Adding context menus Yes, but can't be enabled per tab Always show all menu options
Unloading tabs Not yet, a concept of "discarding" tabs should be added to FF soon Either replace unloaded tabs with an extension page placeholder (quite ugly, especially problematic when disabling the extension, tabs that are not loaded yet and unloaded tabs would be very different) or reload the tab and immidiately stop() it from actually loading (this may confuse other add-ons because there are tabs that appear to be loaded, but only contain empty pages)
Keep tha focus away from unloaded tabs when the active tab gets closed Nope. Would require blocking .tabs.onClosed handlers. I think it is unlikely that Mozilla will add those No workaround possible
Hotkeys for the previous / next unloaded (and visible) tab Firefox supports global keyboard commands, but the keys can't be re-assigned by the user. Tabs can't be hidden yet, once they can, detecting their visibility state should be trivial Wait until Firefox adds a UI to change extension defined shortcuts. Having a non-configurable default is not desireable

I'm not sure how to proceed yet. In any case, there will be least one or two Firefox versions where this extension has greatly reduced functionalities.

rayman89 commented 6 years ago

Thanks for your detailed response. I'll be looking forward to the new versions.

duttyend commented 6 years ago

As the friend Rayman said, Thank you very much for your detailed answer and looking forward to the new versions :-)

NiklasGollenstede commented 6 years ago

Mozilla added some of the required and I finally got around to porting this add-on. With some creativity I actually managed to get pretty close to the previous version. The update notice gives a good overview of what is still missing. (I's currently also displayed after installation/upgrade.)

Unfortunately, Mozilla just retired the beta channel feature of AMO, so I have to upload a signed version with a different id for manual dawnload: unloadtabs-0.8.0b3-an.fx.zip GitHub (pre-)release

I'd really appreciate it if you would install and test that version. While I am confident enough to use this version in all my own profiles, I have to warn you that this is an experimental pre-release and it is not out of the question that it may mess with your browsing sessions.

Any feedback on bugs, usability, UI and the update notice (please read that) would be nice. Thanks!

rayman89 commented 6 years ago

I tested it and the only available option is to unload a tab i tested on current and background tab on github and I get a notificaton error "tab is undefined" im on firefox beta latest win 7 x64

NiklasGollenstede commented 6 years ago

I tested it and the only available option is to unload a tab

When an extension adds more than one menu item, Firefox collapses them to a submenu. To avoid that, the Unload other Tabs option is only available in the Extras menu (press Alt to show the menu bar). I might add an option to configure that.

Also, in Firefox 60 (currently beta) you can now configure the shortcuts.

I get a notificaton error "tab is undefined"

Yep. Unfortunately there are still a ton of bugs in Firefox's tabs API. It's quite difficult to work around all the weird situations that arise. Here is a new beta version that might already fix your issue: https://github.com/NiklasGollenstede/unload-tabs/releases/

rayman89 commented 6 years ago

What would be bad about having a collapsed menu with this subitems for example?

imagen

I think thats more useful than just 1 item that is slightly quicker to select

BTW new version still gives the "tab undefined" error. Maybe you could look at other extensions that unload tabs for reference like

https://addons.mozilla.org/en-US/firefox/addon/unload-tab-from-context-menu

NiklasGollenstede commented 6 years ago

What would be bad about having a collapsed menu

I don't like it. But that doesn't mean that there shouldn't be an option for it. I will add one when I find the time to do it. Maybe that option should even be enabled by default. I know that most people won't go looking in the Tools menu.


new version still gives the "tab undefined" error

That is unfortunate. I'll need more information to track this down. Please do this:

1.) Increase the debug level to 2: image

2.) Go to about:debugging, enable add-on debugging: image

3.) Click Debug and OK in the prompt (which may open in the background. image

4.) Disable and enable Unload Tabs. 5.) Unload your Tab. 6.) Make sure timestamps in the debugger are enabled: image 7.) Copy the console output image 8.) Post the output here. Note that it does contain the favicon (tabicon) URLs of your open tabs (not the actual URL, though). Try to put is in a block like this:

<details><summary>Console output</summary><p>

your output <<<

</p></details>

If you re uncomfortable with posting that here, you can email me (name of this repo at niklasg.de).

rayman89 commented 6 years ago

I don't know if it's normal but on about:debugging below the title of your add-on it says

"Reading manifest: Error processing background.persistent: Event pages are not currently supported. This will run as a persistent background page."

This is what I got by just following your steps

https://hastebin.com/riyowopoxi.css

This is what I got after clicking "unload tab"

https://hastebin.com/garonobaxe.lua

NiklasGollenstede commented 6 years ago

"Reading manifest: Error processing background.persistent: [...]"

That has nothing to do with this. As the warning said, it's not supported in Firefox anyway. I changed it.

This is what I got buy just following your steps

Did you really, especially steps 1 and 4? When starting with verbouse output, there should be a message for each open (even unloaded) tab, and afterwards there should be messages whenever the state of a tab changes.

Your output doesn't contain much. So if you did increase the debug level, then these create and update events were not reported by Firefox. That would explain why the tab is not known (undefined). OR (and that seems more likely) you disabled the "On Tab close: prevent Firefox from loading unloaded Tabs" option. Which as I see now also breaks the tab unload option.

I'll fix that and report back ...

rayman89 commented 6 years ago

Yes I have that disabled. I enabled it and works properly.

NiklasGollenstede commented 6 years ago

The next beta is available, it:

See: https://github.com/NiklasGollenstede/unload-tabs/releases/

rayman89 commented 6 years ago

I tested it and it seems that your fix for "prevent loading unloaded tabs" it's not working properly. Even if I disable it the behavior remains active. It will switch to a loaded tab and it wont load an unloaded like it's supposed to.

I also noticed that when trying to unload the current tab if there is no other loaded tab to switch to it won't unload it and it will display a message saying there is no tab to switch to. I know you implemented this on purpose but I think it should be an option. If you are asking the addon to do something by default it should do it IMO.

Also noticed that "Switch to next load tab" sometimes will skip mozilla/ about:, pages and sometimes not I'm not sure if it's because the addon remembers the order of how tabs were loaded or why. If its switching tabs by order of when they were loaded I think the description is not very clear on the options I was expecting to just move to the next tab loaded tab to the right.

NiklasGollenstede commented 6 years ago

I tested it and it seems that your fix for "prevent loading unloaded tabs" it's not working properly. Even if I disable it the behavior remains active. It will switch to a loaded tab and it wont load an unloaded like it's supposed to.

That seems odd. When it is switched off, it's off. When you try to verify that, make sure Firefox's default behavior is to actually switch to a loaded tab, e.g. by going to the last tab in the tab bar, opening a new one right of it, unloading the previously last tab, then closing the now active last tab. Firefox will then go left by default, loading the tab you just unloaded.

The opposite was unfortunately the case with v0.8.0b5. I made a stupid mistake in that version and it wouldn't prevent tabs from being loaded if the option was enabled.

I also noticed that when trying to unload the current tab if there is no other loaded tab to switch to it won't unload it and it will display a message saying there is no tab to switch to. I know you implemented this on purpose but I think it should be an option. If you are asking the addon to do something by default it should do it IMO.

Well. If there is no tab to switch to, then the currently active tab can't be unloaded, unless an alternative tab is opened. But you didn't tell the extension to do that either. I guess I could add an option for that as well ...

"Switch to next load tab" [...] I was expecting to just move to the next tab loaded tab to the right.

That's what is supposed to happen. It sorts the tabs in the current window by index and goes left or right picking the first tab that is neither unloaded nor hidden. EDIT: see correction below

Also noticed that "Switch to next load tab" sometimes will skip mozilla/ about:, pages and sometimes not

This should only be possible if these tabs are marked as either discarded or hidden or you had tab tracking enabled, moved tabs around and UnloadTabs lost track of that (which obviously shouldn't happen). The extension now logs tabs it skips over. That might be insightful the next time that happens.

Here is the next version: https://github.com/NiklasGollenstede/unload-tabs/releases/tag/v0.8.0b6

rayman89 commented 6 years ago

make sure Firefox's default behavior is to actually switch to a loaded tab

Firefox default behavior is to focus the tab to the right of the current active closed tab and it does not care if the tab is loaded or not. AFIK there is no way to change that on about config.

Well. If there is no tab to switch to, then the currently active tab can't be unloaded, unless an alternative tab is opened.

There are non loaded tabs to switch to. It was not the only tab on the window. Specially if you have the option to prevent loading unloaded tabs turned off it should just load an unloaded tab instead of displaying an error IMO.

it seems that the mozilla tabs were skipped because I was expecting to move to the adjacent tab but as you said it remembers the order the tabs were loaded.

NiklasGollenstede commented 6 years ago

Firefox default behavior is to focus the tab to the right of the current active closed tab

Not quite. If the closing tab has a owner, then that is focused. When opening a tab, the owner is set to the previously focused tab, but it is dropped as soon as you change tabs. You can test that by opening a tab with Ctrl+T (while you are not looking at the rightmost tab) and closing it again with Ctrl+W. Firefox will focus the previous tab, even though it is not left or right of the closed tab.


Specially if you have the option to prevent loading unloaded tabs turned off it should just load an unloaded tab instead of displaying an error IMO.

Hmm. I didn't even consider that ...


it seems that the mozilla tabs were skipped because I was expecting to move to the adjacent tab but as you said it remembers the order the tabs were loaded.

Dammit. I missed a vital word in that sentence: That's not what is supposed to happen. It sorts the tabs in the current window by index (i.e. position) and goes left or right picking the first tab that is neither unloaded nor hidden.

NiklasGollenstede commented 6 years ago

Just FYI: I released the WebExt version on AMO: https://addons.mozilla.org/firefox/addon/unload-tabs/

rayman89 commented 6 years ago

Are there plans to implement unloading tabs that are not used after an amount of time specified by the user and a whitelist that comes with that alongside some options like prevent unloading tabs that have media loaded (like to prevent unloading sites that are/were streaming a video) and prevent unloading sites that have unsent typed text like a comment on this page for example?

NiklasGollenstede commented 6 years ago

Are there plans to implement unloading tabs that are not used after an amount of time specified by the user

Not really. Auto-discarding of tabs is one of the major things I dislike about mobile browsers. I think this should be left up to the user. Clicking "Unload Other Tabs" isn't that hard. But if you have good arguments, I might implement it. UnloadTabs already keeps a lot of state information about tabs anyway.

prevent unloading sites that have unsent typed text like a comment on this page

I believe this is the task of the page itself. GitHub for example saves unfinished comments. Other pages with filled forms could set an beforeunload listener, which not only prevents closing the tab (without prompt), but also prevents discarding/unloading by extensions.

prevent unloading tabs that have media loaded

That would be really hard to specify. And resource wise such tabs would in general be very attractive to discard.

whitelist that comes with that alongside

You can already kind of whitelist tabs by pinning them. If I ever implement auto discarding, a whitelist should come with it.

rayman89 commented 6 years ago

Well with auto tab discard you have it all in auto pilot so you don't have to be all the time using that command. You can specify the amount of time you need to work on the tabs so if the auto discard bothers you it's enough to set a longer time so it does not. Also if the whitelist is at hand on the context menu with like an on/off you can quickly white list a tab that usually you want unloaded but not specifically at this time.

Also if you click unload other tabs right now there is no whitelist so you would get all the tabs unloaded which may not be what you want specially if you are working on multiple tabs at the moment but have other tabs loaded. On that case with auto unload the tabs you been working on will be active so only the rest would get eventually unloaded.

At the end auto unload doesn't have to be ON by default it could be enabled by user so whoever likes it can enable it. Same with the media loaded option. I think people that have problems focusing like me are the ones that tend to have a lot of open tabs and if we are looking at a video specially a long one like movie or something it's probable that we won't always end up watching it on one sitting so if that tab gets unloaded then it would be troublesome to have to search for the point that it was left off and re buffer it; but if you find this request to be to complicatd/ not worth the time the on/off white list would work for this as well. Same thing for the unsent forms in case the page doesn't have auto-save or beforeunload which is the case for most pages in my experience.

NiklasGollenstede commented 6 years ago

I'll think about this, but it will most likely not be implemented soon.