CGDisplayIOServicePort() is deprecated with no replacement

Originator:phil
Number:rdar://22603009 Date Originated:07-Sep-2015
Status:Open Resolved:
Product:OS X SDK Product Version:OSX 10.9+
Classification:Other Bug Reproducible:Always
 
Summary:
In the Quartz Display Services API, the CGDisplayIOServicePort() function is an excellent way to establish a relationship between a display and the IODisplay object, and therefore IOFramebuffer object backing it. It has been marked as deprecated in recent versions, for no clear reason, and no replacement seems to be forthcoming.

Steps to Reproduce:
1. Use CGDisplayIOServicePort() in application code.
2. Notice that the compiler complains that the function is deprecated.
3. Look in documentation for suggested replacement.

Expected Results:
If there is a good reason to remove CGDisplayIOServicePort(), there should be a practical alternative.

Actual Results:
The documentation says:
"Deprecation Statement
There is no replacement."

Version:
OS X 10.9, 10.10, and 10.11 SDKs with Xcode 5, 6, and 7.

Notes:
I realise that there may not be a persistent link between CGDirectDisplayID and an IODisplay kernel object. Examples include GPU switching in MacBook Pros, and CGDisplays which are not backed by a kernel object (e.g. AirPlay display). This is fine. We can subscribe to reconfigurations via CGDisplayRegisterReconfigurationCallback(), and we can check whether the io_service_t handle returned by CGDisplayIOServicePort() is null. Those semantics are OK, and don't invalidate the legitimate use cases where CGDisplayIOServicePort() returns a reliable IOService object identity. There is no sensible alternative; even for a custom IOFramebuffer driver, it's not perfectly reliable to infer display identity by comparing the exported display property values with those of the IOFramebuffer object.

Configuration:
OSX 10.9 and newer.

Comments

No progress and only poor workaround on github

For some cases you can use workaround from the glfw - https://github.com/glfw/glfw/pull/511/files And it works for many cases. But there is cases when user connect 2 same displays without builtin serialnumbers, e.g. Totoku. In such situation there is no chance to distinguish 2 displays - i hope Apple will give any alternative.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!