Closed Bug 2000401 Opened 1 year ago Closed 1 month ago

Tab favicon not dimming when unloaded via browser.tabs.discard

Categories

(WebExtensions :: Frontend, enhancement, P3)

Firefox 144
enhancement

Tracking

(firefox160 wontfix, firefox161 fixed)

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- wontfix
firefox161 --- fixed

People

(Reporter: jtmiller, Assigned: kernp25)

References

Details

Attachments

(1 file, 1 external file)

Attached image dimming_tabs.png —

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0

Steps to reproduce:

  1. Manually unload a tab by right clicking and selecting "Unload Tab"
  2. Observe the tab's favicon changing its opacity, dimming
  3. Load tab again and this time "discard" it via browser.tabs.discard(tabId | [tabId])
  4. Notice the favicon does not dim

Actual results:

In both cases the tabs unload correctly, but only using built-in "Unload Tab" do you see the favicon dim.

Expected results:

I expect the favicon dimming to occur when using the the browser.tabs.discard method.

https://hacks.mozilla.org/2021/10/tab-unloading-in-firefox-93/

"Some browser extensions already offer users the ability to unload tabs. We expect these extensions to interoperate with automatic tab unloading as they use the same underlying tabs.discard() API."

I only point that out, because if using the same underlying API, maybe that suggests we can correct the dimming inconsistency.

Summary: Tab favicon not dimmon when unloaded via browser.tabs.discard → Tab favicon not dimming when unloaded via browser.tabs.discard

The Bugbug bot thinks this bug should belong to the 'Firefox::Tabbed Browser' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Tabbed Browser

To me this is more like an enhancement, marking it accordingly. Please update if not correct. Thank you.

Status: UNCONFIRMED → NEW
Type: defect → enhancement
Ever confirmed: true
QA Contact: mchiorean

(In reply to Monica Chiorean from comment #2)

To me this is more like an enhancement, marking it accordingly. Please update if not correct. Thank you.

It certainly is an enhancement, only marked as a bug because of inconsistency between the native method (right click tab, "Unload Tab"), and the programmer's method: browser.tabs.discard()

I'm developing an extension that does the latter, but for many tabs at one, and I'm hoping to visually distinguish them.

If there is more reason to call this behavior a bug than an enhancement, I'm in favor to label it back as bug. I worry as an enhancement this inconsistency in behavior will persist for years. I am of course interested in solving myself, but FF contributions are very complicated compared to other OSS.

(In reply to BugBot [:suhaib / :marco/ :calixte] from comment #1)

The Bugbug bot thinks this bug should belong to the 'Firefox::Tabbed Browser' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

still wanting to nkow how I correct it, because I do think the bot is wrong. the code change wouldn't be adding an enhancement, it would be fixing a bug

Is this a WebExtension bug? Because tabs.discard does not set aForceDiscard when calling discardBrowser. This will then set the discarded attribute on the tab and so the style kicks in.

Was there a reason why not setting aForceDiscard?

Flags: needinfo?(rob)

(In reply to kernp25 from comment #6)

Is this a WebExtension bug? Because tabs.discard does not set aForceDiscard when calling discardBrowser. This will then set the discarded attribute on the tab and so the style kicks in.

Was there a reason why not setting aForceDiscard?

The aForceDiscard flag predates the style. The flag was used to skip the beforeunload prompt for example.
The style was added relatively recently in bug 1926973, but then limited to when the force flag was set, in bug 1962641, to explicitly exclude discards from low memory conditions.

I personally would not be opposed to visually fading the icon when browser.tabs.discard() is called. The original comment in bug 1926973 explicitly calls out to an extension as a motivating use case. I also recall that I have personally contributed a patch to the Discard Tab extension to alter the title of a tab to visually mark a faded tab; fading the icon would be a superior experience in my opinion.

Right now there is only one flag, aForceDiscard. Perhaps it makes sense to introduce an additional flag. And set that flag when called from https://searchfox.org/firefox-main/rev/b1c5a092fe1916975580c6ed95c51cbe78728a62/browser/components/extensions/parent/ext-tabs.js#954 (defaulting to whether aForceDiscard is set).

Component: Tabbed Browser → Frontend
Flags: needinfo?(rob)
Product: Firefox → WebExtensions
See Also: → 1926973, 1962641

Can you write here?

Flags: needinfo?(jtmiller)

(In reply to shmup from comment #4)

If there is more reason to call this behavior a bug than an enhancement, I'm in favor to label it back as bug. I worry as an enhancement this inconsistency in behavior will persist for years. I am of course interested in solving myself, but FF contributions are very complicated compared to other OSS.

Getting started with Firefox is surprisingly easy. After downloading the git repository, you can run ./mach bootstrap that installs the relevant dependencies, and then run ./mach build to actually build Firefox. This build completes within minutes by default when you don't need to change compiled code, which is the case for front end-only changes.

If you are interested in contributing a patch, I am willing to provide mentorship of the bug. Do you want to work on a patch? See comment 7 for some pointers.

Here is the typical getting started page I share with new contributors in the extensions realm: https://wiki.mozilla.org/WebExtensions/Contribution_Onramp

Severity: -- → N/A
Priority: -- → P3

(In reply to Rob Wu [:robwu] from comment #7)

Right now there is only one flag, aForceDiscard. Perhaps it makes sense to introduce an additional flag. And set that flag when called from https://searchfox.org/firefox-main/rev/b1c5a092fe1916975580c6ed95c51cbe78728a62/browser/components/extensions/parent/ext-tabs.js#954 (defaulting to whether aForceDiscard is set).

Or just set the discarded attribute directly in tabs.discard? How would be the name of the new flag that is only used for setting the discarded attribute?

Flags: needinfo?(rob)

(In reply to kernp25 from comment #10)

(In reply to Rob Wu [:robwu] from comment #7)

Right now there is only one flag, aForceDiscard. Perhaps it makes sense to introduce an additional flag. And set that flag when called from https://searchfox.org/firefox-main/rev/b1c5a092fe1916975580c6ed95c51cbe78728a62/browser/components/extensions/parent/ext-tabs.js#954 (defaulting to whether aForceDiscard is set).

Or just set the discarded attribute directly in tabs.discard?

I wouldn't set it in ext-tabs.js because the "discarded" attribute is an implementation detail owned by discardBrowser in tabbrowser.js. As you see there, the discardBrowser method is non-trivial and has logic before and after setting the attribute. The file is also responsible for clearing the attribute as needed.

How would be the name of the new flag that is only used for setting the discarded attribute?

Maybe aRenderDiscarded? To signal that the flag controls whether the discarded state is rendered. Other names are welcome.

The current signature is:

discardBrowser(aTab, aForceDiscard) {
discardBrowser(aTab, aForceDiscard, aRenderDiscarded = aForceDiscard) {

or to avoid difficult positional parameters, something like this:

discardBrowser(aTab, {
  forceDiscard = false,
  renderDiscarded = forceDiscard,
} = {}) {
Flags: needinfo?(rob)

Clear a needinfo that is pending on an inactive user.

Inactive users most likely will not respond; if the missing information is essential and cannot be collected another way, the bug maybe should be closed as INCOMPLETE.

For more information, please visit BugBot documentation.

Flags: needinfo?(jtmiller)
Assignee: nobody → kernp25
Status: NEW → ASSIGNED

Bug 2053343 is a dup?

Flags: needinfo?(rob)
Duplicate of this bug: 2053343

(In reply to kernp25 from comment #14)

Bug 2053343 is a dup?

Yes, good find!

Flags: needinfo?(rob)
Pushed by rob@robwu.nl: https://github.com/mozilla-firefox/firefox/commit/98806e90f8b8 https://hg.mozilla.org/integration/autoland/rev/21d59f09e804 Make tabs.discard to set the 'discarded' attribute. r=robwu,sessionstore-reviewers,tabbrowser-reviewers,jswinarton
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
Regressions: 2085027
Pushed by dmeehan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f3a2c379c53f https://hg.mozilla.org/releases/mozilla-beta/rev/1699fbb020a2 Revert "Bug 2000401 - Make tabs.discard to set the 'discarded' attribute. r=robwu,sessionstore-reviewers,tabbrowser-reviewers,jswinarton" from Beta because of Bug 2085027

Backed out of Fx160 beta due to Bug 2085027

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: