Closed Bug 1598212 Opened 5 years ago Closed 4 years ago

Website loads in incorrect tab instead of the previously active tab after creating new tab

Categories

(Firefox :: New Tab Page, defect, P1)

Desktop
Linux
defect

Tracking

()

VERIFIED FIXED
Firefox 73
Tracking Status
firefox-esr68 --- wontfix
firefox70 --- wontfix
firefox71 --- wontfix
firefox72 --- verified
firefox73 --- verified

People

(Reporter: alice0775, Assigned: Gijs)

References

Details

(Keywords: nightly-community, regression)

Attachments

(1 file)

When I test bug Bug 1597076 (but str is not same)

I can reproduce the issue on Linux Mint19 Cinnamon.

Reproducible: 1 of 5

Steps to reproduce:

  1. Make sure newtab page is shown in tab
  2. Left click item on Top Sites (e.g Wikipedia) in the tab, So that the page will load in current tab.
  3. Immediately after the clicking, Create new tab (hit Ctrl+t). So that a newtab page will open in new foreground.
    --- Observe which tab a page is loaded in.
  4. If the page loads correctly, repeat step 2 and 3

Actual Results:
By a probability of approximately 1/5, the page loads in the created new tab at step 3.

Expected Results:
The page should load in the tab at step 2.

Regression window:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=63a0e2f626febb98d87d2543955ab99a653654ff&tochange=d2d518b1f8730eb61554df7179ef9a2aeed4d843

See Also: → 1597076

Suspect:
2d34c4f04bc7e18e0e1d2c77581fcca07fd1e865 Boris Zbarsky — Bug 1457155. Rename various focus manager variables to make it clearer that they're Elements. r=mccr8
eea837f5ac160dcec9ec03cc598acd57ae42a487 Boris Zbarsky — Bug 1457156. Rename nsPIDOMWindow::mFocusedNode to reflect that it's an Element now. r=mccr8

Flags: needinfo?(bzbarsky)
Summary: Website loads in incorrect tab after creating new tab → Website loads in incorrect tab instead of the previously active tab after creating new tab

That is ... very odd. Does this step:

Left click item on Top Sites (e.g Wikipedia) in the tab, So that the page will load in current tab.

do something with the selectedBrowser or focused browser or something instead of just navigating in the existing browsing context? Gijs, do you know who would know that?

Flags: needinfo?(bzbarsky) → needinfo?(gijskruitbosch+bugs)

The only thing I can reproduce is it loading in a third tab. I end up with [original new tab][loaded page][new tab page (selected)]. Which I guess could happen if I'm holding ctrl before the click completes.

The about:newtab code has custom click handling code, which presumably is at fault here. It preventDefaults the original click and then does some manual work to record telemetry and/or update frecency or something, and then loads the page by sending a message to the parent. Then code ends up in Redux.jsm and I stop being able to follow what on earth is going on. Maybe Kate can help.

Component: Tabbed Browser → New Tab Page
Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(khudson)

Note that the remote-page-manager based logic that sends the message from the child knows perfectly well which browser the message came from, but seems to not pass that information to anything it calls after that, which presumably is where the problem comes from...

The link click eventually calls openLinkIn

https://searchfox.org/mozilla-central/rev/581466eef9269afb03d8a0dba2f50215f3a9026c/browser/components/newtab/lib/PlacesFeed.jsm#313

Assuming this is a plain link click, where should be "current", and I don't see a params.targetBrowser passed in, so it ends up defaulting to the selectedBrowser:

https://searchfox.org/mozilla-central/rev/581466eef9269afb03d8a0dba2f50215f3a9026c/browser/base/content/utilityOverlay.js#560

Flags: needinfo?(khudson)

The priority flag is not set for this bug.
:thecount, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(sdowne)

(In reply to Ed Lee :Mardak from comment #6)

Oh and to confirm comment 4, yes it does know what tab's browser triggered the message:

https://searchfox.org/mozilla-central/rev/581466eef9269afb03d8a0dba2f50215f3a9026c/browser/components/newtab/lib/PlacesFeed.jsm#312

Oh, I missed this comment somehow. That makes this easy to fix. Patch coming up.

Notes:

https://searchfox.org/mozilla-central/rev/ea63a0888d406fae720cf24f4727d87569a8cab5/browser/base/content/utilityOverlay.js#424
https://searchfox.org/mozilla-central/rev/ea63a0888d406fae720cf24f4727d87569a8cab5/browser/base/content/utilityOverlay.js#560

... though interestingly, it looks like if where is "tab", openLinkIn will open the link in the topmost window, rather than in a tab in the window to which targetBrowser belongs... I'm not 100% sure if that's intentional. I expect most callers that pass a targetBrowser would expect "tab" to then open a "sibling" browser in the same window, rather than in the topmost window... Dão, does that sound right?

Flags: needinfo?(dao+bmo)
Assignee: nobody → gijskruitbosch+bugs
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

There's a race condition where we decide we want to open a link in the 'current'
tab, but that tab has changed between when the user clicked the link, and when
we're processing the event. However, the event still knows where it came from,
and we can pass that along to 'openLinkIn' to ensure we open the link in the
correct window/tab.

Pushed by elee@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/64909b5afe4d
fix browser selection logic for opening new tab tiles in the same tab, r=Mardak
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 73

Is this something we should consider uplifting to Beta for Fx72?

Flags: needinfo?(gijskruitbosch+bugs)

Comment on attachment 9114142 [details]
Bug 1598212 - fix browser selection logic for opening new tab tiles in the same tab, r?Mardak

Beta/Release Uplift Approval Request

  • User impact if declined: race condition in where links opened from about:newtab go
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce: n/a
  • List of other uplifts needed: n/a
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Trivial change ensuring we open about:newtab links from the right context
  • String changes made/needed: none
Flags: needinfo?(gijskruitbosch+bugs)
Attachment #9114142 - Flags: approval-mozilla-beta?

Alice, if you have a moment, could you confirm this is fixed now?

Flags: needinfo?(sdowne) → needinfo?(alice0775)
Priority: -- → P1

(In reply to :Gijs (he/him) from comment #15)

Alice, if you have a moment, could you confirm this is fixed now?

I can not reproduce the issue anymore on Latest Nightly73.0a1(Build ID 20191210095443).

Flags: needinfo?(alice0775)

Verifying per comment #16. Thanks Alice!

Status: RESOLVED → VERIFIED

(In reply to :Gijs (he/him) from comment #9)

Notes:

https://searchfox.org/mozilla-central/rev/ea63a0888d406fae720cf24f4727d87569a8cab5/browser/base/content/utilityOverlay.js#424
https://searchfox.org/mozilla-central/rev/ea63a0888d406fae720cf24f4727d87569a8cab5/browser/base/content/utilityOverlay.js#560

... though interestingly, it looks like if where is "tab", openLinkIn will open the link in the topmost window, rather than in a tab in the window to which targetBrowser belongs... I'm not 100% sure if that's intentional. I expect most callers that pass a targetBrowser would expect "tab" to then open a "sibling" browser in the same window, rather than in the topmost window... Dão, does that sound right?

targetBrowser is supposed to be looked at only for the "current" case. We could theoretically do what you suggest for "tab" but targetBrowser would be misleadingly named in that context. I'm also not sure if what you suggest would be better from a users perspective, or if this case even happens at all in the real world.

Flags: needinfo?(dao+bmo)
See Also: 1597076

Comment on attachment 9114142 [details]
Bug 1598212 - fix browser selection logic for opening new tab tiles in the same tab, r?Mardak

fix for about:newtab, verified in nightly, approved for 72.0b6

Attachment #9114142 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

I tried to verify this issue on the latest Firefox 72 beta 9 but I could not reproduce it - tested on Ubuntu 18.04 x64 using Firefox 71.

Alice, if time permits, could you please confirm this is also fixed on Firefox 72 beta?

Thanks!

Flags: needinfo?(alice0775)

(In reply to Simona Badau from comment #22)

I tried to verify this issue on the latest Firefox 72 beta 9 but I could not reproduce it - tested on Ubuntu 18.04 x64 using Firefox 71.

Alice, if time permits, could you please confirm this is also fixed on Firefox 72 beta?

Thanks!

I reproduced the issue with Nightly73.0a1(20191206214833).
And I verified the fix with Nightly73.0a1(20191222215627). The issue is no longer reproduced.

And also I can not reproduce the issue with Firefox72.0b10.

Flags: needinfo?(alice0775)
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: