How to “cure” screen flickering in VirtualBox on Ubuntu with a Windows 10 guest and 3D support enabled
TL;DR: The goal of this article is to explain why VirtualBox machines on Linux host flicker if your host has an nVidia video card and the VM has 3D support enabled. Also, for 64 bit Linux, a patched library file is provided which can be installed “on top” of an existing VirtualBox installation.
The patches themselves are moved to a separate page: https://techblog.devlat.eu/virtualbox-patches/
The patched library should be installed in the /usr/lib/virtualbox/
directory, as explained below.
Seems that VirtualBox has a strange problem. No, really. If you use an nVidia graphics card on your Ubuntu machine and wish to use a Windows (or, as far as I have read, basically any) virtual machine on VirtualBox for tasks that Ubuntu is not (yet) good enough and wish to enable the “experimental” 3D acceleration support, you will be unpleasantly surprised to find out that this 3D support is virtually unusable, flickering and blinking at will.
As it turns out, this problem was noticed several years ago in this forum. Basically, it’s a bug report with some folks offering a solution which involves changing a single line in the OpenGL rendering code. Unfortunately, the VirtualBox folks refused to patch this, as this breaks some functionality for an unnamed “paying customer” of theirs. This means that those affected by the problem have several options left:
a) Use a non-nVidia card, sending nVidia folks where Linus Torvalds once sent them (in this video).
b) Use the non-proprietary, free driver called nouveau with all the performance hit this implicates. Seriously, who needs 3D acceleration when it’s close to 0 (although I hope the situation will improve over time)?
c) Compile VirtualBox from source by applying the patch that can be found here.
I went through the hassle of doing that oxymoron thing of installing a VirtualBox VM on my VirtualBox to recompile a patched VirtualBox so I could patch my VirtualBox installation and use VirtualBox with 3D support and no flickering on an nVidia graphics card with the proprietary driver. π
Basically, you need one file from the patched and recompiled VirtualBox, namely VBoxOGLrenderspu.so.
Should you happen to run VirtualBox 5.1.8 (STRICTLY THAT VERSION) on an x64 CPU (that is, basically, 64-bit VirtualBox version 5.1.8) running on Ubuntu, you may download the patched library in its binary, ready-to-use form here.
Then, assuming you saved it in your Downloads
folder, execute these commands in terminal:
cd ~/Downloads
sudo mv /usr/lib/virtualbox/VBoxOGLrenderspu.so VBoxOGLrenderspu.so.original
cp VBoxOGLrenderspu.so /usr/lib/virtualbox/
Then just enable 3D acceleration on your virtual machine and launch it, enjoying flicker-free graphics.
Should you need me to recompile VirtualBox with this patch for any other VirtualBox version that might come out later, just let me know. Or, you might wish to learn it yourself (note: this requires some knowledge of command line and Linux/Debian package management) by reading the official building guide here.
Million pages of Googling and now I found reason for nVidia Flickering in VirtualBox with 3D enabled. (Optimus, Intel GFX not flicker on same laptop).
Are there any “stupid” workarounds for this… example some Hacks how do I disable all visual effects from Windows 10?
Well, as this is a VirtualBox issue, not a guest issue per se, there are no workarounds in the guest OS, excluding disabling 3D acceleration at all.
With nVidia drivers on the host, a race condition happens, causing buffers to be swapped (i.e. picture to be shown) before rendering is completed by the client, hence the flickering.
The only workaround is to change (comment out actually) a single line in VirtualBox source and recompile it. After recompilation is done, it is actually possible to just replace a single freshly compiled file,
VBoxOGLrenderspu.so
, which is located in/usr/lib/virtualbox/
. No need to uninstall the “original” VirtualBox and install the self-compiled one.For version 5.1.8 (64 bit), you may fetch a copy of the
VBoxOGLrenderspu.so
file from the link in the article. The bad thing is that as soon as a new version of VirtualBox comes out, VirtualBox also has to be recompiled to match the new version. I think the latest VirtualBox version now is 5.1.12, so I am going to recompile that so I can update my PC. With the “patched”.so
file, VirtualBox works as a charm with 3D enabled and proprietary nVidia drivers.Hey !!
I tried to build Virtualbox due to this issue as there is a new version out now -again-
but as QGLWidget is deprecated in Qt5 I get a fatal error on the build :-/
” Dokumenter/virtualbox/VirtualBox-5.1.16/src/VBox/Frontends/VirtualBox/src/VBoxGLSupportInfo.cpp:26:22: fatal error: QGLWidget: Fila eller mappa finnes ikke ”
(File or directory does not exist)
π
Greets Dag
Even if you get a fatal compile error, it does not mean your VBoxOGLrenderspu.so is not compiled yet. Just check out your build tree. Should you wish to use the official VirtualBox build guide, do it on a VM running Ubuntu 12.04 LTS, as that’s officially supported.
In any case, it’s always better to do such builds on a VM – this way, even if you manage to screw things up, you at least don’t screw up your main system. π
Is there a build for 5.1.18 (the last version of VBox)?
I found this on Google and sadly there was no file available for my VBox version, so I just created a VM on my compile server and recompiled this for 5.1.18, file @
https://bricked.de/_stuff/compiles/VBox/5.1.18_%5Br114002%5D_VBoxOGLrenderspu.so.zip
Confirmed working for 5.1.18 revision 114002.
Just posting this for anyone that went looking for this on Google like I did.
Thank you! I can confirm it’s working properly π
great work on this. I’ll anxiously await your patch as I’ve already got 5.1.18 just installed and my VMs up and just found out about this wonderful feature.
..sorry, that is if you upgrade to 5.1.18 π
Hi all,
Sorry, I was a bit busy with my work, so had no time to even approve the comments. ?
Thanks to showp1984 for also posting a recompiled VBoxOGLrenderspu.so file. I am doing recompilations as soon as I update VirtualBox on my PC. As Iβm still running 5.1.14, havenβt done 5.1.18 recompilation yet. As to the next versions, I will try to keep in line with them. ?
@showp1984 thank you, i tried it and can confirm its workng. No more flickering issues. I noticed your .so file compared to original is much bigger (~500kb) and i had impression patch was small (1 line or something..)…
Thank you
The size of the binaries depends on many factors, including whether debug information is included etc. Also, my build environment is based around Ubuntu 16.04, while the “original” VirtualBox is built around Ubuntu 12.04. Anyway, is the size that matters or the bug that is fixed? π
Yeah, that’s because I didn’t strip away debug symbols. Those account for a large amount. I also built with the highest optimization setting, which generates larger files as well, because I generally don’t care about a few megs π
Built a patched .so for VirtualBox 5.1.20 (the sources say 5.1.20a to be precise).
You can get it from here: https://drive.google.com/open?id=0B30DlLqffmOlV18xUnVwVXY5WUk
* Built on Fedora 25 64bit. Tested on the same machine with a Windows 10 guest.
Wow, so lucky to have found this blog! Current version is 5.1.22 so I just downgraded, fortunatelly in Fedora it’s literally one line, so leaving that here for others:
dnf install VirtualBox-5.1-5.1.18_114002_fedora25-1.x86_64
wget http://techblog.devlat.eu/downloads/vbox-5.1.18/VBoxOGLrenderspu.so -O /usr/lib/virtualbox/VBoxOGLrenderspu.so
Voila, flicker-free. Wow.
Ive now started getting different graphics corruption, that I suspect is the same bug π
Its hard to describe but I guess its in the new graphics systems for Win10 – new app systems sometimes in the Icons on the new add/remove apps system – and another example is if you install for example the Xbox Live app (not any gaming but the overview app that shows what you have been up to etc. If you for example install a game like the Solitaire app, there are graphics corruption in various places , (using the latest Win10 Pro 1703/15063.332) parallell diagonal lines etc in images. I hope its not just me ….
I can confirm this works for 5.1.8_Debian r111374. I’m running Debian 8.7 64 bit and have VirtualBox 5.1.8 installed from the jessie-backports repo. Just drop the library in place of the old one, and it works like a charm.
I’ve been so frustrated by this problem every single time I need to boot my Windows 10 VM, and I’m glad someone found a fix for it. Thanks for sharing!
Here is the same patched library, built from 5.1.22 sources:
https://drive.google.com/open?id=0B30DlLqffmOlVGdkd01qOXRuZGM
Tested locally with a Fedora 25 x64 host and a Windows 10 guest. No flicker.
I can not confirm that the 5.1.22 patch worked on my Debian jessie x64 host. VBox crashes at login screen with Windows 10 (creators update).
Maybe because it was build with Fedora? Does someone already has a patch for 5.1.22-115126, build on Debian or Ubuntu x64?
Thank you for this guys, at least i know now where to look to solve my flickering issues…
I’m sorry that it didn’t work for you, Fr4ncis.
I wonder what differences between the distros cause the crash, but it will remain unknown for now since I don’t have time to investigate.
I do, however, have access to a remote Ubuntu 16.04 (xenial) x64 machine, and I had some time while recompiling a big project on another machine, so there you go:
https://drive.google.com/open?id=0B30DlLqffmOlTEhJMXRIX0ZtalE
The _deb_ tar.gz contains the patched library, this time built on Ubuntu.
I really hope that it works for you, but I didn’t even test it. Best I can do from here is to cross my fingers.
***
To everyone, this is where I’m going to upload the patched libraries from now on, until Oracle hopefully pushes an official fix to this issue:
https://drive.google.com/open?id=0B30DlLqffmOlTEhJMXRIX0ZtalE
It’s worth checking there when new versions come out, even if I don’t comment here.
I have new problems ! Ive managed to compile the fixed file – but unfortunately I get other graphics corruption … with unknown reason .. here is links to screenshots on OneDrive ..
Doug !
https://1drv.ms/i/s!AoL0kjnwi2hQiUq3ID8NxEH1zkzU
https://1drv.ms/i/s!AoL0kjnwi2hQiUtWZmXHEb60dh9Q
Hello !
Here are screenshots of my new graphics corruption ! I dont know if my previous post came through right .. Theyre on OneDrive/MS..
DougJ
https://1drv.ms/i/s!AoL0kjnwi2hQiUtWZmXHEb60dh9Q
https://1drv.ms/i/s!AoL0kjnwi2hQiUq3ID8NxEH1zkzU
Hello Itzik,
still had the same crash at login time, but i found a solution!
It crashes only if you start the vm in “headless mode”. So starting in “normal mode” seems to work fine and also the screen flickering disappears. This workaround is okay for me.
Thank you so much for your help and time, and I hope to see further patches until VBox team is fixing that…
Thanks, Fr4ncis
The `VBoxOGLrenderspu.so` lib for VirtualBox 5.1.24 is now available here:
https://drive.google.com/drive/folders/0B30DlLqffmOlTEhJMXRIX0ZtalE?usp=sharing
(Compiled and tested on Fedora 25_x64 KDE spin with Windows 10 guest)
Hi Itzik,
(form now you will be my best friend π )
Thanks so much for your great job.
Hi all and thanks for the helpful post and comments!
I was just updated to VirtualBox 5.1.26 and was subjected to the flickering hell once again. Since there was no version of the VBoxOGLrenderspu.so for this version yet I rebuilt it myself with the patch and though I might save some hassle for those of you on Ubuntu OSes. Here is the link to the file for VBox 5.1.26 ONLY https://drive.google.com/file/d/0B-bQmaa9GDxeQmdORXg0Yl9nQWs
Thanks and enjoy!
Julian
You saved my time…thanks!
Thank you Julian! Is your file the one for the 64 bit version? I checked the drive Itzik posted and see a zip file for 5.1.26 but was unable to open it.
That’s easy:
$ file vboxoglrenderspu_v5.1.26_x64.zip
vboxoglrenderspu_v5.1.26_x64.zip: POSIX tar archive (GNU)
$ tar xvf vboxoglrenderspu_v5.1.26_x64.zip
VBoxOGLrenderspu.so
π
Fixed that. Sorry for the mixup.
The fix work fine in VirtualBox 5.1.24, 5.1.26, renderspu_glx.c wasn’t modified in last 13 month
I tried installing 5.1 on Ubuntu 16.04 (LTS) via this set of instructions: http://ubuntuhandbook.org/index.php/2016/07/virtualbox-5-1-released/ but ended up having errors with and without the updated VBoxOGLrenderspu.so (version 5.1.26).
Is there any hope of getting a compiled version for Ubuntu 16.04 (amd64) with the current LTS version of VirtualBox (5.0.40)?
@AcklenX, what kind of errors did you get from VirtualBox 5.1? did you at least file a bug report in hope that you will not be stuck with 5.0 (which is no longer supported by Oracle) forever?
I compiled the patched library for you on an Ubuntu 16.04 (amd64) machine, but it is NOT tested. So make backups of the two files before replacing with the ones from the archive.
You can find vboxogl_v5.0.40_deb_x64.tar.gz
in my Drive share: https://drive.google.com/open?id=0B30DlLqffmOlTEhJMXRIX0ZtalE
There are two files in this tar instead of one, since after applying the patch I noticed that these two files were recompiled. Maybe they are both affected by the patch. I don’t know.
Good luck
Hello.
How I can fix it in mac os x? VirtualBox 5.1.26.
Thanks
Well, basically, you have to set up a build environment on your macOS box and compile VirtualBox yourself.
Unfortunately, we don’t have any macOS machines available and thus are not able to do this ourselves.
You are the best! Thank you for your post, research and the page with VirtualBox patches! I think I love you.
OMG, I’ve been dealing with flickering while using the oVirt viewer in a VM for days… I almost lost my mind, this post is a life saver.
Hi again,
Since VBox 5.1.30 is now out for a while already I decided to recompile the offending file for this version as well. π
You can find the compiled patched file here https://drive.google.com/file/d/0B-bQmaa9GDxeb1VvSUVGNnR0NkU/view?usp=sharing
It was compiled on Ubuntu 64 bit from VBox’s source tar – USE ON YOUR OWN RISK.
Cheers,
Julian
Awesome, thanks!
5.2 is out.
Is it possible to request file for 5.2
Hi,
solidarity with aks.
Thanks again
Just a FYI, although probably not recommended the file generated by Julian for virtualbox 5.1.30 works with 5.2. It solved my problem. So far I haven’t had problems.
I compiled the version for 5.2.0 for those that need it but I myself am still running 5.1.30 so I can’ yet try myself if it works https://drive.google.com/open?id=1oWbc68kF_bi7dLAoNcfJbpQ5A7fuSToh Remember to rename the file to only VBoxOGLrenderspu.so before putting it in its location.
As usual it was compiled on Ubuntu 64 bit from VBoxβs source tar β USE ON YOUR OWN RISK.
Julian
Thanks – the flickering was really annoying
Hi Julian,
This does not work on VBox 5.2.0 on Debian, sadly. :'(
Big very thanks!
VirtualBox 5.2.2 is out.
version for 5.2.0 not work with 5.2.2, but 5.1.30 works with 5.2.2.
It solved my problem too.
WIN8x64 guest / Ubuntu 16.04 host
It is a pity that this is not added to the official Vbox release.
Thx this works fine
debian stretch 64 / win 10 / vbox version 5.1.28 64 bit
Thanks for this.
I can confirm that the 5.1.30 build works with VBox 5.2.4
Is there a new version that was created for 5.2.4 or should we be using 5.1.30?
https://www.datafilehost.com/d/c1b2c017
for VBox 5.2.4 (compiled in Ubuntu 16.04 64bit). My W10 guest flickers no more, heh…
https://www.datafilehost.com/d/680c9d69
for recently released VBox 5.2.6 (Ubuntu 16.04 64bit)
Thanks ioni you’re a life saver.
There is a runtime environment patch in the bug report now… it would be nice if someone from VirtualBox could implement this into a release…
Can someone tell how can i compile by myself pls, i will thanks a lot.
Hi,
thanks for your article. I encountered the same problems with Ubuntu 17.10 (Gnome, Xorg) after adding a graphic card (Nvidia) to my Intel-Xeon-GPU. I wanted to run a virtual machines (Windows) dedicated to this card allowing and to speed up 3D.
So far I encountered the following: after a lot of general problems with 3D apps under VirtualBox in the past due to the fact, that it is only possible to give the machine 256 MB RAM (!!!) I switched for those apps to vmware-player. With it, it is no problem to give the machine enough RAM from the graphic card to use e.g. Autodesk Fusion 360. The latter never ran on VirtualBox without problems (artifacts). So I moved all those apps to Vmware-player vms and completely turned off 3D in VirtualBox. As far, as this problem is solved.
See:
* https://wiki.blue-it.org/VMware
* https://wiki.blue-it.org/Autodesk_Fusion_360
Cheers
Axel
Forgot to mention: I am using VirtualBox 5.6 (so the bug is NOT solved) ;-(
@Axel what is your message?
Saying you’re using VirtualBox 5.6 (you meant 5.26 i presume) therefore the bug is not solved??? Using some version means only that, nothing else… what’s have to do with bugs?
Forgot to mention:) I am using 5.26 and at me it no longer flickers using the above patch.
thank you so much ioni
Starting with 5.2.8 the fix is already included in the official release (controlled by the new environment variable CR_RENDER_FORCE_PRESENT_MAIN_THREAD). Bottom line, simply install the new release and will be flicker free (no more patches required) took them few years…
I just updated and the flicker is still there
to expand on ioni’s post a little bit, you need to `export CR_RENDER_FORCE_PRESENT_MAIN_THREAD=0` to stop the flickering
thanks again ioni.
VBox 5.2.10 r122088 here, installed Windows 10 april 2018 version but flickering still present, so they doesn’t correct the bug.
Where can I find the patch for this vbox version?
Thx!!!
Hi,
I just installed MacOS High Sierra on my VirtualBox 5.2.12 on Windows 10 Machine using Nvidia Card.
It’s my first ever installation and I’m happy it’s working pretty well. I’m getting flickers when hovering on the dock icons and scrolling down on pages.
I don’t know anything about this, googled and found this page but as far as I can tell, there’s no patch for 5.2.12 is there? Also as I’m a noob, if there was – where do I begin?
Thanks