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

macOS Monterey: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist) #122

Open
adams-family opened this issue Feb 14, 2022 · 9 comments

Comments

@adams-family
Copy link

I've been using ddcctl on my Display with MacBook Pro 2018 (Intel) - worked perfectly, I'm addicted to it.

Now I've replaced my laptop with a MacBook Pro 2021 (M1), installed ddctl via homebrew but unfortunately it does not work anymore - same display, same cable, just different laptop.

$ ddcctl -d 1 -c 1
D: CGDisplay C1BE29A5-BFC9-4EDA-82B0-1E638BB772F7 dispID(#3) (1920x1080 0°) HiDPI
D: CGDisplay A6A4A5E4-6D41-4340-843E-FD4361382A24 dispID(#2) (1440x900 0°) 89.00 DPI
I: found 2 external displays
E: Failed to parse WindowServer's preferences! (/Library/Preferences/com.apple.windowserver.plist)
E: Failed to acquire framebuffer device for display

I can confirm that such a file does not exist:

cat /Library/Preferences/com.apple.windowserver.plist
cat: /Library/Preferences/com.apple.windowserver.plist: No such file or directory

I searched my entire drive with "find" and I haven't found a file with such a name at all. I'm happy to help with testing if you had an idea on how to fix it.

@adams-family
Copy link
Author

Ok, I think this might be the file we are looking for?

/Library/Preferences/com.apple.windowserver.displays.plist

@adams-family
Copy link
Author

All right, I confirm that even if I change the file path to the above, the app is still failing with:

2022-02-14 16:08:21.539 ddcctl[6486:275857] D: CGDisplay C1BE29A5-BFC9-4EDA-82B0-1E638BB772F7 dispID(#2) (1920x1080 0°) HiDPI
2022-02-14 16:08:21.539 ddcctl[6486:275857] -[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x96e7084facc55e4e
2022-02-14 16:08:21.539 ddcctl[6486:275857] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x96e7084facc55e4e'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001a8f2c1cc __exceptionPreprocess + 240
	1   libobjc.A.dylib                     0x00000001a8c7d7b8 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001a8fbf1a0 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00000001a8e8c360 ___forwarding___ + 1728
	4   CoreFoundation                      0x00000001a8e8bbe0 _CF_forwarding_prep_0 + 96
	5   ddcctl                              0x0000000100c8b6bc getDisplayDeviceLocation + 428
	6   ddcctl                              0x0000000100c8c074 main + 852
	7   dyld                                0x0000000100d9d0f4 start + 520
)
libc++abi: terminating with uncaught exception of type NSException
Abort trap: 6

Which has been reported here:
#86

And I also found that my issue has already been reported here:
#114

Sorry for the duplicates. I'd love to help solving this, problem is my C programming skills are very limited.

@kfix
Copy link
Owner

kfix commented Feb 14, 2022

I'll look into removing or fixing that code but M1s are not supported yet so this is the least of your issues.

@adams-family
Copy link
Author

I made some debugging and I discovered the following:

  • the format of the two Preferences files (Monterey and Big Sur) are different, that's where the code fails as it's expecting a key in the dictionary that does not exist
  • even if I remove the code that's trying to parse the Preferences file, the IOServiceGetMatchingServices function is returning an empty iterator, so I'm not able to get through

However, I have a good news for you and for myself, as well: there is a tool called m1ddc which is very short, very straightforward and working fine on M1 and Monterey (I'm using it right now), so that could serve you as a reference. Hope it helps!

@vizcay
Copy link

vizcay commented Mar 25, 2022

However, I have a good news for you and for myself, as well: there is a tool called m1ddc which is very short, very straightforward and working fine on M1 and Monterey (I'm using it right now), so that could serve you as a reference. Hope it helps!

Unfortunately no luck for us using HDMI displays:

Please note that controlling a HDMI display via the 2020 M1 Mini's HDMI port is not working. You have to use DisplayPort over USB-C!

@azubala
Copy link

azubala commented Sep 15, 2022

@adams-family thanks for sharing the m1ddc tool!

@luco
Copy link

luco commented Dec 5, 2022

Getting this as well on i5 Mac Mini

@Takdrift
Copy link

I made some debugging and I discovered the following:

  • the format of the two Preferences files (Monterey and Big Sur) are different, that's where the code fails as it's expecting a key in the dictionary that does not exist
  • even if I remove the code that's trying to parse the Preferences file, the IOServiceGetMatchingServices function is returning an empty iterator, so I'm not able to get through

However, I have a good news for you and for myself, as well: there is a tool called m1ddc which is very short, very straightforward and working fine on M1 and Monterey (I'm using it right now), so that could serve you as a reference. Hope it helps!

m1ddc is perfect for M1 MacBook Pro, and you can change the input of display by just using a shortcut by automator, cheers!

@sunknudsen
Copy link

Thanks for sharing @Takdrift, m1ddc works like a charm.

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

7 participants