Resolve browser.tabs.duplicate() promise right away (before tabs are completely loaded)
Categories
(WebExtensions :: General, enhancement, P5)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: yuki, Assigned: perso, Mentored)
References
Details
(5 keywords, Whiteboard: [design-decision-approved])
Attachments
(1 file)
browser.tabs.duplicate() returns a promise which is resolved after all duplicated tabs are completely loaded. https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/duplicate https://developer.chrome.com/extensions/tabs#method-duplicate But we sometime need to do something for duplicated tabs immediately. For example, my Tree Style Tab addon provides ability to duplicate a tree (multiple tabs) at dropped position by drag-and-drop with Ctrl key. https://github.com/piroor/treestyletab/tree/master/webextensions Currently I have to wait all duplicated tabs are loaded before reorganize them as a duplicated tree at the dropped position. It is painfully slow for me... So I propose a new option to resolve the returned promise just after tabs are inserted into the tab bar, like: var duplicatedTabs = await browser.tabs.duplicate([1, 2, 3], { immediately: true }); The option name "immediately" is just an example and I need more better naming. How about this?
https://hg.mozilla.org/mozilla-central/annotate/db7f19e26e571ae1dd309f5d2f387b06ba670c30/browser/components/extensions/ext-tabs.js#l619 This promise be resolved when the tab has been restored, which may in order to the index and pinned properties is correct. But this brings hundreds of ms or higher delay. So I think a new option is reasonable. In addition, the select tab behavior may be unnecessary for some cases and lead to unnecessary UI jumps, maybe also require a new option, and a new bug? Maybe an option to return immediately and allow to override the default behavior is simple.
Updated•6 years ago
|
Reporter | ||
Comment 2•6 years ago
|
||
I've tried to do something when the duplicated tab appears in the tab bar with a combination of browser.tabs.onCreated and browser.sessions.getTabValue (getTabValue returns something value copied from the original tab but the tab has different id, so it means the tab is duplicated.) to accelerate my addon, but it doesn't work as expected because tabs can be moved after browser.tabs.onCreated, before the promise is resolved. So I think that this is a too hard problem for addon developers. I cannot find out any stable workaround yet...
Updated•6 years ago
|
Comment 3•6 years ago
|
||
Hi Piro, this has been added to the agenda for the January 30, 2018 WebExtensions APIs triage. Would you be able to join us? Here’s a quick overview of what to expect at the triage: * We normally spend 5 minutes per bug * The more information in the bug, the better * The goal of the triage is to give a general thumbs up or thumbs down on a proposal; we won't be going deep into implementation details Relevant Links: * Wiki for the meeting: https://wiki.mozilla.org/WebExtensions/Triage#Next_Meeting * Meeting agenda: https://docs.google.com/document/d/1x80jYXicAotNjlitY5RZDcSRpRM3lmaSHp_q4co4OEg/edit# * Vision doc for WebExtensions: https://wiki.mozilla.org/WebExtensions/Vision
Reporter | ||
Comment 4•6 years ago
|
||
OK, I'll join to IRC channel for the meeting.
Updated•6 years ago
|
Comment 5•6 years ago
|
||
In the meeting, it was agreed that this should be the default behaviour for tabs.duplicate() (without needing any option).
Comment 6•6 years ago
|
||
The code for tabs.duplicate is here: https://dxr.mozilla.org/mozilla-central/source/browser/components/extensions/ext-tabs.js#715 Seems like the solution would be resolving just after adding both listeners, or resolving at the end of the `SSTabRestoring` listener as opposed to the `SSTabRestored` listener.
Updated•6 years ago
|
Updated•6 years ago
|
Updated•5 years ago
|
I still have this problem, there’s a workaround in TreeStyleTab but we also hit the problem in Tab Center Redux.
Comment 8•5 years ago
|
||
Updated link: https://dxr.mozilla.org/mozilla-central/rev/4e56a2f51ad739ca52046723448f3129a58f1666/browser/components/extensions/parent/ext-tabs.js#893-921
Comment 9•5 years ago
|
||
Bulk move of bugs per https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
Comment 10•5 years ago
|
||
If this is your first contribution, please refer to https://wiki.mozilla.org/WebExtensions/Contribution_Onramp on how to get started. Mentor: zombie
Assignee | ||
Comment 11•5 years ago
|
||
Don’t wait for tab to be fully loaded to resolve the promise.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 12•5 years ago
|
||
Pushed by nerli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/88d980179ff9
Resolve browser.tabs.duplicate() promise as soon as possible r=zombie
Comment 13•5 years ago
|
||
bugherder |
Comment 14•5 years ago
|
||
Thanks for the patch, ariasuni! Your contribution has been added to our recognition wiki: https://wiki.mozilla.org/Add-ons/Contribute/Recognition
Would you be interested in creating an account on mozillians.org? I'd be happy to vouch for you!
Comment 15•5 years ago
|
||
Hi Mike, this might break some extensions that expect the duplicated tab to be fully loaded when the promise resolves, and should probably be mentioned in the release notes blog post.
Assignee | ||
Comment 16•5 years ago
|
||
(In reply to Caitlin Neiman [:caitmuenster] from comment #14)
Thanks for the patch, ariasuni! Your contribution has been added to our recognition wiki: https://wiki.mozilla.org/Add-ons/Contribute/Recognition
Would you be interested in creating an account on mozillians.org? I'd be happy to vouch for you!
I created a profile here: https://mozillians.org/fr/u/ariasuni/ :)
Comment 17•5 years ago
|
||
(In reply to ariasuni from comment #16)
I created a profile here: https://mozillians.org/fr/u/ariasuni/ :)
You are vouched! 🎉 Welcome onboard! I look forward to seeing you around the project. :)
Comment 18•5 years ago
|
||
(In reply to Tomislav Jovanovic :zombie from comment #15)
Hi Mike, this might break some extensions that expect the duplicated tab to be fully loaded when the promise resolves, and should probably be mentioned in the release notes blog post.
Thanks. Let's make sure this behavior is explicitly noted in the documentation on MDN, too.
Comment 19•4 years ago
|
||
Can you please provide some STR for this issue so we can check it manually? If no manual testing is needed please mark it as "qe-verify- "
Comment 21•4 years ago
|
||
Added the following note to the page tabs.duplicate:
Note: Beginning with Firefox 68, the promise returned by browser.tabs.duplicate() resolves immediately for performance reasons. Your extension should not depend on the duplicated tab to be fully loaded when the promise resolves.
If this isn't enough information, please let me know.
Updated•4 years ago
|
Comment 22•4 years ago
|
||
There is no performance reason for this; the main motivation for this feature is to allow tab manager extensions to update their own UI as soon as possible.
The next note,
Your extension should not depend on the duplicated tab to be fully loaded when the promise resolves.
... is a bug. This has been fixed in Firefox 69 and uplifted to ESR 68 - see bug 1559216
I'd change the note to "... resolves as soon as the tab has been duplicated. Previously, the promise only resolved once the tab had fully been loaded."
If you can find a concise way to mention the regression/fix from bug 1559216, include it, but otherwise you may omit it.
Comment 23•4 years ago
|
||
Made the change. Also, the BCD information is now showing on the page.
Description
•