Ubuntu Nvidia Compiz “Black Window Bug” Fix

Black Window Bug

Some Nvidia graphics cards suffer from a bug called the “Black Window Bug” when running Compiz (the Linux 3D desktop). The Nvidia drivers will stop rendering windows after a certain memory limit has been reached. This is a known Nvidia driver bug and has been fixed but did not make it into the Ubuntu Gutsy 7.10 release. Fortunately, there is a fairly simple fix.

BWB Fix

  1. Download the fixed file and use Archive Manager to unzip the file to your desktop.
  2. Open a terminal (Applications->Accessories->Terminal).
  3. Back up the broken file by entering the following command into the terminal (without the ‘$’). No output should show:
    $ cp /usr/bin/compiz ~/Desktop/compiz.back
  4. Replace the broken file by entering the following command into the terminal (without the ‘$’). You should have to enter your password after entering the command for the command to run. No output should show besides the password prompt:
    $ sudo cp ~/Desktop/compiz-manager/compiz-manager /usr/bin/compiz
  5. Enable the fix by entering the following command into the terminal (without the ‘$’). No output should show:
    $ echo "INDIRECT=yes" > ~/.config/compiz/compiz-manager
  6. Close all your programs and restart X by hitting Ctrl + Alt + Backspace.

Reverting “the Fix”

When the fixed version of the Nvidia drivers are packaged into the next release of Ubuntu, to undo this “fix,” simply remove the .config/compiz/compiz-manager file. Other fixes for this problem do exists, though I feel they are harder and more risky.

More “Fix” Details

There are two things causing the BWB. The first is that indirect rendering needs to be enabled to work around the Nvidia driver bug. That’s what the “$ echo “INDIRECT=yes” > [...]” command does. The second problem is that compiz has a bug where it doesn’t read the setting that the former line is intended to direct. The file I’ve linked too is an official development version of the file that takes care of reading the indirect rendering setting.

    None Found
  • nawsher

    hey, i applied your fix as you mentioned. but i am still having the ‘black window’ problem after opening couple of windows.
    let me know if i got your right….
    in step 2a: you simply made a backup of original.
    in step 2b: you copied the extracted ‘compiz-manager’ folder with its contents to /user/bin.
    in step 3: should i be getting any message when i run the command? cause i didn’t get any.

    i am a newbie in ubuntu, so please help.

    thanks in advance.

  • http://humani.st Luke Hoersten

    You followed the instructions correctly, I just had a typo. I had “~/Desktop/compiz-manager” when I should have had “~/Desktop/compiz-manager/compiz-manager”. I’ve fixed the guide to reflect this.

    So you should be copying a text file called “~/Desktop/compiz-manager/compiz-manager” over “/usr/bin/compiz”. This is to fix a bug which will enable us to fix the BWB.

    Let me know if you have any more trouble.

    -Luke

  • nawsher

    thanks for the correction. just for your info, i downloaded the driver from nvidia and installed it. no more BWB :)

    thanks for your article, i was looking for this fix for ages.

  • http://humani.st Luke Hoersten

    No problem. If you see at the end of the article, I link to another fix which describes installing the Nvidia drivers from Nvidia. This, however, on a Linux distribution with package management (like Ubuntu) is not recommended. The Nvidia drivers that were installed via a run script will not be managed or known about by Ubuntu.

    The solution I give is much safer.

  • Chino

    Hi, I have the same problem but I’m unable to run the step 5 I keep receiving the same msg .config/compiz/compiz-manager no such file or directory. Any help would be great, I’m new with Ubuntu and I have been unable to fix this proble. Thanks.

  • http://humani.st Luke Hoersten

    Try “$ touch ~/.config/compiz/compiz-manager; echo “INDIRECT=yes” > ~/.config/compiz/compiz-manager” for step 5. This will just try to create the directory before it writes to it.

  • Chino

    It looks like all I get with the method above is a gren vertical line to the right of my screen, like 1px or 2 wide. I don’t now which file should I update with this line $ echo “INDIRECT=yes” > .config/compiz/compiz-manager I changed it to this $ echo “INDIRECT=yes” > compiz-manager and it ran but as I said I only get the green vertical line and the black windows keep appearing.

    Any idea? Thanks in advanced.

  • Chino

    Hi There, It looks like I was pointing to a wrong folder, my bad. I will try again today when I arrive home. I install the new nVidia Driver and after some modification and manual changes to the xorg.conf I got it to work correctly and also I was able to enable the compiz-fusion (It had been imposible before since ubuntu was asking me to select enable nvidia driver from some admin window that I dont recall its name) the BWB is still appearing and if I understand correctly (I´m new with linux) I need to tell compiz to use indirect rendering right. Just one question what are the changes in the /usr/bin/compiz file that you are providing.

    Thanks for your help, it seems like your fix should work, I’m the one who is highly ignorant of Linux here, but in this days of try and error it seems like I’m begining to see some light at the en of the tunnel.

    PS. I have another issue with compiz that I’ll solved after the BWB windows always open at the top left corner of my screen and behind the application panel, which is an issue because I have to always manually grab them and move them so I can see the entire window, any help with that would be awesome. Thanks.

  • http://humani.st Luke Hoersten

    There are two things causing the BWB. The first is that, as you’ve said, indirect rendering needs to be enabled. That’s what the “$ echo “INDIRECT=yes” > [...]” command does. The second problem is that compiz has a bug where it doesn’t read the setting that the former line is intended to direct. The file I’ve linked too is a development version of the file that takes care of reading the indirect rendering setting.

    Really, the fact that indirect rendering even needs to be used is an Nvidia driver bug but that is proprietary software and we are at the hands of a corporation when it comes to a real fix.

    I hope your able to get everything ironed out. I’m not sure what the second bug you mentioned is. I’ve never heard of that before.

  • Chino

    Hi there, that problem with the windows rendering at in a weird part of the screen was solved by enabling place-window plugin of compiz.

    Since I intalled the new Nvidia Driver with envy (and finally getting ubuntu to use it by modifyong the xorg.conf, by some strange reason it was always configuring my laptop LCD in a weird resolution and not telling ubuntu to use nvidia driver instead of vesa anyways…) the appearing of the BWB has been less frequent but it still occurs, I did what you suggested and it’s actually working awesome I have like Twelve windows opened on the same desktop, no way I could do that before even after installing the new nVidia Driver.

    But I have some doubts, I did not have that file inside that folder before (I checked) how does compiz now it has to go there and use it, I actually don’t get it, Could you pls explain a little to know why it worked?

  • Chino

    PS. I mean I undesrtand that with indirect rendering the windows are painted in a different way, which is probably why it solves the BWB problem, but the reason why compiz nows it has to pickup that file that did not exist before intrigues me….

  • Chino

    PSS: Wiat a moment… then “The second problem is that compiz has a bug where it doesn’t read the setting that the former line is intended to direct. The file I’ve linked too is an official development version of the file that takes care of reading the indirect rendering setting. ” so when we moved this file to the /usr/bin/compiz we told the compiz-fusion to look for the other file we created afterwards…. Now it makes sense.

    Thanks a lot, LukeHoersten. This is as you said a lot easier than othe fixes, even for me who is a newbie with linux, just a matter of understand some things. I’ll make sure to paste this link whenever I see the BWB mentioned :-) . Awesome work, keep it up, regards.

  • http://humani.st Luke Hoersten

    It looks like you understand. If you’ve done everything correctly, you should never see any black windows as far as I know (I’m no expert though).

  • RobTaintor

    Thank you very much for this fix. It seems so far that it has been very effective. I will update if I run into another problem. Keep up the good work

  • http://humani.st Luke Hoersten

    Thanks a lot! I’m just trying to help.

  • Zeljko

    Hi, you have solved bwb issue, but after applying this patch desktop environment is not as responsive as it used to be. Windows are 20-30% slower, even my coursor lags sometimes. Overall feeling in use is like I have downgraded my machine.. could you help me with this?

  • http://humani.st Luke Hoersten

    I’m no expert but this could be a result of using indirect rendering. Indirect rendering, if I recall correctly, means all the desktop rendering is done through the X server which then renders on the graphics card instead of rendering straight from compiz to the graphics card. Extra buffers are introduced in this case. If you are experiencing slowdowns when using indirect rendering, chances are the problem is somewhere in there. I’ll try to look into this more when I get a chance.

    Looks like for now you unfortunately have either the direct rendering BWB or the indirect rendering desktop slowdown. Let me know if you can fix either of these problems. Hopefully an Nvidia fix to the direct rendering reaches stable distros soon.

  • noob ubuntu

    THANK YOU

  • noob ubuntu

    THANK YOU

  • an onymous

    I encountered this with a 256MB nvidia 6600GT AGP card when the 'AGP Aperture size' in the BIOS was set to a value lower than the amount of memory on the video card. After upping the value in the BIOS, the problem went away.