browser.search.search() doesn't work reliably with fission enabled
Categories
(Core :: DOM: Content Processes, defect, P3)
Tracking
()
People
(Reporter: robbendebiene, Assigned: aiunusov)
Details
(Whiteboard: dom-lws-bugdash-triage)
Attachments
(3 files)
With fission enabled (fission.autostart = true) the search engine API sometimes doesn't work.
Using the following manifest.json and background.js:
{
"manifest_version": 2,
"name": "Test",
"version": "1",
"permissions": [
"search"
],
"background": {
"scripts": [ "background.js" ]
},
"browser_action": {
"default_title": "Test"
}
}
browser.browserAction.onClicked.addListener(async () => {
const [ activeTab ] = await browser.tabs.query({active: true});
const searches = await browser.search.get();
const tab = await browser.tabs.create({
openerTabId: activeTab.id,
url: "about:blank",
active: true
});
const randomSearchEngine = searches[Math.floor(Math.random()*searches.length)];
browser.search.search({
query: "Search query",
engine: randomSearchEngine.name,
tabId: tab.id
});
});
When clicking the browser action the newly opened tab will sometimes stay blank instead of switching to the search query.
Comment 1•4 years ago
|
||
Hello,
I reproduced the issue on the latest Nightly (96.0a1/20211118212756), Beta (95.0b9/20211118185700) and Release (94.0.1/20211103134640) under Windows 10 x64 and Ubuntu 16.04 LTS.
With fission.autostart = false, the first click on the browser action will yield a blank tab, however, every subsequent click on the browser action will open a tab with the search query.
With fission.autostart = true, each second click on the browser action will yield a blank tab i.e. 1st click=search query, 2nd click=blank tab, 3rd click=search query, 4th click=blank tab etc.
For more details, see the attached screenshots.
Comment 2•4 years ago
|
||
Comment 3•4 years ago
|
||
Comment 5•4 years ago
|
||
I believe this is tab browsing rather than search related.
As far as I can tell what gets passed through to openLinkIn is consistent and correct (called from here). It always has the correct search urls, and is indicating to load in the current tab.
If I add a breakpoint in ext-search.js, e.g. here, then the issue goes away - at least in the non-fission case.
This makes me think it is process switching related & timing. Since Fission is likely to be changing processes more often, this would seem to back up the idea.
I'm wondering if Mike might be able to look into this, or know who to pass it onto.
Updated•4 years ago
|
Comment 6•4 years ago
|
||
This is really easy to reproduce by creating an add-on from the things in comment 0.
From what I can tell using rr, what's going on is that we attempt to load the search result page in a process that goes away soon after...and the new process that gets created tries to load about:blank.
So I think this is deeper DOM process switching stuff. I think I'm going to see if Nika has any idea what's going on here.
Comment 7•4 years ago
|
||
(In reply to Mike Conley (:mconley) (:⚙️) from comment #6)
From what I can tell using
rr, what's going on is that we attempt to load the search result page in a process that goes away soon after...and the new process that gets created tries to load about:blank.
If you can reproduce with rr, can you post a pernosco trace for me to look into? It would be useful for following it through.
We've got the process switching stuff down pretty well at this point, so it sounds like we're perhaps attempting to load the search result page and then some other code (perhaps extension code?) is cancelling the load during the process switch? An about:blank in the new process after the process switch which is quickly replaced is expected.
Comment 8•4 years ago
|
||
Sorry for the delay - Pernosco session is here: https://pernos.co/debug/3S2g3Kl1x83kcssQcqkvsg/index.html
Comment 9•4 years ago
|
||
The severity field is not set for this bug.
:mixedpuppy, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 10•4 years ago
|
||
Nika, can you validate Mike's thoughts?
Updated•4 years ago
|
Comment 11•4 years ago
|
||
Updated•4 years ago
|
Comment 12•2 years ago
|
||
Would you mind verifying if the STR still apply? In case we should probably capture a new pernosco session, too.
| Assignee | ||
Comment 13•1 year ago
•
|
||
Managed to reproduce.
At least, I see this in the logs, when search is interrupted and page is blank:
"WebProgress Ignored: no longer current window global: file C:/Users/aiunu/mozilla-source/mozilla-unified/dom/ipc/BrowserParent.cpp:3141"
https://searchfox.org/mozilla-central/source/dom/ipc/BrowserParent.cpp#3141 ("The current process for this BrowsingContext may have changed since the notification was fired")
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 14•1 year ago
|
||
| Assignee | ||
Comment 15•1 year ago
•
|
||
However, the problem may be in the extension code itself. Because using the latest official MDN documentation I was able to create an extension that works like a charm (using disposition: "NEW_TAB"):
function search() {
browser.search.get().then(function(searches) {
const randomSearchEngine = searches[Math.floor(Math.random() * searches.length)];
browser.search.search({
query: "Search query",
engine: randomSearchEngine.name,
disposition: "NEW_TAB",
});
});
}
browser.browserAction.onClicked.addListener(search);
| Assignee | ||
Comment 16•1 year ago
•
|
||
Would this solution be enough? Because the search itself does not seem to be broken.
| Reporter | ||
Comment 17•1 year ago
|
||
Thanks for investigating the problem.
Using disposition: "NEW_TAB" might be a solution for some add-ons, but in Gesturefy the user can define the placement of the new tab
(see code). This is why the tabId is required. Back then when the API was first introduced this was the recommended way and also worked without any problems.
| Assignee | ||
Comment 18•1 year ago
•
|
||
Thanks for the feedback.
Got it. I will take a look into the problem closely, to figure out why the process goes away (or changes) for the new tabId
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 19•1 year ago
|
||
I changed a bit your example. And it started working fine
browser.browserAction.onClicked.addListener(async () => {
const activeTab = browser.tabs.getCurrent();
const searches = await browser.search.get();
const tab = await browser.tabs.create({
openerTabId: activeTab.id,
url: "about:blank",
active: true
});
const randomSearchEngine = searches[Math.floor(Math.random()*searches.length)];
browser.search.search({
query: "Search query",
engine: randomSearchEngine.name,
tabId: tab.id
});
});
(So, I am suspecting browser.tabs.query({active: true}) is causing issue)
| Reporter | ||
Comment 20•1 year ago
|
||
Perhaps it is important to note that for me the problem only occurred after having several tabs open. E.g. with less than 7 tabs everything worked but having more than 7 caused the problem. Therefore I thought it must be some sort of race condition.
| Assignee | ||
Comment 21•1 year ago
•
|
||
with browser.tabs.query({active: true}) every second click on extension leads to the blank page
with browser.tabs.getCurrent() it works fine in 100% cases
(I will take a look on rr traces and create a follow up bug)
Updated•1 year ago
|
| Assignee | ||
Comment 22•8 months ago
|
||
(still an issue)
sometimes browser.tabs.query({active: true}) does not work properly when fission is enabled
| Assignee | ||
Updated•8 months ago
|
| Assignee | ||
Comment 23•7 months ago
•
|
||
I double checked everything, so
browser.tabs.query({active: true}) always returns correct tab
then, new tab is created
but search() sometimes does not work with that tab
My workaround is working, because openerTabId is always undefined (means, browser.tabs.getCurrent() returns undefined)
(checking regression window)
| Assignee | ||
Comment 24•7 months ago
|
||
renewed Pernosco session
https://pernos.co/debug/3S2g3Kl1x83kcssQcqkvsg/index.html
| Assignee | ||
Comment 25•2 months ago
|
||
Not reproducible anymore
This may be fixed due to recent improvements to about:blank handling.
| Assignee | ||
Updated•2 months ago
|
Description
•