What to do against game performance drop in 12.04 when using unity (3D)?

Solution 1:

It's not a real solution, but at least it might be a (hopefully) useful workaround (apart from simply using Unity 2D).

Before you start a game, open up Nautilus (the file manager) and go to /usr/share/application. Open up a terminal, type metacity --replace, and press enter. Don't panick, the Unity interface will disappear, but this is my intention. Launch the game from the file manager (the launcher for the game should be in the folder I mentioned). After you finish playing your game, type unity --replace in the terminal window, and press enter. Your desktop is now restored to how it was.
This should work as it's probably Unity running in the background that's causing trouble.

Also, I'd report this as a bug. It's definitely something that needs to be fixed. If you submit a bug report, be sure to leave a link here so other people who are experiencing this problem can mark it as "affecting them", which will get it fixed sooner.

Solution 2:

You could always update to the 304.22 Nvidia Beta drivers and see what happens. I was having huge performance issues with Ubuntu 12.04 LTS and the Nvidia 295.59 version & the 302.07 version seemed to fix some minor things. Most of the issues have been resolved by updating the latest 304.22 driver. Now my GeForce performance is finally equal to Windows XP but there are still minor issues from a few applications but the situation is really improved significantly. You should use the latest Nvidia drivers at all times, even if they are in BETA because it seems that the older stable ones aren't tested by Nvidia's team on newer Kernel and Ubuntu rolling updates causing unexpected problem and issues. Problem is that Nvidia needs to Open Source their drivers so that Ubuntu maintainers and Linux developers can keep everything in sync but that's an ongoing discussion that will not resolve anytime soon :-(

You can obtain them http://www.geforce.com/drivers/beta-legacy

The 304.22 drivers have tons of large scale fixes like:

  • Added support for the following GPUs:
    • GeForce GTX 680M
      Quadro K1000M
      Quadro K2000M
  • Enhanced the functionality of the IncludeImplicitMetaModes Xconfiguration option:
  • Implicit MetaModes will be added for the primary display device,even if multiple display devices are in use when X is initialized.
  • Implicit MetaModes will be added for common resolutions, even if there isn't a mode with that resolution in the mode pool of the display device.
  • Extended the syntax of the IncludeImplicitMetaModes configuration option, e.g., to control which display device is
    used for creation of implicit MetaModes.
  • See the description of the IncludeImplicitMetaModes X configuration
    option in the README for details.

  • Modified the handling of the RandR 1.0/1.1 requests RRGetScreenInfo and RRSetScreenConfig (e.g., `xrandr -q --q1` and `xrandr --size ...` and `xrandr --orientation ...`) such that they operate on MetaModes. This was the behavior in NVIDIA X driver versions 295.xx and earlier, but 302.xx releases altered the handling of these RandR 1.0/1.1 requests to operate on a single RandR output's modes.
  • With the above changes to IncludeImplicitMetaModes and RandR 1.0/1.1 handling, fullscreen applications (e.g., SDL-based applications, Wine), should have more resolutions available to them, and should interact better with multiple monitor configurations.
  • Fixed a bug that could cause G8x, G9x, and GT2xx GPUs to display a black screen or corruption after waking up from suspend.
  • Fixed several bugs that could cause some OpenGL programs to hang when calling fork(3).
  • Fixed an nvidia-settings bug that caused the results of ProbeDisplays queries made with the --display-device-string option to be formatted incorrectly.
  • Improved the responsiveness of updates to the nvidia-settings control panel when displays are hotplugged.
  • Fixed a bug that caused display corruption when setting some transforms, especially when panning a transformed display.
  • Fixed a bug that caused extra RandR events to be generated the first time a display is hotplugged.
  • Fixed a bug that caused X11 modelines with '@' in their names to be rejected.
  • Added support for DisplayPort 1.2 branch devices, which allow multiple displays to be connected to a single DisplayPort connector on a graphics board.
  • Fixed a bug that caused most OpenGL texture uploads to be slow when the context was bound rendering to an RGB overlay drawable.
  • Fixed a bug that caused audio over HDMI to not work after restarting the X server on some MCP7x (IGP) GPUs.
  • Updated the X configuration option "UseDisplayDevice" to honor the value "none" on any GPU.
  • Added support for DKMS in nvidia-installer. Installing the kernel module through DKMS allows the module to be rebuilt automatically when changing to a different Linux kernel. See the README and the nvidia-installer help text or the "--dkms" option.
  • Added RandR output properties _ConnectorLocation, ConnectorNumber,ConnectorType, EDID, _GUID, and SignalFormat. See the README for details on these properties.
  • Extended support for Base Mosaic to all G80+ SLI configurations with up to three displays.
  • Fixed a bug that caused some monitors to fail to wake from DPMS suspend mode when multiple DisplayPort monitors were attached to one GPU.
  • Removed controls for XVideo attributes from the "X Server XVideo Settings" page of the nvidia-settings control panel. XVideo attributes can be configured in XVideo player applications, or through utilities such as xvattr.
  • Fixed a bug that caused all ports on an XVideo adaptor to share color correction settings.
  • Removed support for the following X configuration options:
    • SecondMonitorHorizSync
      SecondMonitorVertRefresh
    Similar control is available through the NVIDIA HorizSync and VertRefresh X configuration options. Please see the NVIDIA driver README for details.
  • Fixed a bug that prevented NVIDIA 3D Vision Pro from working properly when switching between X servers on different VTs.
  • Added support for desktop panning when rotation, reflection, or transformation is applied to a display device (either through RandR or through the MetaMode syntax); panning would previously be ignored in that case.
  • Solution 3:

    EDIT: X is now lockable thru xscreensaver

    hi! try this, I am having great results using it, mostly for games! As it wont be managed by Unity, you may have great results too!

    I have created this script that creates a new X session and runs a command or open a terminal so you can run it there.

    openNewX.sh

    #!/bin/bash
    
    function FUNCisX1running {
      ps -A -o command |grep -v "grep" |grep -q -x "X :1"
    }
    
    useJWM=true
    useKbd=true
    while [[ ${1:0:2} == "--" ]]; do
      if [[ "$1" == "--no-wm" ]]; then #opt SKIP WINDOW MANAGER (run pure X alone)
        useJWM=false
        shift
      elif [[ "$1" == "--no-kbd" ]]; then #opt SKIP Keyboard setup
        useKbd=false
        shift
      elif [[ "$1" == "--isRunning" ]]; then #opt check if new X :1 is already running
        if FUNCisX1running; then
          exit 0
        else
          exit 1
        fi
      elif [[ "$1" == "--help" ]]; then #opt show help info
        echo "usage: options runCommand"
    
        # this sed only cleans lines that have extended options with "--" prefixed
        sedCleanHelpLine='s"\(.*\"\)\(--.*\)\".*#opt" \2"' #helpskip
        grep "#opt" $0 |grep -v "#helpskip" |sed "$sedCleanHelpLine"
    
        exit 0
      else
        #echoc -p "invalid option $1"
        echo "PROBLEM: invalid option $1"
        $0 --help
        exit 1
      fi
    done
    #echo "going to execute: $@"
    #runCmd="$1" #this command must be simple, if need complex put on a script file and call it!
    runCmd="$@" #this command must be simple, if need complex put on a script file and call it!
    
    #if ! echoc -q -t 2 "use JWM window manager@Dy"; then
    #  useJWM=false
    #fi
    
    # run in a thread, prevents I from ctrl+c here what breaks THIS X instace and locks keyb
    if ! FUNCisX1running; then
      xterm -e "\
      echo \"INFO: hit CTRL+C to exit the other X session and close this window\";\
      echo \"INFO: running in a thread (child proccess) to prevent ctrl+c from freezing this X session and the machine!\";\
      echo \"INFO: hit ctrl+alt+f7 to get back to this X session (f7, f8 etc, may vary..)\";\
      echo ;\
      echo \"Going to execute on another X session: $runCmd\";\
      sudo X :1"&
    fi
    #sudo chvt 8 # this line to force go to X :1 terminal
    
    # wait for X to start
    while ! FUNCisX1running; do
      sleep 1
    done
    
    # run in a thread, prevents I from ctrl+c here what breaks THIS X instace and locks keyb
    if $useJWM; then
      if [[ ! -f "$HOME/.jwmrc" ]]; then
        echo '<?xml version="1.0"?><JWM><Key mask="4" key="L">exec:xscreensaver-command --lock</Key></JWM>' \
          >$HOME/.jwmrc
        #if ! jwm -p; then
        #  rm $HOME/.jwmrc
        #  echo ".jwmrc is invalid"
        #else
          echo "see http://joewing.net/programs/jwm/config.shtml#keys"
          echo "with Super+L you can lock the screen now"
        #fi
      fi
    
      jwm -display :1&
    fi
    
    kbdSetup="echo \"SKIP: kbd setup\""
    if $useKbd; then
      kbdSetup="setxkbmap -layout us"
    fi
    
    sleep 2
    
    xscreensaver -display :1&
    
    # setxkbmap is good for games that have console access!; bash is to keep console open!
    
    # nothing
    #xterm -display :1&
    
    # dead keys
    #xterm -display :1 -e "setxkbmap -layout us -variant intl; bash"&
    
    # good for games!
    xterm -display :1 -e "$kbdSetup; bash -c \"$runCmd\"; bash"&
    #xterm -display :1 -e "$kbdSetup; bash -c \"$@\"; bash"&
    

    also, add this at: compiz config settings manager -> window rules -> non closeable windows:

    (class=XTerm) & (title=sudo X :1) & (name=xterm)
    

    This will prevent you from closing that terminal (use ctrl+c to close the other X session and also the terminal), because if you close "the window" it will freeze your current X session!

    It has the advantage that you dont have alt+enter full screen problems, also no Alt+TAB full screen problems; you can run with more stability any 3D game, from Urban Terror (linux native) to games run with Wine! Even some browsers that run 3D games like Firefox with Quake!

    Obs.: you may want to install jwm package, not required but will make a difference if you need to do any window management there..

    PS.: it can be improved of course, my plan is to add the keyboard setup to an option, but I do it very slowly ;), if someone improve/clean it up, post so I can update mine script :)