I got a black screen under Ubuntu when the screensaver got activated, or I switched to console mode with ctrl+alt+1 and back to X with ctrl+alt+7. The cause of the problem is gnome-screensaver, so I uninstalled it, and installed xscreensaver instead.
I created a symlink at /usr/bin/gnome-screensaver-command which points at /usr/bin/xscreensaver-command. This is needed because if I use xscreensaver’s built-in lock method, it won’t notice my keypresses, only mouse movements and the screensaver could turn on if I using just my keyboard for a few minutes.
Install the following packages also: sudo apt-get install xscreensaver-data-extra xscreensaver-gl-extra
I configured xscreensaver with xscreensaver-demo:
I’ve set Turn off after to Never in System Settings -> Screen, and Lock screen after: 10 minutes. This will start the screensaver after 10 minutes.
I also had to add xscreensaver to Startup applications with the command: xscreensaver -nosplash