Closed Bug 1696908 Opened 4 years ago Closed 4 years ago

Enforce focused BrowsingContext ordering by action id

Categories

(Core :: DOM: UI Events & Focus Handling, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
89 Branch
Fission Milestone M8
Tracking Status
firefox89 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

Attachments

(1 file)

We know that out-of-order attempts to set the active BrowsingContext must be rejected by action id or things go wrong.

While we don't have a concrete demonstration of things going wrong in an analogous way with the focused BrowsingContext it seems prudent to implement the same mechanism for focused BrowsingContext in the hope of solving mystery problems in this general area.

Fission Milestone: --- → M8
Severity: -- → S3

I found bug 1695135 is fixed by this, Henri, do you want to add the test in bug 1695135 here? Or I could post a patch for the test in bug 1695135 and land it there.

Flags: needinfo?(hsivonen)

Let's land the test as part of that other bug.

Flags: needinfo?(hsivonen)
Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e072b56f8518
Ensure parent-managed order of setting the focused browsing context. r=nika

Backed out changeset e072b56f8518 (bug 1696908) for causing bc failures in browser_bug1303838.js
Backout link: https://hg.mozilla.org/integration/autoland/rev/0fbb2d7f53d500f374dc43465fbb8308827f99e3
Push with failures, failure log.

(Update): There were also bc failures caused by these changes.
(Update 2): Also looks to have caused mochitest plain failures.

Flags: needinfo?(hsivonen)

Hmm. Looks like all the failures were previously-known intermittents.

It looks like we reject nsFocusManager::SetFocusedWindowInternal due to stale action id:
https://pernos.co/debug/bdobZfU_AhZJAcJOM8bfNA/index.html#f{m[AfLx,CFKC_,t[Zw,CKg_,f{e[AfLx,CFHM_,s{af4284PAA,bAXo,uAWxF1A,oAW5ILg___

For some reason, that Pernosco trace is broken in the sense that local variable cannot be inspected, so it's hard to make progress on getting closer to the root cause before that's resolved.

Found this comment:

    // Sync the window for a newly-created OOP iframe
    // The actionID will be unused, so pass 0 to trigger assertions
    // in case code is later changed to use it accidentally.

And this patch changed the code that way.

Flags: needinfo?(hsivonen)

Findings so far:

The assumption that for a given action id there is at most one focused BrowsingContext may be violated when we focus a remote iframe: In that case, we may set a focused BrowsingContext in the process hosting the iframe element and a second BrowsingContext in the process hosting the iframe contents.

It seems that the problem here is that a content process starts focusing stuff due to a load finishing before a parent-initiated focusing process happens, but the IPC message that makes the content process-initiated action take its place in the queue happens after the parent-initiated action has taken its place in the queue. This leads to the content process-initiated focusing messing up the parent-initiated focusing action (which takes many IPC round trips to complete.)

One option to explore would be making parent-initiated actions always complete.

I think I'm going to still pursue examining the test itself. Adding more logging makes the failure happen less often...

https://treeherder.mozilla.org/#/jobs?repo=try&revision=b108ec53072d3b8682e94039811d3416d9ba6a65

When opening links that contain iframes in a background tab, the focusing of the iframe races with chrome-initiated focusing and I failed to come up with a nice way to make the test wait for the iframe getting focused first.

Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/27d3d97f875f
Ensure parent-managed order of setting the focused browsing context. r=nika
Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/562969cdeb6d
Ensure parent-managed order of setting the focused browsing context. r=nika
Flags: needinfo?(hsivonen)
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
Regressions: 1702312
Regressions: 1702297
Regressions: 1767201
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: