This forum has been archived. All content is frozen. Please use KDE Discuss instead.

suspend/resume issues: black screen and mouse cursor

Tags: None
(comma "," separated)
dreamz
Registered Member
Posts
70
Karma
0
OS
i just noticed something. now, this correlation may be spurious, but it looks like suspend and resume work properly when programs (e.g., browser, file manager, etc.) are open, but not when there are no programs open.
User avatar
LBL
Registered Member
Posts
131
Karma
0
OS
I doesn't seem to be the same with me... it happens in both cases. maybe it's different


42: There is no other answer. There are only different ways to express it.
0x2A
0o52
0b101010
dreamz
Registered Member
Posts
70
Karma
0
OS
i think i might have figured out the problem.

preliminary note: any screen-blanking event (e.g., switching to a virtual terminal, suspend, etc.) causes the problem.

i think it has to do with the graphics. i've noticed that when compositing is disabled, i can suspend, switch between the virtual terminals and the gui, etc. without any issue. when compositing is enabled, i run into problems.

some more evidence: as noted above, i can return to the gui properly when compositing is disabled. but as soon as i enable compositing, the screen turns black and all i get is the mouse cursor.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Which graphics drivers do you use? Are they Intel drivers by any chance?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
i'm using the open source ati drivers.

i just did some more testing. i think the following should work. to get suspend and resume to work properly, disable compositing before suspending, and on resume, replace kwin and then enable compositing.

i did that manually and things seemed to work. now i'm trying to figure out how to do it automatically.
dreamz
Registered Member
Posts
70
Karma
0
OS
i ended up creating a hook for pm-utils. i called it 00togglecompositing and put it in /etc/pm/sleep.d.

Code: Select all
#!/bin/bash
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
. /home/$USER/.dbus/session-bus/*
case $1 in
   hibernate)
       ;;
   suspend)
       if `sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin compositingActive`;
       then
               sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;
               sleep 1
       fi
       ;;
   thaw)
       ;;
   resume)
               kwin --replace
               sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;
       ;;
   *)
       ;;
esac


but for some reason, i get these errors:

Code: Select all
/etc/pm/sleep.d/00togglecompositing suspend suspend: Could not connect to D-Bus server: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /tmp/dbus-x2WQfx6PSQ: Connection refused
success.


and

Code: Select all
/etc/pm/sleep.d/00togglecompositing resume suspend: kwin: cannot connect to X server
Could not connect to D-Bus server: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /tmp/dbus-x2WQfx6PSQ: Connection refused
Returned exit code 1.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You need to set DISPLAY to ":0"

additionally, I would recommend sourcing ~/.dbus/session-bus/* as the user, not as root, for both security and multiple user support.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
bcooksley wrote:You need to set DISPLAY to ":0"

can you elaborate? i just copied the code from the arch wiki: http://wiki.archlinux.org/index.php/Pm- ... re_suspend

how do i set it? what does that command do?

additionally, I would recommend sourcing ~/.dbus/session-bus/* as the user, not as root, for both security and multiple user support.

can you explain what you mean here as well?

i was doing some more research, and it seems an alternative approach would be to write a script that accomplishes the same task and link it to powerdevil. this is easier than creating a hook for pm-utils in the sense that pm-utils is outside of x.

what do you think of the alternative approach? is it possible to implement?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Add the following scripts:

~/.local/prepare-suspend.sh
Code: Select all
eval 'cat $HOME/.dbus/session-bus/*'
export DISPLAY=:0

if 'qdbus org.kde.kwin /KWin compositingActive` then
        qdbus org.kde.kwin /KWin toggleCompositing
        sleep 2s
fi


~/.local/resume-suspend.sh
Code: Select all
eval 'cat $HOME/.dbus/session-bus/*'
export DISPLAY=:0

qdbus org.kde.kwin /KWin toggleCompositing


Change 00togglecompositing to:
Code: Select all
#!/bin/bash
USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
case $1 in
   hibernate)
       ;;
   suspend)
       sudo -u $USER -i /home/$USER/.local/prepare-suspend.sh
       ;;
   thaw)
       ;;
   resume)
       sudo -u $USER -i /home/$USER/.local/resume-suspend.sh
       ;;
   *)
       ;;
esac


In your script, if KWin had managed to access the display, then it would have started and KWin would have been running as root which is EXTREMELY dangerous.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
thank you, bcooksley!

note: there are two minor errors in the first script. first, the quotation mark before 'qdbus' should be a left quotation mark '`'. second, a semicolon is needed before the 'then'.

the fixed script:

Code: Select all
eval 'cat $HOME/.dbus/session-bus/*'
export DISPLAY=:0

if `qdbus org.kde.kwin /KWin compositingActive`; then
        qdbus org.kde.kwin /KWin toggleCompositing
        sleep 2s
fi


seems to work.

also, the second script is problematic on occasion; either the screen goes black when compositing is enabled or everything comes back properly, but some windows are missing borders, etc. to get around this problem, i added 'kwin --replace' after the last line.

interestingly, i get the following error in pm-suspend.log:

Code: Select all
WARNING: Application calling GLX 1.3 function "glXCreatePixmap" when GLX 1.3 is not supported!  This is an application bug!
WARNING: Application calling GLX 1.3 function "glXQueryDrawable" when GLX 1.3 is not supported!  This is an application bug!
WARNING: Application calling GLX 1.3 function "glXDestroyPixmap" when GLX 1.3 is not supported!  This is an application bug!


not sure why. however, thus far, everything appears to be working properly.

i'm going to continue testing this, but the solution is promising.
dreamz
Registered Member
Posts
70
Karma
0
OS
i removed the 'kwin --replace' command and everything works (moreover, no errors). i haven't had a black screen since. i guess i didn't need it after all.

i'm marking this thread as solved. thank you again, bcooksley.
dreamz
Registered Member
Posts
70
Karma
0
OS
sorry to bring this back up, but the fix noted earlier no longer works (at least not consistently).

to get around the problem, i've created a new hook called 00restartkdm with the following code:

Code: Select all
#!/bin/bash
case $1 in
   hibernate)
       ;;
   suspend)
       ;;
   thaw)
       ;;
   resume)
       /etc/rc.d/kdm restart
       ;;
   *)
       ;;
esac


is there anything wrong with this workaround?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
As far as I am aware, there shouldn't be, assuming it works fine for you with no ill effects ( such as being thrown back to the login screen )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
dreamz
Registered Member
Posts
70
Karma
0
OS
thanks, bcooksley.

i get the splash screen upon resume, which is expected. i just want to make sure that there are no issues with security or data integrity associated with the workaround.

is there a better way to restart the graphics (x server)?

edit: i noticed this in pm-suspend.log:

Code: Select all
/etc/pm/sleep.d/00restartkdm resume suspend: :: Stopping KDE Desktop Manager    [BUSY]    [DONE]
:: Starting KDE Desktop Manager    [BUSY]    [FAIL]
success.


but kdm (and my desktop) starts properly.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
There is no issue associated with security, however if it succeeds ( which it seems to not ) then you will likely end up back at the login screen. I do not know of any method to restart the X server as such. Changing to a virtual terminal, then back to X is common to trigger the display to be reconfigured.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]