#9: Solving “Flash in background issue”
This article is very specific and doesn't really fit into this series of general Linux tips but it covers such an annoying issue, whose solution is documented nowhere on the Internet, that I decided to include it into this Advent series. So if you're not concerned with this issue, stay tuned for tomorrow's blog post.
Since Adobe has introduced Flash, there have always been major and minor problems with that on all platforms, especially on Linux. One problem I often had to deal with is a focus stealing bug with Kwin, KDE's window manager. I don't know how far this is KDE related, perhaps also some Compiz users could encounter this problem under Gnome. If you are concerned, please let me know and write a comment.
For this short article I will focus on Kwin since it's my window manager of choice and that one I use. So what happens when this bug occurs? Well, this does not happen each time and also not on each website (e.g., I couldn't reproduce it for YouTube yet). Primarily, this bug occasionally occurs in Firefox on websites like Vimeo. When you switch to full screen mode, suddenly Flash decides to go into background and continues, whatever it's doing right at the moment, behind the browser window. That results in something like that:
To see what's going on there, you have to minimize your browser window or to hit <ALT>+<TAB>. That's very annoying and because your taskbar is always visible then, you don't even have a real full screen. But what to do? I have not figured out yet what the actual cause of this focus bug is. It might be a conflict between the browser and the Flash window, which runs in a separate process and not as a thread of the browser itself; but it could also be an issue with the compositor or something like that. Whatsoever, a way to fix this issue is to set up a window rule for the Flash full screen window. For this purpose open your system settings panel and go to “Window Behavior” → “Window Rules” and click “New”. To detect what to type in, you can click onto “Detect Window Properties” and then onto the window whose properties you need. But you might notice that this is not possible here because the full screen window closes as soon as it recognizes a focus out event, so when you click that button, Flash terminates full screen mode. But there's a little trick. Flash closes only on focus out events, but since it doesn't have the focus initially, we can do things when paying attention to not passing the focus to the Flash window in any way. So resize your browser window that it only fills part of the screen and position the properties window next to it. Arrange both windows that way that you still have some empty space on your screen. Now activate full screen, bring the properties window to the front carefully, click on “Detect Window Properties“ and then on your Flash full screen window.
Having this done you now should've got some weird information about your Flash full screen window. For Firefox it looks like this:
Class: <unknown> (<unknown> <unknown>)
Role:
Type: Normal Window
Title: <unknown>
For Chromium it's
Class: Exe (exe Exe)
Role:
Type: Normal Window
Title: exe
and for Opera
Class: Operapluginwrapper-ia32-linux (operapluginwrapper-ia32-linux Operapluginwrapper-ia32-linux)
Role:
Type: Normal Window
Title: operapluginwrapper-ia32-linux
That's not very meaningful information but hopefully unique on your system. So tick “Match also window title” and click OK. Then enter some (hopefully more expedient) description (e.g. “Adobe Flash full screen fix”) and go to the Workarounds tab. There activate “Focus stealing prevention” and set the first drop down menu to “Force”. After clicking OK and Apply you're done. Henceforth Flash should always get the focus when switching to full screen mode.
Update March 20th 2011:
Many people had trouble getting the technique above to work. Entering the values manually works, but that's not very convenient and you have to know the values for all browsers etc. For instance, if you use nspluginwrapper, the values are again different. Here just the values for Firefox:
Class: Npviewer.bin (npviewer.bin Npviewer.bin)
Role:
Type: Normal Window
Title: npviewer.bin
One workaround for this is that you first set a window rule for the window properties detector window. Click “New” to create a new window rule, then “Detect Window Properties” and then the “Edit Window-Specific Settings” window itself. Under “Preferences” now check “Accept focus”, set the drop-down menu to “Force” and leave the checkbox behind it unchecked. Click “OK” and “Apply”. Now Flash shouldn't close its fullscreen anymore when you click the “Detect Window Properties” button.
Trackbacks
Adobe Flash has ever been a great source of anger due to many bugs (see here for example) and security vulnerabilities. Anyhow, it has evolved into a widely used technology and many, many websites need it to function correctly (yeah, HTML5 is coming, let'
RT @reflinux: #Advent series "24 Short #Linux #Hints", day 9: Solving "#Flash in background issue" http://bit.ly/g7MSHG