Time to time I see the error 'FAILED TO REGISTER PROCESS WITH CPS/CoreGraphics in WindowServer' if CGImageForProposedRect is called immediately after start: https://developer.apple.com/documentation/appkit/nsimage/1519861-cgimageforproposedrect
_RegisterApplication(), FAILED TO REGISTER PROCESS WITH CPS/CoreGraphics in WindowServer, err=-50
This error appears only one time during start. What does this error mean?
Thank you in advance!
First, as a broad answer, you should take a look at "On Log Noise", as this log message is a reasonable good example of the genre. Your app may have some role in the issue, but I wouldn't consider the problem all that critical unless you're having some other issues.
Getting into the specifics, reordered a bit for clarity:
Time to time I see the error 'FAILED TO REGISTER PROCESS WITH CPS/CoreGraphics in WindowServer'
_RegisterApplication(), FAILED TO REGISTER PROCESS WITH CPS/CoreGraphics in WindowServer, err=-50
What does this error mean?
When initially launched "an app" isn't really any different than any other process. It's created by launchd, then "starts running code" just like any other process. However, (typically) very early in it's launch process, it establishes a series of connections with a number of daemon's in the system, which make it "an app". "_RegisterApplication()" is one of the very early functions that initiates that process. More specifically, "_RegisterApplication()" connects your app into the ProcessManager* and then tries to connect you to the WindowServer.
*Yes, the Carbon ProcessManager still sort of exists.
The historically minded might notice that "-50" is the mac classic error code "paramErr" and that the name "_RegisterApplication()" is not exactly inline with our more modern naming conventions. While the implementation details have changed over time, the general code "flow" and frameworks involved here are very, very, very old. Much of the original implementation of this "check" process was originally written as the C layer underneath Carbon and Cocoa.
WHY exactly you failed is not a question I can really answer, as "paramErr" is the default error of the underlying function that's actually failing. You can check the console log for any additional info (look for logging from the "WindowServer" process and any message that reference "Skylight") and please post it back here if you find anything interesting.
In any case, in theory you'd think this error would be catastrophic. The connection to the WindowServer is one of the critical connections that makes your app "an app", since the WindowServer is how your app both receives input events from the system AND is able to draw out to the screen. No window server connection means you're not really "an app". However, in practice, that's not really what happens. All of this infrastructure is so critical that there are multiple connection paths so that a "failure" at one point generally ends up being hidden/covered up by a later success. All of this is also happening VERY early in your apps lifetime (for example, your app isn't visible on the screen at all), so unless the failure is permanent you're unlikely to "know" anything when wrong.
Case in point:
This error appears only one time during start.
If the problem persisted, your app wouldn't work at all.
if CGImageForProposedRect is called immediately after start
How "immediately" do you mean? If this is happening after one of the early delegate methods (say, "applicationDidFinishLaunching"), then that's deeply weird and potentially worrying. If it's happening before "applicationDidFinishLaunching", then my advice would be to avoid calling into our graphics frameworks before your app has initialized.
Also, how exactly are you running your app? Launching your app by running your app "directly" for example, by executing it's binary through terminal instead of having the system launch it, can sometimes trigger this sort of error/logging. Bypassing LaunchServices means you've (technically) violated the API contract but our frameworks tend to "self correct", so your app ends up working anyway.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware