If you’ve ever tried to watch a Youtube video in fullscreen on a Linux multihead desktop (especially with twinview), you’ve probably seen this bug. Read on for the explanation and fix.


Above are a couple of examples. In the first case, the video is a small box in the middle of the screen. The player chrome stretches to the whole width of the display, but is vertically nearer the middle. In the second case, the video is the right size but shifted off the screen. This doesn’t happen with all Flash based video players and is dependent on the way that the applet interprets the information it gets from the Flash runtime.
If you look at the full multihead layout of my desktop it looks like this:

What happens is that Flash tells the applet the full size of the display. When the applet goes fullscreen it has to scale itself to fit the new fullscreen window. When playing video, the applet will want to maintain the aspect ratio of the video too. So it will try to fit the video to the display. So, what seems to be happening is that some applets scale the video up to the full size of the display, and then back down to the size of the fullscreen window, like this:
First, scale the video to the full display size, maintaining aspect by adding black bars at the sides:

Then, in the first example above, the result is scaled back down to fit on the primary monitor, adding black bars at the top and bottom:

In the second example the result is simply cropped to fit on the primary monitor:

If you have a different monitor layout to me you’ll probably see different but similar problems.
So how can we fix this? Flash plugin is giving the applets the size of the full area of the multihead displays. It must use some operating system specific code to find this information in the first place. If we can feed it different values when it asks for this information, we can work around the problem.
After much tracing of the Flash plugin, it turns out that it gets this data using an XGetGeometry call on the root window of the display. I used an LD_PRELOAD library to patch this call so that it returns the size of the primary monitor instead. This is enough to fix all the buggy Flash video player applets.
When using this hack I noticed that fullscreen videos played faster too. I suspect this could be because the buggy players are scaling the video up to the much larger than required size of the full display, and then back down to the monitor size, instead of directly scaling to the monitor size.
UPDATE: The source code for the workaround is available on GitHub.
March 14, 2012 at 8:33 am
Gday, I’m trying to use your patch but i’m getting an error when trying to run iceweasel…
sirjohndfox@stud:~/fullscreenhack-0.2$ LD_PRELOAD=/home/sirjohndfox/fullscreenhack-0.2/libfullscreenhack.so firefox
fullscreen hack loaded…
fullscreen hack loaded…
/usr/bin/iceweasel: line 116: exec: fullscreen: not found
Any ideas?
cheers
John
March 14, 2012 at 3:02 pm
/usr/bin/iceweasel is a shell script. You should edit it so that it loads the patch when it runs the real iceweasel binary.
October 13, 2012 at 12:50 am
Hello all
Complete noob here, but I think i’m going to make a valid point. I have downloaded the files in the archive….
No where do I stick em, where does the libfullscreenhack.so file come from?
Do I need to use a process to install the files?
The read me file is great for the purposes of sales, but it does not explain to a noob, exactly what to do. So as i’m having this issue with flash, could someone please tell me how I impliment this patch. Lets call it a “complete” idiots guide π
Thanks all in advance
March 22, 2012 at 3:56 pm
Hi
I use your patch and now I can see youtube with correct resolution. Thanks your help!!!!! i was looking for a solution since much time ago
However i have another bug yet. I see fullscreen videos in same monitor although Browser was in other. you could help me with this?.
Thanks anyway
March 22, 2012 at 6:46 pm
Flash always sticks to the first monitor where you open a browser window.
March 22, 2012 at 4:02 pm
I forgot to say I don’t have this problem in youtube. it’s in the rest of webs with flash.
I’m sorry for my english.
March 27, 2012 at 3:27 am
Did not work at all for me, tests run but after install and restart it doesn’t go full screen.
All I can think of is I don’t have any npviewer in my processes, it’s been replaced by plugin-container like a month ago or more. maybe your fix works for earlier versions of ff… you can email me if you think of something. Thanks.
I use ubuntu 11.10 x64, firefox 10 x32, flash 11.1 (x32 I guess)
PS: I had to do
sudo apt-get install libc6-dev-i386
to get some dependencies like bits/predefs.h
March 29, 2012 at 10:20 pm
EDIT : Actually, it worked twice, I don’t know on what circumstances, but more importantly, youtube is blue now, red has disappeared from any video… Only youtube and only on this computer where I ran your script. I want to reverse whatever your script does, how do I do that? Thank you.
I have tested reinstalling flash but it did nothing.
March 30, 2012 at 1:05 am
To uninstall it edit /usr/lib/nspluginwrapper/noarch/npviewer and delete the marked lines near the bottom. Then delete /usr/lib/nspluginwrapper/i386/linux/libfullscreenhack.so.
May 6, 2012 at 2:06 pm
BTW, the reversed red/blue channels is a known bug in flash player which Adobe refuses to fix.
May 6, 2012 at 1:48 pm
It works perfect, this was driving me crazy, thanks! π
May 11, 2012 at 11:35 am
This is perfect. You deserve a damn medal.
May 14, 2012 at 1:55 pm
I updated your source code if you’re interested.
I was having this issue and I came across your hack.
I changed it to 64bit and included code that detects if you’re using Xinerama and if you are it gets the values of the screen width and height relative to your cursor position.
It’s much more automated this way.
It’s also very easy to switch it back to 32bit if necessary.
Thanks,
~Timothy Zorn
May 20, 2012 at 5:56 pm
Hey Timothy, would you mind sharing your updated version? Thanks π
August 13, 2012 at 12:20 pm
Al seems to have updated his version the way I updated mine. However, I’ve simplified the compiling and installing process for using firefox with this hack.
The github repository is http://github.com/SystemDisc/fullscreenhack
Entire credit for the idea and code goes to Al. I take no credit for that.
Amazing work, Al. Let me know what you think of my fork of your work on github.
May 19, 2012 at 3:06 pm
how might i force it to the SECOND monitor?
June 8, 2012 at 6:38 pm
OMFG. This is wonderful. I think I’m in love with you now.
June 19, 2012 at 3:31 am
I have added a fix for xinerama queries, which caused some flash players to still use the wrong screen dimensions, despite youtube working flawlessly with the hack.
with the xinerama query fix all flashplayers tested work for me now, from blip.tv to porn sites.
Pastebinned it here:
http://pastebin.com/76vecbSp
Cheers!
Pingback: Flash-Videos im Fullscreen auf Dual-Monitor-Systemen | Linux und Ich
June 22, 2012 at 1:07 am
Has anyone gotten this working with chrome on amd64 arch?
I use gentoo, preload the hack (which says it was preloaded) but it does not change anything, videos are still buggy…
The tester works though.
Any help?
June 22, 2012 at 3:27 am
Chrome is launched by a shell script and I think it does some funny stuff with the environment.
July 1, 2012 at 10:26 pm
dude, you’re fucking awesome!
i hated this bug, and i’m just was about to “waste” my time to track down this stuff myself…
however googling out your “cheap” solution blows my mind π
LD_PRELOAD!!! dude, wow…i have no words…
it’s as brilliant as simple π
you simply RULE!
July 30, 2012 at 3:11 pm
This does not presently seem to work with the Flash 11.3.31.213 bundled with chrome 22.0.1201.0 dev
Works perfectly with 11.2.202.236 I have with chromium and 11.0.1.60 in firefox though.
August 6, 2012 at 1:05 am
I’m getting `cannot find -lXrandr` when I try to make… any idea which package I should install to get it? I’ve installed an X11-proto-randr-dev package with no joy, and I have no idea how to find this package (no C experience).
December 18, 2012 at 5:22 am
try:
yum provides /*/*randr.a
or
yum search xrandr
and install the -devel package.
If you use apt-get, I won’t be of much help there.
August 30, 2012 at 5:39 am
Thanks! Good job!
September 9, 2012 at 3:26 am
I’ve loaded this for firefox using the simpleinstall and it doesn’t change anything..
September 10, 2012 at 12:04 am
simpleinstall isn’t part of my code.
December 18, 2012 at 5:20 am
My code is outdated, and Al pulled the important fixes I made into his code. Use his.
he doesn’t support simpleinstall nor should he. However, simpleinstall should work but you have to launch firefox with:
LD_PRELOAD=”/usr/lib/libfullscreenhack.so” firefox
or (64bit)
LD_PRELOAD=”/usr/lib64/libfullscreenhack.so” firefox
I suggest you just use Al’s repo, not mine. π
September 25, 2012 at 3:51 am
It seems, at least for my computer, that the changes to the NVidia drivers regarding xrandr support (as in enabling it) starting from version 302.07 both made your nice and my hacky fix impotent. xinerama is not queried at all anymore, unless I override “Status XRRQueryVersion (Display *dpy, int *major_version_return, int *minor_version_return)” and have it return a failure status, then xinerama gets queried again and the flash players on blip, cinemassacre, etc are getting the right dimensions again. This grotesque fix works for me for the time being, but a proper one would obviously be better. Sadly, I lack experience and finesse, if it hadn’t been for the source you provided I wouldn’t even have known where to begin. Well, cheers!
October 5, 2012 at 3:30 pm
hi,
Iv been searching for a fix for this exact problem but unfortunately i need the fix for windows !
any suggestions anyone π
November 12, 2012 at 6:54 am
You are a god among men. After long nights of attempting to fix this issue, your workaround fixed it!
Tip for chrome users, if you disabled pepperflash like me in chrome://settings, instead tell chrome to use libfshack-npapi.so
November 18, 2012 at 10:23 pm
I got it working for firefox, but it seg faults under chrome. I have fedora x86_64, but my chrome is 32 bit. I compiled with -m32 to build the so. Any ideas?
[vanw@kyoto fullscreenhack]$ env LD_PRELOAD=$(pwd)/libfshack-ppapi.so /opt/google/chrome/google-chrome
ERROR: ld.so: object ‘/tmp/fullscreenhack/libfshack-ppapi.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tmp/fullscreenhack/libfshack-ppapi.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tmp/fullscreenhack/libfshack-ppapi.so’ from LD_PRELOAD cannot be preloaded: ignored.
ERROR: ld.so: object ‘/tmp/fullscreenhack/libfshack-ppapi.so’ from LD_PRELOAD cannot be preloaded: ignored.
fullscreen hack loaded… running under flash = 1
fullscreen hack loaded… running under flash = 1
fullscreen hack loaded… running under flash = 1
Segmentation fault (core dumped)
November 18, 2012 at 10:33 pm
UPDATE: I installed the 64-bit chrome and it works now. Thanks for the great hack.
June 12, 2013 at 1:50 am
where are the install instuctions
June 13, 2013 at 5:49 pm
is this suppose to open a new instance of firefox
October 31, 2013 at 3:18 pm
64-bit Firefox, 64-bit OS, Flash 11.2 r202. God damn flawless, man. This had been bugging me for ages.
March 29, 2014 at 5:00 am
how very clever! it works perfectly on my x86_64 Arch system with two different-sized monitors
April 1, 2014 at 11:45 am
Could some one write up how to do all this from start to finish?
Thanks
April 3, 2014 at 1:38 am
Wow, this actually worked! I must admit I wasn’t expecting it to after many hours trying various solutions!
Confirm this works in latest Ubuntu 14.04 π
April 4, 2014 at 10:42 pm
Running Eos luna. Hade to create the usr/lib64 directory manualy to install with “sudo make firefox”.
Worked beautifully.