I have this login problem with my Ubuntu 12.10 installation, and the cure for it is listed here. It may work for other versions of Ubuntu, but there’s no guarantee.
Workaround for the Ubuntu 12.10 blank screen problem
Sometimes, on waking the computer up from being asleep/screensaver or whatever, all I get is a blank screen. No desktop icons, no menus, no status bar, nothing.
Here’s how to get around the problem. Bear in mind that this is not a cure, just a workaround:
Right-click on the desktop and a context menu will pop up with the following options:
Create New Folder
Create New Document
Organise Desktop by Name
Keep Aligned
Paste
Change Desktop Background
Click on the last option: Change Desktop Background, and the System Settings window will open at the Appearance Tab.
Change to All Settings by ckicking All Settings at the top of the window
Now click on Displays in the Hardware section.
Nine times out of ten, this restores the desktop icons and menus and all the other open program windows to normal.
If it doesn’t, press Ctrl-Alt-T to open a root terminal, and type:
sudo reboot