Author Topic: Web browser steals focus due to forums scripting?  (Read 3095 times)

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Web browser steals focus due to forums scripting?
« on: 9 January 2012, 08:27:57 »
I've have this issue with Firefox stealing focus from time to time (every hour or so), which can be annoying if it keeps happening. While I usually have several browser tabs open and there can be other resons to it, the one I have open most of the time (others change more often) has been the Glest forum one. And it stopped happening when I closed this tab, keeping others open. So I suspect that the javascript code embedded on the forum and the AJAX requests it keeps making all the time in the background to monitor whether you are still present (Would there be any other reason to doing this? Is there a way to deactivate this since it seems like a waste of resources and impacts privacy?) somehow causes Firefox to steal focus.

Does this happen to anyone else? Could someone, probably Omega, please investigate this?

Thank you!
« Last Edit: 9 January 2012, 09:28:06 by tomreyn »
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Web browser steals focus due to forums scripting?
« Reply #1 on: 9 January 2012, 22:53:34 »
Strange, I have the browser open on the forum for dozens of hours in the past. There is no JavaScript that could cause an instance like this (only element.focus should be able to grab the focus). There's relatively few locations where the focus is called. Besides input focuses, there's only two things which call the window's focus: opening the member list window (which opens in a small, new window, generally only seen when sending a PM) and the help window (which also opens as a new window). Since you stated this was reoccurring, neither of these will be the case.

I also took a close look at how the time online thing works. It doesn't use AJAX, but rather very simply tries to count the time based on user interactions. If you were to login without doing anything, it should count your time online as up to 15 minutes. Every time you click a link or make a post while logged in, this counter will be reset. The time online, therefore, is extremely inaccurate, but based only on interactions, so cannot possibly steal focus. Running a quick search, I could not find any AJAX calls in the source (barring mods).

I'll try and run firefox with a fullscreen application later and see if I encounter any focus stealing, as chrome does not support the focus command (opening a new window via target="_BLANK" will always be focused. Pop unders are the result of window.blur). However, I don't recall seeing such a problem  before on any type of site, including this Glest Board, regardless of the browser, and I often keep a web browser open most of the time, even when playing a full screen game. Can you provide more information, such as if Firefox is minimized or maximized (there was a bug in the past where a minimized Firefox window caused fullscreen applications to minimize, though that was patched), what specific page(s) this occurs on, if it occurs with other browsers, does it occur with addons disabled (that buggy adobe flash addon had issues with such in the past, as well), and if it occurs on other operating systems.

Besides that, I'll try and see if I can replicate it. Has anyone else seen such an issue?
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: Web browser steals focus due to forums scripting?
« Reply #2 on: 11 January 2012, 13:43:16 »
Strange, I have the browser open on the forum for dozens of hours in the past. There is no JavaScript that could cause an instance like this (only element.focus should be able to grab the focus). There's relatively few locations where the focus is called. Besides input focuses, there's only two things which call the window's focus: opening the member list window (which opens in a small, new window, generally only seen when sending a PM) and the help window (which also opens as a new window). Since you stated this was reoccurring, neither of these will be the case.

I also took a close look at how the time online thing works. It doesn't use AJAX, but rather very simply tries to count the time based on user interactions. If you were to login without doing anything, it should count your time online as up to 15 minutes. Every time you click a link or make a post while logged in, this counter will be reset. The time online, therefore, is extremely inaccurate, but based only on interactions, so cannot possibly steal focus. Running a quick search, I could not find any AJAX calls in the source (barring mods).

Actually the forum does pingback in regular intervals also when there is no user interaction. Supposedly triggered by javascript code, the web browser accesses this location every couple of minutes:
https://forum.megaglest.org/index.php?action=keepalive;time=TIMESTAMP
TIMESTAMP is a Linux epoch timestamp (though in microseconds, not seconds). An example value is 1326280941493.

I would be glad if it was possible to deactivate the session keepalive code, ideally sitewide, or on a user level. If I'm not actively using a website then I am not using my session and this means my session should expire.

I do not know for certain whether the SMF keepalive function is what triggers the focus stealing, though. There are other suspects, and Flash is one of them, but I think the only website I had consistently loaded in a tab when the focus stealing took place was really the Glest forum. Still, it could be a Firefox extension which does this, that's another probable cause. I have a bunch installed and some of those do background updates (such as Adblock++), so chances are one of these triggers it.

Thanks for your reply and for looking into this.
« Last Edit: 11 January 2012, 13:48:17 by tomreyn »
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Web browser steals focus due to forums scripting?
« Reply #3 on: 12 January 2012, 21:05:18 »
How very strange... "keepalive" does not appear in the sources at all (nor any similar syntax). As well, my test with firefox, addons disabled, Glest Board only open did not encounter this problem at all...
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert