Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and restore the osx power handler #1137

Closed
totaam opened this issue Feb 27, 2016 · 11 comments
Closed

fix and restore the osx power handler #1137

totaam opened this issue Feb 27, 2016 · 11 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Feb 27, 2016

Issue migrated from trac ticket # 1137

component: platforms | priority: critical | resolution: fixed | keywords: osx

2016-02-27 13:31:29: antoine created the issue


Split from #924 which ended up disabling the code.

@totaam
Copy link
Collaborator Author

totaam commented Mar 18, 2016

2016-03-18 11:42:24: antoine commented


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

XPRA_OSX_SLEEP_HANDLER=1 Xpra ...

@totaam
Copy link
Collaborator Author

totaam commented Mar 29, 2016

2016-03-29 06:05:02: antoine uploaded file osx_sleepwake_notification.py (1.2 KiB)

example code found here: http://stackoverflow.com/questions/31091413/

@totaam
Copy link
Collaborator Author

totaam commented Mar 29, 2016

2016-03-29 06:07:44: antoine uploaded file osx_sleep_notification.py (0.9 KiB)

example code found here: ​https://mail.python.org/pipermail/pythonmac-sig/2011-February/022916.html

@totaam
Copy link
Collaborator Author

totaam commented Mar 29, 2016

2016-03-29 08:19:25: antoine changed owner from antoine to afarr

@totaam
Copy link
Collaborator Author

totaam commented Mar 29, 2016

2016-03-29 08:19:25: antoine commented


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;
}})
register_sleep_handlers()
...
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
...

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,..)

ie:

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

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

@totaam
Copy link
Collaborator Author

totaam commented Apr 10, 2016

2016-04-10 07:18:37: antoine changed priority from major to critical

@totaam
Copy link
Collaborator Author

totaam commented Apr 10, 2016

2016-04-10 07:18:37: antoine commented


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

@totaam
Copy link
Collaborator Author

totaam commented Apr 13, 2016

2016-04-13 22:30:30: afarr changed status from new to closed

@totaam
Copy link
Collaborator Author

totaam commented Apr 13, 2016

2016-04-13 22:30:30: afarr set resolution to fixed

@totaam
Copy link
Collaborator Author

totaam commented Apr 13, 2016

2016-04-13 22:30:30: afarr commented


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).

@totaam totaam closed this as completed Apr 13, 2016
@totaam
Copy link
Collaborator Author

totaam commented Sep 6, 2016

2016-09-06 11:00:06: antoine commented


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant