Firefox windows pop up and steal focus against window manager's focus stealing setting in session restore
Categories
(Core :: Widget: Gtk, defect, P5)
Tracking
()
People
(Reporter: 8, Assigned: tao)
References
(Blocks 2 open bugs)
Details
(Keywords: leave-open)
Attachments
(2 external files)
Updated•17 years ago
|
Comment 1•17 years ago
|
||
Updated•14 years ago
|
| Reporter | ||
Comment 3•12 years ago
|
||
Comment 4•7 years ago
|
||
Updated•4 years ago
|
Comment 5•3 years ago
|
||
This seems similar to bug 1658790 ("Firefox restoring sessions steals focus") which is under Toolkit/Startup and Profile System.
| Assignee | ||
Comment 6•4 months ago
|
||
Mark additional GTK windows opened by non-interactive bulk SessionStore
restoration so their first map does not request focus.
Replace repeated per-window refocusing with one transaction-local refocus
after all window feature restores complete, unless the originally active
window was blurred or deactivated in the meantime. Clean up transaction
listeners on both success and failure, and keep undo-close and non-GTK
behavior unchanged.
Updated•4 months ago
|
| Assignee | ||
Comment 7•4 months ago
|
||
Add a privileged, transient chrome flag that disables focus for the first GTK
map of a newly created window. Restore the normal focus-on-map policy after
that map and leave any activation context untouched for the user-initiated
window it belongs to.
Keep the existing always-on-top and Document Picture-in-Picture behavior
unchanged.
| Assignee | ||
Comment 8•4 months ago
|
||
I can still reproduce this on Firefox Nightly 155 on Arch Linux with Xfce
4.20/xfwm4 under X11.
In an isolated Xvfb + xfwm4 reproducer, both builds restored 128 browser
windows. After an external GTK window was activated, the unpatched build
changed focus back to Firefox 160 times during the following 75 seconds. The
patched build produced zero Firefox focus transitions during the same
observation interval.
I submitted the fix as two dependent revisions:
- D315352 adds a privileged, transient chrome flag that suppresses focus for
the first GTK map of a non-interactively created window. Normal
focus-on-map behavior is restored after that map. Importantly, the
process-wide GTK activation context is left untouched so a later
user-initiated window can still consume its own token. - D315350 uses that flag for additional windows created during bulk
SessionStore restoration. It also replaces repeated per-window refocusing
with one transaction-local refocus after all window-feature restores
complete, unless the originally active window was blurred or deactivated
in the meantime.
The submitted D315350 commit explicitly depends on D315352. Validation of the
submitted source tree:
- full
./mach build -j8: passed - targeted lint, formatting, manifest, license, and whitespace checks: passed
- final X11 tests under isolated Xvfb + xfwm4: 18/18 passed
(browser_500911_restore_focus.js14/14 and
test_suppress_initial_focus.xhtml4/4) - controlled focus comparison: 160 baseline Firefox focus transitions versus
zero with the patched build
An earlier combined real-session smoke test also restored all 128 windows to
their saved Xfce workspaces (5 on workspace 0, 1 on workspace 1, and 122 on
workspace 4). Show Desktop remained active and no non-iconic Firefox window
was visible on the current workspace after restoration.
Two independent defects discovered while validating this scenario are tracked
separately:
- Bug 2059452 / D315320: preserve a minimization made while delayed window
features are pending - Bug 1707415 / D315322: allow GTK X11 restoration to workspace zero
No profile data, window titles, cookies, credentials, or raw traces were
uploaded.
Updated•4 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Comment 9•3 months ago
|
||
We have a refactor in-flight for SessionStore.sys.mjs. I'd prefer to land functional changes to Session Restore on top of this to make back-out easier so I'm blocking on bug 1892761.
Comment 10•2 months ago
|
||
Comment 11•2 months ago
|
||
Comment 12•2 months ago
|
||
Backed out for causing lint failures @ browser/components/sessionstore/SessionStore.sys
Backout link: https://hg.mozilla.org/integration/autoland/rev/7c77762705f695de98e9f94ab383f271bbeb1e2e
Comment 14•2 months ago
|
||
Updated•2 months ago
|
Comment 15•2 months ago
|
||
Comment 16•2 months ago
|
||
Backed out for causing bc failures
Updated•2 months ago
|
Comment 17•1 month ago
|
||
Lukas, do you mind to check the test failures?
Thanks.
| Assignee | ||
Comment 18•1 month ago
|
||
Thanks, Martin. I checked both September 29/30 autoland browser-test logs. They fail in test_bulk_restore_refocuses_after_delayed_activation: the test assumes nonTargetWindow.focus() has not changed Services.focus.activeWindow yet. That timing assumption does not hold consistently. The subsequent diagnostic test queues the request explicitly, but Sam's Linux opt/debug Try still shows the native non-target activation arriving 21–33 ms after bulk-restore end, with zero target focus calls.
I have now reproduced the latter behavior through a complete programmatic bulk restore in isolated Xvfb/Openbox, using the packaged SessionStore and BrowserWindowTracker modules from that Try. Both modules match the current submitted source byte-for-byte. The two local queued-request cases delivered the non-target activation 40.9 and 129.0 ms after bulk end. One main-thread dispatch therefore does not settle that request.
The same integration also confirms the separate initial-null issue raised in review. When restore begins with no active Firefox window, then an owned window activates and an external application takes focus, final arbitration calls the target's focus once and takes activation back. Both repetitions agree. With an initially active Firefox window, the external intervention is preserved with zero target focus calls. A further pair of cases shows that an external-null sample is not remembered if an owned window becomes active again before completion. All twelve diagnostic cases completed their restore notifications with a paired bulk start/end.
These are full setBrowserState() restore diagnostics on an artifact build, not startup acceptance or an unpatched-baseline comparison. I have left production focus policy unchanged. The remaining questions about pending native activation and initial-null/background restoration are with Emilio in D315350 comment 1765496: https://phabricator.services.mozilla.com/D315350#11560016. The current patch is not ready to reland; I will follow up with the correction and fresh platform tests once that contract is established.
Sam's diagnostic Try: https://treeherder.mozilla.org/jobs?repo=try&revision=7505fb68349bab106c2da3045272921816254f86
Description
•