xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.

Opened 6 years ago

Closed 6 years ago

Last modified 16 months ago

#1137 closed defect (fixed)

fix and restore the osx power handler

Reported by: Antoine Martin Owned by: alas
Priority: critical Milestone: 0.17
Component: platforms Version: trunk
Keywords: osx Cc:


Split from #924 which ended up disabling the code.

Attachments (2)

osx_sleepwake_notification.py (1.2 KB) - added by Antoine Martin 6 years ago.
example code found here: http://stackoverflow.com/questions/31091413/
osx_sleep_notification.py (946 bytes) - added by Antoine Martin 6 years ago.
example code found here: ​https://mail.python.org/pipermail/pythonmac-sig/2011-February/022916.html

Download all attachments as: .zip

Change History (8)

comment:1 Changed 6 years ago by Antoine Martin

Some related changes in r12162: different import using AppKit instead of Foundation.
As per #924, one can re-enable the power event handler with:


Changed 6 years ago by Antoine Martin

comment:2 Changed 6 years ago by Antoine Martin

Owner: changed from Antoine Martin to alas

Based on the small differences between our code and the two examples above and also seeing the changes in #965, I believe r12268 + r12269 makes our code more likely to handle the power events properly and reliably, hopefully without crashing.. (see commit messages for details).
Tested OK on a mac mini by clicking on "Sleep" in the Apple menu then waiting until the network packets stop coming through to the server, which seems to be the sign that the machine has been put to sleep proper.
So r12271 enables the power event handling code by default again, you can disable it using XPRA_OSX_SLEEP_HANDLER=0.

Does this work for you? (new osx beta uploaded):

  • power events should be logged with -d osx, and look like this:
    applicationDidFinishLaunching_(NSConcreteNotification 0x9eb5060 {name = NSApplicationDidFinishLaunchingNotification; object = <NSApplication: 0x4009a0>; userInfo = {
         NSApplicationLaunchIsDefaultLaunchKey = 1;
    receiveSleepNotification_(NSConcreteNotification 0x1b4c170 {name = NSWorkspaceWillSleepNotification; object = <NSWorkspace: 0x9eb42c0>}) sleep_callback=<bound method XpraClient.suspend of gtk2.client>
    cb(sleep_callback)=<bound method XpraClient.suspend of gtk2.client>
    system is suspending
  • it should not crash!
  • it should still restore the windows when clicking on the dock (#965 - this code was modified)

Wishlist level: when we are suspending, we should stop querying the clipboard using the timer (timer_clipboard_check). Meh.

If there is still a problem with power events (not seen at all or causing crashes), please try both code examples attached to this ticket from a terminal in the GUI session (NOT from ssh, sudo or su,..)


./Desktop/Xpra.app/Contents/Helpers/Python ./osx_sleepwake_notification.py

Do you get sleep / wake notifications with either of them? Do you get crashes?

comment:3 Changed 6 years ago by Antoine Martin

Milestone: 1.00.17
Priority: majorcritical

Raising: this should be included in 0.17 if we can.

comment:4 Changed 6 years ago by alas

Resolution: fixed
Status: newclosed

Tested with osx 0.17.0 r12380 client against 0.17.0 r12380 fedora 23 server.

Works like a charm... both when inducing sleep with the apple menu and when just setting the sleep preferences in the system preferences.

One detail that might be worth noting - if the client machine doesn't have the "Wake for network access" box checked then the client connection will timeout after 60 seconds while asleep. Checking the box though, the client seems to suspend indefinitely without timing out (maybe the clipboard querying is an awkward bonus?).

I'll go ahead and take the liberty of closing this one (also confirmed that #965 is still fixed).

comment:5 Changed 6 years ago by Antoine Martin

#1277 changes this power event delegate code to avoid warnings.

comment:6 Changed 16 months ago by migration script

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1137

Note: See TracTickets for help on using tickets.