macOS: Check for display availability when looking for backends#27761
macOS: Check for display availability when looking for backends#27761QuLogic wants to merge 1 commit into
Conversation
a3255ec to
d6179de
Compare
d6179de to
e8943a0
Compare
|
I can confirm that this:
|
|
Running the tests on this branch locally without a user logged in to the desktop (so launched via ssh) I get: This suggests that what is going on the CI is slightly different than not having a display? |
|
On Actions, the display does appear to exist, according to the results from #27723: For your failures, I think that's because the macOS tests don't have a skip, so I hadn't added one (only modified existing ones.) |
e8943a0 to
bcc570b
Compare
|
I tried re-running the failed mac3.11 jobs. |
|
Looking at https://stackoverflow.com/questions/71954472/tkinter-crashes-on-ipython-but-not-in-python-on-a-m1-mac I think this might be because |
|
Ah, here's a full explanation:
but substitute the new code written here for AFAICT from Googling though, we need the Can you check if it works without the |
There was a problem hiding this comment.
@QuLogic - I'm not sure if you plan to merge this eventually, but you probably want to use CGSessionCopyCurrentDictionary() from CoreGraphics.framework to see if a GUI session is ready, rather than calling into NSApplicationLoad() which will always try to fire up AppKit and make the shared NSApplication.
The other typical approach is SessionGetInfo in Security.framework.
Both could likely live in _c_internal_utils.cpp since they aren't Obj-C APIs.
See "Getting Login Session Information" from the ancient Multiple User Environment Programming Topics documentation.
There was a problem hiding this comment.
I was actually pretty much stuck and going to ask if you had any suggestions. It looks like I'll just need to call CGSessionCopyCurrentDictionary and see if it's not NULL.
There was a problem hiding this comment.
Let me know if you have any issues. The document in question is old, and Apple changed the exact timing of when WindowServer launches when you restart and then unlock your computer.
You may need to make sure that the dictionary actually has one of the expected keys (or use the Security API).
There was a problem hiding this comment.
The main problem is that I don't have an actual mac to test... But it does appear that I did get the right incantation to build at least.
There was a problem hiding this comment.
I'll try to check in 10 hours or so when I wake up!
There was a problem hiding this comment.
@QuLogic - On my Tahoe test machine:
iccir is logged in and has a GUI session.
testuser is not logged in.
If I SSH into the machine with testuser, CGSessionCopyCurrentDictionary() returns NULL.
If I SSH into the machine with iccir, CGSessionCopyCurrentDictionary() returns a dictionary:
2026-06-12 10:44:05.818 a.out[10671:1935474] {
CGSSessionScreenIsLocked = 1;
CGSSessionScreenLockedTime = 3928769798;
CGSSessionUniqueSessionUUID = "2728BB0E-8FE4-42C1-BE6A-50D6AE021E90";
kCGSSessionAuditIDKey = 100015;
kCGSSessionGroupIDKey = 20;
kCGSSessionLoginwindowSafeLogin = 0;
kCGSSessionOnConsoleKey = 1;
kCGSSessionSystemSafeBoot = 0;
kCGSSessionUserIDKey = 501;
kCGSSessionUserNameKey = iccir;
kCGSessionLoginDoneKey = 1;
kCGSessionLongUserNameKey = iccir;
kSCSecuritySessionID = 100015;
}
bcc570b to
a1f4739
Compare
a1f4739 to
36e7a14
Compare
36e7a14 to
860d94e
Compare
|
Previously against and now: It seems like one new test ran, but that appears to be because Noto Sans CJK SC was found. For Python 3.12 and 3.13, it's the opposite. So at the least, in this PR, we aren't skipping anything new that was passing before. |
New implementation, needs re-testing.
|
This works as expected for me. Fell back to Agg when not logged in, opened a plot when logged in using the OSX backend. |
PR summary
This checks
CGSessionCopyCurrentDictionarysimilar to checking$DISPLAY/$WAYLAND_DISPLAYon Linux.Fixes #26292
PR checklist