Why does the active Firefox window occasionally lose focus?

5

1

Occasionally, when I transition from one tab to another, the Firefox window loses focus. This is especially notable when I switch or close tabs via keyboard shortcuts. For example, I can be closing a bunch of tabs with Ctrl+w and suddenly it stops working. I have noticed that the Firefox window title is grayed out, indicating that the window has lost focus. Alt tabbing or clicking the window regains focus, but this is disruptive to the browsing experience.

To test if another application is stealing focus from Firefox, I kept this line running in a terminal

while true; do sleep 20; xdotool getwindowfocus getWindowname; done

which prints the name of the currently active window to stdout every 20 s. When Firefox loses focus, no window title is printed (just a newline), indicating that there is no other application that steals the focus from Firefox. Firefox is the only application that displays this behavior.

I am on Firefox 47.0 on Antergos (Arch derivative) Linux with Gnome 3.20.2 and kernel 4.6.2.1. Why does this happen and what can I do to make Firefox stop losing the window focus?

joelostblom

Posted 2016-06-18T00:09:29.973

Reputation: 1 833

Extremely frustrating... Even worse, it can provide focus to the wrong window, and then when you are clicking in one window, another active window takes the mouse click, when it is invisible. This can also be used by malware to have you click on one screen, only to really click in a separate window or tab, – DaaBoss – 2016-06-18T00:29:29.480

1By any chance do you have a touchpad? This is a common side effect of getting your hands too close to the touchpad if it is overly sensitive; you may be more prone to doing that when typing certain key combinations, so the coincidence points to the keyboard command. – fixer1234 – 2016-06-18T01:06:07.120

Thanks for the suggestion. I do not think that accidental touchpad clicking is the issue, since this only happens with Firefox and xdotool reports a blank window title, suggesting that no other application has been focused. – joelostblom – 2016-06-18T03:17:43.210

Did you try changing the value of dom.disable_window_flip under about:config? If not, try toggling it's value. – Michael D – 2016-06-28T03:24:27.073

1

Do you have installed the Flash add-on ? You could try starting Firefox in safe mode to see if this is caused by an add-on.

– harrymc – 2016-06-28T07:21:35.990

1

Please provide a list of your addons. I had a similar issue, and I discovered it was the Add-On "Tab Scope" causing issues for me.

– Christoph Terasa – 2016-06-28T07:23:37.027

Thanks for the suggestions! I did not expect an addon to be able to steal focus and I was convinced that I had been using Firefox with these addons for a while without seeing the issue. However, it turns out that it is the combination of the addon ThumbnailZoomPlus and Gnome3 that causes this problem. The reason focus is suddenly lost when closing tabs must be that the mouse ends up on an image in the new tab when the previous tab is closed. @harrymc Since you posted first, if you post an answer about the addons, I can fill it out with details and give you the bounty.

– joelostblom – 2016-06-28T15:09:03.217

@MichaelD I tried toggling dom.disable_window_flip from 'true' to 'false', but it had no effect. – joelostblom – 2016-06-28T15:10:15.903

Answer posted, as requested. – harrymc – 2016-06-28T20:41:14.503

Answers

2

Firefox losing focus is usually caused by one (or more) add-on(s).

This is easily tested by running Firefox in safe mode. If the problem then disappears, then one can turn off add-ons selectively, until the guilty add-on(s) is(are) found.

There have been reports about the Flash add-on, and as the poster has found out, a combination of the add-ons ThumbnailZoomPlus and Gnome3 can also cause this problem.

harrymc

Posted 2016-06-18T00:09:29.973

Reputation: 306 093

0

Focus may be lost if one of the tabs has a page that auto-refreshes or it tries to spawn adds/other new tabs or make any type of background action

Note that Opera seems to have found a solution to counter this type of behavior since quite a few versions ago, so pages trying to do various actions cannot cause focus stealing. I have 50++ tabs open at all times.

As for FF, try saving your tabs file, uninstall it, make a cleanup for all the temp files, reinstall the latest version and then put your tabs file back. Re-test to see if the behavior still persists.

Overmind

Posted 2016-06-18T00:09:29.973

Reputation: 8 562