Flash is terrible: How to fix fullscreen flash

02 Jul
2013-07-02

As we all know, flash is downright terrible, and should preferably go away as quickly as possible.

However, while we’re forced to contend with it, let’s at least try to make it as painless as possible.

One common cause of frustration with flash in multi-monitor mode, is the fact fullscreen flash windows (youtube videos, for example) close as soon as you click anywhere else.

At least on Linux, I know this to be true. On windows, there are a lot of other problems, but not this one specifically.

This is very frustrating if you have more than one monitor. It completely prevents you from watching something on one monitor, and working on the other. No matter if it’s an instructional video, or just some background entertainment, this is clearly a reasonable workflow that fails.

Now, we don’t have the source for flash (I wish), so we are limited to a solution that can either be applied directly to the .so-file, or in the frameworks around the browser.

It would also be great if the fix would be reasonably version-independant, so we don’t have to come up with a complicated binary patch for each point release. Finally, a safe idempotent way of applying it would be great.

After a lot of digging, I discovered part of the mechanism. The Windows Manager (WM) extension to X11, mandates that a client (a window manager) that changes windows, MUST send a _NET_ACTIVE_WINDOW to the root window.

It turns out that this message is crucial to the fullscreen process. Flash is set to listen for _NET_ACTIVE_WINDOW, and go to non-fullscreen mode whenever it receives such a message. That is, whenever any other window is selected.

After experimentation, I concluded that by failing to receive _NET_ACTIVE_WINDOW, flash will stay nicely in fullscreen mode. Everything else works as expected.

A very simply way to fix flash, then, is to hack the binary to make it listen for another message. This can be done programmatically, like so (the script is 1 line, broken into 2 lines by a backspace. It works either way):

$ sed -i -re s/_NET_ACTIVE_WINDOW/XNET_ACTIVE_WINDOW/ \
  /usr/lib/.../libflashplayer.so

Where the last part is the path to your libflashplayer.so. This code performs a scripted search-replace of the string _NET_ACTIVE_WINDOW and substitutes XNET_ACTIVE_WINDOW. By making flash listen for a message that does not exist, we can be sure it will never react to the real _NET_ACTIVE_WINDOW, which is what we want.
If you want a backup file, use

$ sed -i.orig -re ...

but that is usually not necessary.

After this, simply restart any browsers that might use the flash binary, and behold! Full screen flash that works!

You can run the sed command as many times as you want. It’s completely idempotent, and it’s reasonably non-dangerous. So far, I’m yet to encounter a version of flash that will change in any way except the desired way, by no longer having the _NET_ACTIVE_WINDOW string.

In an upcoming post, we’ll take a look at how we can fix the resolution of fullscreen flash. That’s an entirely different problem, with an entirely different solution. Till then!

VN:F [1.9.22_1171]
Rating: 9.8/10 (18 votes cast)
Flash is terrible: How to fix fullscreen flash, 9.8 out of 10 based on 18 ratings
6 replies
  1. Alex says:

    works great thank you 🙂

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    Reply
  2. dominikh says:

    The analysis isn’t entirely correct. Clients that wish to change the window send an _NET_ACTIVE_WINDOW message, yes. The window manager doesn’t send such messages though, it handles them.

    What the window manager does do is update the *property* with the same name. And Flash listens to *property changes* on the root window.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    Reply
  3. Anon McNoone says:

    Works brilliantly thanks.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    Reply
  4. Erik Bray says:

    Very nice workaround. +1 to Dominikh’s slight correction, but it’s a quibble. Otherwise very clever and works like a charm. I *hope* Flash doesn’t need to do anything else with _NET_ACTIVE_WINDOW but I can’t think of anything I’d care about.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    Reply
  5. clook says:

    Very nice trick, well done!

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    Reply
  6. John says:

    Works great.

    A minor improvement for the libflashplayer.so file lookup can be done as follows, assuming there is only ONE libflashplayer.so file under /usr/lib
    Works for Ubuntu 16.04

    sed -i -re s/_NET_ACTIVE_WINDOW/XNET_ACTIVE_WINDOW/ “$(find /usr/lib -name ‘libflashplayer.so’)”

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

© Copyright - Christian Iversen's blog
UA-41598088-1