GNOME Bugzilla – Bug 667345
Connect to gnome-screensaver when needed instead of at startup
Last modified: 2012-03-09 11:22:19 UTC
In current trunk and 3.2.x, the libpower plugin connects to gnome-screensaver's D-BUS interface right at startup, and then saves the GDBusProxy. This causes gnome-screensaver to be dbus-activated very early during session startup, which unnecessarily slows down boot speed. Usually g-s gets started much later through an autostart .desktop file, which can be further delayed with e. g. X-GNOME-Autostart-Delay=20 to keep it out of the critical path during boot. Also, the proxy object will be invalid if gnome-screensaver gets killed or restarted in between g-s-d startup and the time when the power plugin actually calls it in upower_notify_sleep_cb(). To fix both, it would be better to create the GDBusProxy object in upower_notify_sleep_cb() instead of gsd_power_manager_start(). If gnome-screensaver fails to start, it will just fail as well at the beginning, so in both cases the screen lock will just fail on sleep. In the normal case, g-s is already running through the autostart desktop file, so there is no additional delay for entering sleep mode. I'll work on a patch for this now.
Sorry, the proxy object actually remains valid when gnome-screensaver gets restarted or killed (then it gets re-spawned), so please ignore that part.
Created attachment 204678 [details] [review] power: Lazily connect to gnome-screensaver This patch changes the logic to lazy initialization. I. e. it keeps the global manager->priv->screensaver_proxy, initializes it the first time the screen lock is invoked, and then keeps it around for future invocations. If you prefer, I'm also happy to simplify the code/patch by removing manager->priv->screensaver_proxy and always creating the proxy in upower_notify_sleep_cb(). Thanks for considering!
Attachment 204678 [details] pushed as b531fdd - power: Lazily connect to gnome-screensaver